Thread (38 messages) 38 messages, 9 authors, 2024-03-03

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

From: Jakub Kicinski <kuba@kernel.org>
Date: 2024-02-29 00:56:11
Also in: dmaengine, linux-arm-kernel, linux-hardening, linux-iio, linux-spi, lkml

On Wed, 28 Feb 2024 16:01:49 -0800 Kees Cook wrote:
So, I found several cases where struct net_device is included in the
middle of another structure, which makes my proposal more awkward. But I
also don't understand why it's in the _middle_. Shouldn't it always be
at the beginning (with priv stuff following it?)
Quick search and examined manually: git grep 'struct net_device [a-z0-9_]*;'

struct rtw89_dev
struct ath10k
etc.
Ugh, yes, the (ab)use of NAPI.
Some even have two included (?)
And some seem to be cargo-culted from out-of-tree code and are unused :S
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...
That's... less pretty. I'd rather push the ugly into the questionable
users. Make them either allocate the netdev dynamically and store 
a pointer, or move the netdev to the end of the struct.

But yeah, that's a bit of a cleanup :(
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help