Thread View: linux.kernel.netdev
3 messages
3 total messages
Started by Zhengchuan Liang
Thu, 19 Nov 2026 21:20
[PATCH net-next v2] net: openvswitch: avoid hashing the network namespace pointer
Author: Zhengchuan Liang
Date: Thu, 19 Nov 2026 21:20
Date: Thu, 19 Nov 2026 21:20
62 lines
13473 bytes
13473 bytes
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. Hash the cookie down to a 32-bit 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.")
Reviewed-by: Eric Dumazet <edumazet@kernel.org>
Signed-off-by: Zhengchuan Liang <zcliangcn@gmail.com>
---
Changes in v2:
- Use hash_64() rather than jhash_2words() to derive the 32-bit seed.
- Use u32 for the local hash value.
- Drop Cc: stable because this net-next change is not a stable candidate.
- Drop the deprecated Assisted-by trailer.
v1: https://lore.kernel.org/netdev/4e124b37fc972925a825881c50f95eb6b3c2e231.1794989369.git.zcliangcn@gmail.com/
---
net/openvswitch/vport.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/openvswitch/vport.c b/net/openvswitch/vport.c
index 083f7a8d9d4e..04e4df103b26 100644
--- a/net/openvswitch/vport.c
+++ b/net/openvswitch/vport.c
@@ -4,6 +4,7 @@
*/
#include <linux/etherdevice.h>
+#include <linux/hash.h>
#include <linux/if.h>
#include <linux/if_vlan.h>
#include <linux/jhash.h>
@@ -53,7 +54,8 @@ 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 hash = jhash(name, strlen(name), hash_64(net->net_cookie, 32));
+
return &dev_table[hash & (VPORT_HASH_BUCKETS - 1)];
}
--
2.34.1
Re: [PATCH net-next v2] net: openvswitch: avoid hashing the network namespace pointer
Author: patchwork-bot+netdevbpf
Date: Wed, 25 Nov 2026 02:50
Date: Wed, 25 Nov 2026 02:50
25 lines
8918 bytes
8918 bytes
Hello:
This patch was applied to netdev/net-next.git (main)
by Willem de Bruijn <willemb@google.com>:
On Thu, 19 Nov 2026 13:20:46 -0800 you wrote:
> 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.
>
> [...]
Here is the summary with links:
- [net-next,v2] net: openvswitch: avoid hashing the network namespace pointer
https://git.kernel.org/netdev/net-next/c/2239275bf3cf
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Re: [PATCH net-next v2] net: openvswitch: avoid hashing the network namespace pointer
Author: Zhengchuan Liang
Date: Wed, 25 Nov 2026 05:51
Date: Wed, 25 Nov 2026 05:51
80 lines
15329 bytes
15329 bytes
On Sun, Nov 22, 2026 at 7:46 PM Ilya Maximets <i.maximets@ovn.org> wrote:
>
> On 11/19/26 10:20 PM, Zhengchuan Liang wrote:
> > 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. Hash the cookie down to a 32-bit 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.")
> > Reviewed-by: Eric Dumazet <edumazet@kernel.org>
> > Signed-off-by: Zhengchuan Liang <zcliangcn@gmail.com>
> >
> > ---
> > Changes in v2:
> > - Use hash_64() rather than jhash_2words() to derive the 32-bit seed.
> > - Use u32 for the local hash value.
> > - Drop Cc: stable because this net-next change is not a stable candidate.
> > - Drop the deprecated Assisted-by trailer.
> >
> > v1: https://lore.kernel.org/netdev/4e124b37fc972925a825881c50f95eb6b3c2e231.1794989369.git.zcliangcn@gmail.com/
> > ---
> > net/openvswitch/vport.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/net/openvswitch/vport.c b/net/openvswitch/vport.c
> > index 083f7a8d9d4e..04e4df103b26 100644
> > --- a/net/openvswitch/vport.c
> > +++ b/net/openvswitch/vport.c
> > @@ -4,6 +4,7 @@
> > */
> >
> > #include <linux/etherdevice.h>
> > +#include <linux/hash.h>
> > #include <linux/if.h>
> > #include <linux/if_vlan.h>
> > #include <linux/jhash.h>
> > @@ -53,7 +54,8 @@ 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 hash = jhash(name, strlen(name), hash_64(net->net_cookie, 32));
> > +
> Sashiko had a nice comment about using net_hash_mix() as a seed, which
> seems to be a good idea as it fits the use case pretty well.
>
> Best regards, Ilya Maximets.
That would allow an attacker to recover the 32-bit net_hash_mix, which
is reused by other networking hash tables.
Best, Zhengchuan
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