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

From: Andy Shevchenko
Date: Wed Feb 28 2024 - 16:53:43 EST


On Wed, Feb 28, 2024 at 01:46:10PM -0800, Kees Cook wrote:
> On Wed, Feb 28, 2024 at 10:41:37PM +0200, Andy Shevchenko wrote:

..

> > static inline void *netdev_priv(const struct net_device *dev)
> > {
> > - return (char *)dev + ALIGN(sizeof(struct net_device), NETDEV_ALIGN);
> > + return struct_data_pointer(dev, NETDEV_ALIGN);
> > }
>
> I really don't like hiding these trailing allocations from the compiler.
> Why can't something like this be done (totally untested):

Below is interesting idea, now at least I started understanding your previous
comments.

--
With Best Regards,
Andy Shevchenko