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: <1c7024ba-60fc-472d-982a-ab45b4f23748@kernel.org>
Date: Wed, 10 Sep 2025 15:43:00 +0900
From: Vincent Mailhol <mailhol@...nel.org>
To: Marc Kleine-Budde <mkl@...gutronix.de>
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 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?


Yours sincerely,
Vincent Mailhol


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ