Re: [PATCH] netdev: Use flexible array for trailing private bytes

From: Breno Leitao
Date: Wed Mar 06 2024 - 08:16:35 EST


On Thu, Feb 29, 2024 at 10:59:10PM -0800, Jakub Kicinski wrote:
> On Thu, 29 Feb 2024 13:30:22 -0800 Kees Cook wrote:
> > Introduce a new struct net_device_priv that contains struct net_device
> > but also accounts for the commonly trailing bytes through the "size" and
> > "data" members.
>
> I'm a bit unclear on the benefit. Perhaps I'm unaccustomed to "safe C".
>
> > As many dummy struct net_device instances exist still,
> > it is non-trivial to but this flexible array inside struct net_device
>
> put
>
> Non-trivial, meaning what's the challenge?
> We also do somewhat silly things with netdev lifetime, because we can't
> assume netdev gets freed by netdev_free(). Cleaning up the "embedders"
> would be beneficial for multiple reasons.

I've been looking at some of these embedders as reported by Kees[1], and
most of them are for dummy interfaces. I.e, they are basically used for
schedule NAPI poll.

>From that list[1], most of the driver matches with:

# git grep init_dummy_netdev

That said, do you think it is still worth cleaning up embedders for
dummy net_devices?

[1] https://lore.kernel.org/all/202402281554.C1CEEF744@keescook/