From: Zhengchuan Liang <zcliangcn@gmail.com>
To: "David S . Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Zhengchuan Liang <zcliangcn@gmail.com>
Subject: [PATCH net-next v2] net: avoid hashing the namespace pointer for device names
Date: Tue, 17 Nov 2026 22:26:52 -0800 [thread overview]
Message-ID: <c9b3c1a0e3410ffa70db448e2299ed420528b5ff.1794981913.git.zcliangcn@gmail.com> (raw)
dev_name_hash() salts device-name hashes with the network namespace
pointer. An unprivileged user can time SIOCGIFINDEX lookups for chosen
missing names and identify collisions with a resident name such as "lo".
Ranking this collision pattern across possible KASLR slides recovers the
init_net pointer and thus the kernel text base.
Use an unsalted name hash. Each network namespace has a separate hash
table, so this does not change lookup or namespace-isolation semantics.
Found by AI-assisted code review and reproduced unprivileged on an
unmodified kernel without fault injection. The reproducer and networking
selftests pass with this change.
Fixes: 8387ff2577eb ("vfs: make the string hashes salt the hash")
Cc: stable@vger.kernel.org
Assisted-by: LLM
Signed-off-by: Zhengchuan Liang <zcliangcn@gmail.com>
---
Changes in v2:
- Pass NULL instead of net_hash_mix(), which would expose a seed shared
by other per-network namespace hash tables.
- Target net-next, as requested by Eric.
v1: https://lore.kernel.org/all/62774f8c6cbad549d1a95f88df99ab7745d7f6b8.1790917676.git.zcliangcn@gmail.com/
net/core/dev.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/core/dev.c b/net/core/dev.c
index d88af07aea29..12100fbf9022 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -195,7 +195,7 @@ static inline void dev_base_seq_inc(struct net *net)
static inline struct hlist_head *dev_name_hash(struct net *net, const char *name)
{
- unsigned int hash = full_name_hash(net, name, strnlen(name, IFNAMSIZ));
+ unsigned int hash = full_name_hash(NULL, name, strnlen(name, IFNAMSIZ));
return &net->dev_name_head[hash_32(hash, NETDEV_HASHBITS)];
}
--
2.34.1
next reply other threads:[~2026-11-18 6:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 6:26 Zhengchuan Liang [this message]
2026-11-18 8:35 ` Eric Dumazet
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=c9b3c1a0e3410ffa70db448e2299ed420528b5ff.1794981913.git.zcliangcn@gmail.com \
--to=zcliangcn@gmail.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=pabeni@redhat.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
all inboxes | Powered by JetHome®