Netdev List
 help / color / mirror / Atom feed
From: Nicolas Dichtel <nicolas.dichtel@6wind.com>
To: Yuyang Huang <yuyanghuang@google.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>,
	Stanislav Fomichev <sdf.kernel@gmail.com>,
	netdev@vger.kernel.org, Henry Martin <bsdhenrymartin@gmail.com>
Subject: Re: [PATCH net-next] net: zero hw address entries on allocation
Date: Mon, 23 Nov 2026 11:53:39 +0100	[thread overview]
Message-ID: <77c1afb5-3a1b-419c-a36d-660c464ad307@6wind.com> (raw)
In-Reply-To: <20261122002633.584362-1-yuyanghuang@google.com>

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);


  parent reply	other threads:[~2026-11-23 10:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-22  0:26 [PATCH net-next] net: zero hw address entries on allocation Yuyang Huang
2026-11-22  0:32 ` netdev-bot+sinfo
2026-11-22  0:38   ` Yuyang Huang
2026-11-22  4:10 ` Andrew Lunn
2026-11-23 10:53 ` Nicolas Dichtel [this message]
2026-11-23 11:39   ` Yuyang Huang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=77c1afb5-3a1b-419c-a36d-660c464ad307@6wind.com \
    --to=nicolas.dichtel@6wind.com \
    --cc=bsdhenrymartin@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sdf.kernel@gmail.com \
    --cc=yuyanghuang@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox