🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
4 messages
4 total messages Started by Zhengchuan Liang Wed, 18 Nov 2026 06:26
[PATCH net-next v2] net: avoid hashing the namespace pointer for device names
#18335
Author: Zhengchuan Liang
Date: Wed, 18 Nov 2026 06:26
44 lines
12395 bytes
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
Re: [PATCH net-next v2] net: avoid hashing the namespace pointer for device names
#18369
Author: Eric Dumazet
Date: Wed, 18 Nov 2026 08:35
28 lines
9995 bytes
Le mer. 18 nov. 2026 à 07:27, Zhengchuan Liang <zcliangcn@gmail.com> a écrit :
>
> 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

As discussed in v1, local KASLR attacks are not a serious concern,
this is why I asked for net-next.

A "Cc: stable" tag does not belong in a net-next patch.

Maintainers can probably remove it when applying, no need for a V3.

Reviewed-by: Eric Dumazet <edumazet@kernel.org>
Re: [PATCH net-next v2] net: avoid hashing the namespace pointer for device names
#20347
Author: netdev-bot+sashiko
Date: Sun, 22 Nov 2026 06:43
85 lines
11136 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] The patch fixes only dev_name_hash().

--

net: avoid hashing the namespace pointer for device names

This commit changes dev_name_hash() to call full_name_hash() with no salt,
where it used to salt with the struct net pointer. The goal is to stop
unprivileged users from recovering init_net and the kernel text base by
timing name lookups that collide in the hash table.

> diff --git a/net/core/dev.c b/net/core/dev.c
> index d88af07aea290..12100fbf9022a 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)];
>  }

[Severity: Medium]
This fixes dev_name_hash(). Is there still a similar name hash in Open
vSwitch that uses the struct net pointer as its seed?

net/openvswitch/vport.c:hash_bucket() {
	unsigned int hash = jhash(name, strlen(name), (unsigned long) net);
	return &dev_table[hash & (VPORT_HASH_BUCKETS - 1)];
}

jhash() takes a u32 initval, so the seed is the low 32 bits of the net
pointer. On x86-64 those low bits contain the KASLR slide of init_net.

ovs_vport_locate() then walks the bucket with strcmp() and net_eq(). The
lookup time therefore depends on whether a probe name shares a bucket with
a resident vport:

net/openvswitch/vport.c:ovs_vport_locate() {
	struct hlist_head *bucket = hash_bucket(net, name);
	...
	hlist_for_each_entry_rcu(vport, bucket, hash_node,
				 lockdep_ovsl_is_held())
		if (!strcmp(name, ovs_vport_name(vport)) &&
		    net_eq(ovs_dp_get_net(vport->dp), net))
			return vport;
	...
}

Unprivileged users can reach this lookup with a name they choose, since
both commands use .flags = 0:

  OVS_VPORT_CMD_GET -> lookup_vport() -> ovs_vport_locate()
  OVS_DP_CMD_GET -> lookup_datapath() -> ovs_vport_locate()

Take a host with OVS vports in init_net, such as ovs-system or br-int.
Could the collision-timing method in the commit message still recover
init_net through this path? It has not been shown that one extra strcmp()
can be measured through genetlink, which adds more timing noise.

A grep of net/ suggests this is the only hash left that uses the net
pointer as its seed. The commit message doesn't mention it.

dev_table is one global table of VPORT_HASH_BUCKETS buckets, shared by
every namespace. Would it need a random seed instead of NULL? Options
include get_random_u32() in ovs_vport_init() or net_hash_mix(). This
could be done as a separate follow-up.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/c9b3c1a0e3410ffa70db448e2299ed420528b5ff.1794981913.git.zcliangcn%40gmail.com
Re: [PATCH net-next v2] net: avoid hashing the namespace pointer for device names
#21748
Author: patchwork-bot+netdevbpf
Date: Tue, 24 Nov 2026 12:20
26 lines
8827 bytes
Hello:

This patch was applied to netdev/net-next.git (main)
by Paolo Abeni <pabeni@redhat.com>:

On Tue, 17 Nov 2026 22:26:52 -0800 you wrote:
> 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.
> 
> [...]

Here is the summary with links:
  - [net-next,v2] net: avoid hashing the namespace pointer for device names
    https://git.kernel.org/netdev/net-next/c/a4c450594f5d

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads