Re: [PATCH v4 7/8] net-device: Use new helpers from overflow.h in netdevice APIs

From: Andy Shevchenko
Date: Thu Feb 29 2024 - 05:55:26 EST


On Wed, Feb 28, 2024 at 04:01:49PM -0800, Kees Cook wrote:
> On Wed, Feb 28, 2024 at 02:41:48PM -0800, Jakub Kicinski wrote:
> > On Wed, 28 Feb 2024 13:46:10 -0800 Kees Cook wrote:

..

> But I still like the idea -- Gustavo has been solving these cases with
> having two structs, e.g.:
>
> struct net_device {
> ...unchanged...
> };
>
> struct net_device_alloc {
> struct net_device dev;
> u32 priv_size;
> u8 priv_data[] __counted_by(priv_size) __aligned(NETDEV_ALIGN);
> };
>
> And internals can use struct net_device_alloc...

I just realized that I made same approach in

f6d7f050e258 ("spi: Don't use flexible array in struct spi_message definition")
75e308ffc4f0 ("spi: Use struct_size() helper")


--
With Best Regards,
Andy Shevchenko