lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250910-quaint-weightless-narwhal-658e26-mkl@pengutronix.de>
Date: Wed, 10 Sep 2025 12:55:22 +0200
From: Marc Kleine-Budde <mkl@...gutronix.de>
To: Vincent Mailhol <mailhol@...nel.org>
Cc: Oliver Hartkopp <socketcan@...tkopp.net>, 
	Stéphane Grosjean <stephane.grosjean@...-networks.com>, Robert Nawrath <mbro1689@...il.com>, 
	Minh Le <minh.le.aj@...esas.com>, Duy Nguyen <duy.nguyen.rh@...esas.com>, 
	linux-can@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 04/20] can: netlink: refactor can_validate_bittiming()

On 10.09.2025 15:43:00, Vincent Mailhol wrote:
> On 10/09/2025 at 15:13, Marc Kleine-Budde wrote:
> > On 10.09.2025 15:03:29, Vincent Mailhol wrote:
> >> Whenever can_validate_bittiming() is called, it is always preceded by
> >> some boilerplate code which was copy pasted all over the place. Move
> >> that repeated code directly inside can_validate_bittiming().
> >>
> >> Finally, the mempcy() is not needed. Just use the pointer returned by
> >> nla_data() as-is.
> > 
> > The memcpy()'ed struct is guaranteed to be properly aligned, is this
> > also the case for the casted nla_data() pointer?
> 
> The NLA attributes are aligned on 4 bytes, c.f. NLA_ALIGNTO:
> 
> https://elixir.bootlin.com/linux/v6.16.5/source/include/uapi/linux/netlink.h#L248
> 
> Which is sufficient for struct can_bittiming which also requires just 4 bytes of
> alignment as proven by the fact the the code would still compile if I add this
> static assert:
> 
>   static_assert(_Alignof(typeof(*bt)) <= NLA_ALIGNTO);
> 
> But I have to admit that you caught me off guard. I did not think of that. Maybe
> I should add above static assertions to the code to document that what we are
> doing is correct?

Yes, make it so!

regards,
Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde          |
Embedded Linux                   | https://www.pengutronix.de |
Vertretung Nürnberg              | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-9   |

Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ