From: Henry Martin <bsdhenrymartin@gmail.com>
To: Paolo Abeni <pabeni@redhat.com>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Simon Horman <horms@kernel.org>,
Stanislav Fomichev <sdf.kernel@gmail.com>,
Nicolas Dichtel <nicolas.dichtel@6wind.com>,
Yuyang Huang <sigefriedhyy@gmail.com>,
Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Henry Martin <bsdhenrymartin@gmail.com>,
stable@vger.kernel.org,
Daniel Machon <daniel.machon@microchip.com>
Subject: [PATCH net v2] net: zero the tail of ha->addr when allocating address list entries
Date: Thu, 19 Nov 2026 12:01:52 +0800 [thread overview]
Message-ID: <20261119040153.158372-1-bsdhenrymartin@gmail.com> (raw)
__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@vger.kernel.org
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@gmail.com>
Reviewed-by: Daniel Machon <daniel.machon@microchip.com>
---
v1 -> v2:
- allocate with kzalloc() and drop the manual ha->sync_cnt = 0, as
suggested by Eric Dumazet and Daniel Machon
- add the runtime observation to the changelog
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 d827cc21867b..9613c8a9ed7f 100644
--- a/net/core/dev_addr_lists.c
+++ b/net/core/dev_addr_lists.c
@@ -96,7 +96,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);
@@ -104,7 +104,6 @@ __hw_addr_create(const unsigned char *addr, int addr_len,
ha->refcount = 1;
ha->global_use = global;
ha->synced = sync ? 1 : 0;
- ha->sync_cnt = 0;
return ha;
}
--
2.43.7
next reply other threads:[~2026-11-19 4:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 4:01 Henry Martin [this message]
2026-11-19 4:07 ` netdev-bot+sinfo
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=20261119040153.158372-1-bsdhenrymartin@gmail.com \
--to=bsdhenrymartin@gmail.com \
--cc=aleksandr.loktionov@intel.com \
--cc=daniel.machon@microchip.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nicolas.dichtel@6wind.com \
--cc=pabeni@redhat.com \
--cc=sdf.kernel@gmail.com \
--cc=sigefriedhyy@gmail.com \
--cc=stable@vger.kernel.org \
/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
all inboxes | Powered by JetHome®