๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
2 messages
2 total messages Started by Nicolas Dichtel Mon, 23 Nov 2026 10:53
Re: [PATCH net-next] net: zero hw address entries on allocation
#20911
Author: Nicolas Dichtel
Date: Mon, 23 Nov 2026 10:53
44 lines
12978 bytes
Le 22/11/2026 ร  01:26, Yuyang Huang a รฉcritย :
> __hw_addr_create() allocates struct netdev_hw_addr with kmalloc() and
> copies only addr_len bytes into ha->addr[MAX_ADDR_LEN], leaving the
> rest uninitialized.
> 
> If dev->addr_len later grows while entries remain (e.g., adding a
> multicast address to a down TAP device with SIOCADDMULTI and then
> switching it to ARPHRD_TUNNEL6 via TUNSETLINK), readers using
> dev->addr_len such as /proc/net/dev_mcast and AF_PACKET
> RTM_GETMULTICAST expose the uninitialized trailing slab bytes, and
> __hw_addr_add_ex() reads them in memcmp().
> 
> Switch __hw_addr_create() to kzalloc() so the unused tail of ha->addr
> is always zero.
> 
> Link: https://lore.kernel.org/netdev/179012275175.2160803.16091441325063775173@kernel.org/
> Signed-off-by: Yuyang Huang <yuyanghuang@google.com>

Henry already starts a thread on this:
https://lore.kernel.org/netdev/20261119040153.158372-1-bsdhenrymartin@gmail.com/

He will probably send a v3.

Regards,
Nicolas

> ---
>  net/core/dev_addr_lists.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/core/dev_addr_lists.c b/net/core/dev_addr_lists.c
> index b6f25e487984..ff0815d8f6a8 100644
> --- a/net/core/dev_addr_lists.c
> +++ b/net/core/dev_addr_lists.c
> @@ -100,7 +100,7 @@ __hw_addr_create(const unsigned char *addr, int addr_len,
>  	alloc_size = sizeof(*ha);
>  	if (alloc_size < L1_CACHE_BYTES)
>  		alloc_size = L1_CACHE_BYTES;
> -	ha = kmalloc(alloc_size, GFP_ATOMIC);
> +	ha = kzalloc(alloc_size, GFP_ATOMIC);
>  	if (!ha)
>  		return NULL;
>  	memcpy(ha->addr, addr, addr_len);
Re: [PATCH net-next] net: zero hw address entries on allocation
#20940
Author: henry martin
Date: Mon, 23 Nov 2026 12:21
11 lines
12051 bytes
> He will probably send a v3.

Hi Nicolas,

Thanks for pointing Yuyang to the existing thread.  v3 is posted:

https://lore.kernel.org/netdev/20261123121325.3137049-1-bsdhenrymartin@gmail.com/

Thanks,
Henry
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads