mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net-next v2] net: avoid hashing the namespace pointer for device names
@ 2026-11-18  6:26 Zhengchuan Liang
  2026-11-18  8:35 ` Eric Dumazet
  0 siblings, 1 reply; 2+ messages in thread
From: Zhengchuan Liang @ 2026-11-18  6:26 UTC (permalink / raw)
  To: David S . Miller
  Cc: Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman, netdev,
	linux-kernel, Zhengchuan Liang

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-18  8:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-18  6:26 [PATCH net-next v2] net: avoid hashing the namespace pointer for device names Zhengchuan Liang
2026-11-18  8:35 ` Eric Dumazet

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®