Re: [PATCH net v2] net: zero the tail of ha->addr when allocating address list entries

From: Nicolas Dichtel

Date: Thu Nov 19 2026 - 03:16:40 EST


Le 19/11/2026 à 05:01, Henry Martin a écrit :
> __hw_addr_create() allocates entries with kmalloc() and initializes only
> addr_len bytes of ha->addr. The dump paths emit each entry using the
> current dev->addr_len, so an entry that was created with a smaller
> addr_len is dumped with uninitialized tail bytes.
>
> dev->addr_len can grow after the entry was created: tun's TUNSETLINK
> changes a device from ARPHRD_NONE (addr_len 0) to ARPHRD_IP6GRE
> (addr_len 16). On v7.4-rc3, with 64 entries armed on a down tun device
> and the link type then set to ARPHRD_IP6GRE, RTM_GETMULTICAST returned
> 16 bytes per entry of which 37 were non-zero and 21 started with a
> kernel heap pointer (e.g. 0xffff8188_04857ee0); /proc/net/dev_mcast
> exposed the same bytes. This discloses stale heap contents to readers
> of those interfaces.
>
> Allocate with kzalloc(), so the tail is always zeroed and a dump can
> only emit bytes that were written or zeroed at creation. This also
> makes the explicit ha->sync_cnt = 0 initialization redundant.
>
> Cc: stable@xxxxxxxxxxxxxxx
> Fixes: a748ee242681 ("net: move address list functions to a separate file")
> Link: https://lists.openwall.net/linux-kernel/2026/09/10/320
> Signed-off-by: Henry Martin <bsdhenrymartin@xxxxxxxxx>
> Reviewed-by: Daniel Machon <daniel.machon@xxxxxxxxxxxxx>

Reviewed-by: Nicolas Dichtel <nicolas.dichtel@xxxxxxxxx>