* [PATCH net-next] net: openvswitch: avoid hashing the network namespace pointer
@ 2026-11-18 8:37 Zhengchuan Liang
2026-11-18 8:49 ` Eric Dumazet
0 siblings, 1 reply; 3+ messages in thread
From: Zhengchuan Liang @ 2026-11-18 8:37 UTC (permalink / raw)
To: Aaron Conole
Cc: Eelco Chaudron, Ilya Maximets, David S . Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman, Pravin B Shelar,
Jesse Gross, netdev, dev, linux-kernel, Zhengchuan Liang
The Open vSwitch vport name table uses the network namespace pointer as
the Jenkins hash seed. When an Open vSwitch vport already exists in the
attacker's network namespace, unprivileged OVS_VPORT_CMD_GET requests can
look up attacker-chosen missing names and time whether those lookups
traverse an occupied bucket. Ranking the resulting collision pattern
across possible KASLR slides recovers the init_net pointer and thus the
kernel text base.
Use the namespace cookie instead. It is a stable, unique, non-address
identifier that is deliberately exposed to userspace. setup_net() assigns
it before per-net initializers run, and it remains unchanged for the
namespace lifetime. Fold both halves into the seed so vports in different
namespaces retain namespace-dependent bucket placement.
Found by AI-assisted code review and reproduced on an unmodified kernel
without fault injection. After privileged setup created the resident
vport, the timing measurements ran as an unprivileged user with no
effective capabilities. With this change, the pointer-derived prediction
fails. Existing and missing vport lookups behave as expected. Identically
named vports in separate network namespaces remain independent.
Fixes: 46df7b814548 ("openvswitch: Add support for network namespaces.")
Cc: stable@vger.kernel.org
Assisted-by: LLM
Signed-off-by: Zhengchuan Liang <zcliangcn@gmail.com>
---
net/openvswitch/vport.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/net/openvswitch/vport.c b/net/openvswitch/vport.c
index 083f7a8d9d4e..6689c8370ec1 100644
--- a/net/openvswitch/vport.c
+++ b/net/openvswitch/vport.c
@@ -53,7 +53,10 @@ void ovs_vport_exit(void)
static struct hlist_head *hash_bucket(const struct net *net, const char *name)
{
- unsigned int hash = jhash(name, strlen(name), (unsigned long) net);
+ u32 seed = jhash_2words(lower_32_bits(net->net_cookie),
+ upper_32_bits(net->net_cookie), 0);
+ unsigned int hash = jhash(name, strlen(name), seed);
+
return &dev_table[hash & (VPORT_HASH_BUCKETS - 1)];
}
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH net-next] net: openvswitch: avoid hashing the network namespace pointer
2026-11-18 8:37 [PATCH net-next] net: openvswitch: avoid hashing the network namespace pointer Zhengchuan Liang
@ 2026-11-18 8:49 ` Eric Dumazet
2026-11-18 11:02 ` Ilya Maximets
0 siblings, 1 reply; 3+ messages in thread
From: Eric Dumazet @ 2026-11-18 8:49 UTC (permalink / raw)
To: Zhengchuan Liang
Cc: Aaron Conole, Eelco Chaudron, Ilya Maximets, David S . Miller,
Jakub Kicinski, Paolo Abeni, Simon Horman, Pravin B Shelar,
Jesse Gross, netdev, dev, linux-kernel
Le mer. 18 nov. 2026 à 09:40, Zhengchuan Liang <zcliangcn@gmail.com> a écrit :
>
> The Open vSwitch vport name table uses the network namespace pointer as
> the Jenkins hash seed. When an Open vSwitch vport already exists in the
> attacker's network namespace, unprivileged OVS_VPORT_CMD_GET requests can
> look up attacker-chosen missing names and time whether those lookups
> traverse an occupied bucket. Ranking the resulting collision pattern
> across possible KASLR slides recovers the init_net pointer and thus the
> kernel text base.
>
> Use the namespace cookie instead. It is a stable, unique, non-address
> identifier that is deliberately exposed to userspace. setup_net() assigns
> it before per-net initializers run, and it remains unchanged for the
> namespace lifetime. Fold both halves into the seed so vports in different
> namespaces retain namespace-dependent bucket placement.
>
> Found by AI-assisted code review and reproduced on an unmodified kernel
> without fault injection. After privileged setup created the resident
> vport, the timing measurements ran as an unprivileged user with no
> effective capabilities. With this change, the pointer-derived prediction
> fails. Existing and missing vport lookups behave as expected. Identically
> named vports in separate network namespaces remain independent.
>
> Fixes: 46df7b814548 ("openvswitch: Add support for network namespaces.")
> Cc: stable@vger.kernel.org
Same remark as for your dev_name_hash() patch: local KASLR attacks are
not a serious concern, a "Cc: stable" tag does not belong in a
net-next patch.
> Assisted-by: LLM
> Signed-off-by: Zhengchuan Liang <zcliangcn@gmail.com>
> ---
> net/openvswitch/vport.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/net/openvswitch/vport.c b/net/openvswitch/vport.c
> index 083f7a8d9d4e..6689c8370ec1 100644
> --- a/net/openvswitch/vport.c
> +++ b/net/openvswitch/vport.c
> @@ -53,7 +53,10 @@ void ovs_vport_exit(void)
>
> static struct hlist_head *hash_bucket(const struct net *net, const char *name)
> {
> - unsigned int hash = jhash(name, strlen(name), (unsigned long) net);
> + u32 seed = jhash_2words(lower_32_bits(net->net_cookie),
> + upper_32_bits(net->net_cookie), 0);
Nit: hash_64(net->net_cookie, 32) would be simpler.
Reviewed-by: Eric Dumazet <edumazet@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH net-next] net: openvswitch: avoid hashing the network namespace pointer
2026-11-18 8:49 ` Eric Dumazet
@ 2026-11-18 11:02 ` Ilya Maximets
0 siblings, 0 replies; 3+ messages in thread
From: Ilya Maximets @ 2026-11-18 11:02 UTC (permalink / raw)
To: Eric Dumazet, Zhengchuan Liang
Cc: Aaron Conole, Eelco Chaudron, Ilya Maximets, David S . Miller,
Jakub Kicinski, Paolo Abeni, Simon Horman, netdev, dev,
linux-kernel
On 11/18/26 9:49 AM, Eric Dumazet wrote:
> Le mer. 18 nov. 2026 à 09:40, Zhengchuan Liang <zcliangcn@gmail.com> a écrit :
>>
>> The Open vSwitch vport name table uses the network namespace pointer as
>> the Jenkins hash seed. When an Open vSwitch vport already exists in the
>> attacker's network namespace, unprivileged OVS_VPORT_CMD_GET requests can
>> look up attacker-chosen missing names and time whether those lookups
>> traverse an occupied bucket. Ranking the resulting collision pattern
>> across possible KASLR slides recovers the init_net pointer and thus the
>> kernel text base.
>>
>> Use the namespace cookie instead. It is a stable, unique, non-address
>> identifier that is deliberately exposed to userspace. setup_net() assigns
>> it before per-net initializers run, and it remains unchanged for the
>> namespace lifetime. Fold both halves into the seed so vports in different
>> namespaces retain namespace-dependent bucket placement.
>>
>> Found by AI-assisted code review and reproduced on an unmodified kernel
>> without fault injection. After privileged setup created the resident
>> vport, the timing measurements ran as an unprivileged user with no
>> effective capabilities. With this change, the pointer-derived prediction
>> fails. Existing and missing vport lookups behave as expected. Identically
>> named vports in separate network namespaces remain independent.
>>
>> Fixes: 46df7b814548 ("openvswitch: Add support for network namespaces.")
>> Cc: stable@vger.kernel.org
>
> Same remark as for your dev_name_hash() patch: local KASLR attacks are
> not a serious concern, a "Cc: stable" tag does not belong in a
> net-next patch.
>
>> Assisted-by: LLM
>> Signed-off-by: Zhengchuan Liang <zcliangcn@gmail.com>
>> ---
>> net/openvswitch/vport.c | 5 ++++-
>> 1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/net/openvswitch/vport.c b/net/openvswitch/vport.c
>> index 083f7a8d9d4e..6689c8370ec1 100644
>> --- a/net/openvswitch/vport.c
>> +++ b/net/openvswitch/vport.c
>> @@ -53,7 +53,10 @@ void ovs_vport_exit(void)
>>
>> static struct hlist_head *hash_bucket(const struct net *net, const char *name)
>> {
>> - unsigned int hash = jhash(name, strlen(name), (unsigned long) net);
>> + u32 seed = jhash_2words(lower_32_bits(net->net_cookie),
>> + upper_32_bits(net->net_cookie), 0);
>
> Nit: hash_64(net->net_cookie, 32) would be simpler.
I agree. Also, both jhash* and hash_64 actually return u32, so we should
probably swap the type of the local 'hash' variable here as well. Having
a mix of u32 and unsigned int for the values of the same nature within the
same function is not the greatest.
Otherwise, the change looks fine to me.
Best regards, Ilya Maximets.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-18 11:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-18 8:37 [PATCH net-next] net: openvswitch: avoid hashing the network namespace pointer Zhengchuan Liang
2026-11-18 8:49 ` Eric Dumazet
2026-11-18 11:02 ` Ilya Maximets
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®