Article View: linux.kernel.netdev
Article #20368Re: [PATCH net-next] net: openvswitch: avoid hashing the network namespace pointer
From: netdev-bot+sashiko
Date: Sun, 22 Nov 2026 08:52
Date: Sun, 22 Nov 2026 08:52
109 lines
11939 bytes
11939 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 replaces the pointer-derived seed in hash_bucket()
(net/openvswitch/vport.c) with a seed computed only from…
--
net: openvswitch: avoid hashing the network namespace pointer
This patch changes the seed for the Open vSwitch vport name hash. It
used the struct net pointer and now uses a jhash_2words() of the
namespace cookie. The goal is to stop a timing side channel on vport
lookups from leaking the init_net pointer and the KASLR base.
> diff --git a/net/openvswitch/vport.c b/net/openvswitch/vport.c
> index 083f7a8d9d4e4..6689c8370ec13 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);
[Severity: Medium]
This fixes the pointer leak. Does it also make bucket placement in the
global dev_table fully predictable?
In setup_net() the cookie is just the namespace id:
net/core/net_namespace.c:setup_net() {
...
net->net_cookie = to_ns_common(net)->ns_id;
...
}
For init_net, that id is the uAPI constant NET_NS_INIT_ID (7) from
include/uapi/linux/nsfs.h. For every other namespace,
__ns_tree_gen_id() hands out the next value of a global counter:
ns->ns_id = atomic64_inc_return(&namespace_cookie);
Userspace can read its own cookie with getsockopt(SO_NETNS_COOKIE). It
can find other ids through nsfs (NS_GET_ID) or listns.
That makes the init_net seed jhash_2words(7, 0, 0) on every system. The
bucket for any (netns, name) pair can then be computed offline.
The lookup oracle described in the commit message is still there.
ovs_vport_locate() walks a bucket chain that all namespaces share:
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))
OVS_VPORT_CMD_GET and OVS_DP_CMD_GET both have .flags = 0, so
unprivileged users can reach this lookup.
With a public seed, could an unprivileged user in a container learn
whether a vport or datapath name exists in init_net? The steps would be:
- pick a missing name in its own namespace that lands in the same
bucket as the candidate name
- time a GET request on the missing name
Before this patch, that attack needed the kernel pointer of the victim
namespace.
A second case: OVS_VPORT_CMD_NEW and OVS_DP_CMD_NEW only need
GENL_UNS_ADMIN_PERM, which a user has inside its own user namespace.
Could an attacker create vports with names chosen to land in the
buckets that hold another namespace's vports? Name lookups for those
vports would then walk long strcmp chains. Only control-plane name
lookups would be affected, since the datapath fast path looks ports up
by port_no in dp->ports.
A secret per-netns random value already exists:
net/core/net_namespace.c:preinit_net() {
...
net->hash_mix = get_random_u32();
...
}
Would using net_hash_mix(net) as the seed, or mixing the cookie with a
get_random_once() key, close the KASLR leak while keeping bucket
placement secret?
> +
> return &dev_table[hash & (VPORT_HASH_BUCKETS - 1)];
> }
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/4e124b37fc972925a825881c50f95eb6b3c2e231.1794989369.git.zcliangcn%40gmail.com
Technical Details
Message-ID:
<179533752531.3135.16631437077733586224@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368613-linux-kernel-netdev=dewy.ruReferences:
<4e124b37fc972925a825881c50f95eb6b3c2e231.1794989369.git.zcliangcn@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368613-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next] net: openvswitch: avoid hashing the network namespace pointer Date: Sun, 22 Nov 2026 08:52:05 +0000 Organization: Usenet Network Message-ID: <179533752531.3135.16631437077733586224@kernel.org> References: <4e124b37fc972925a825881c50f95eb6b3c2e231.1794989369.git.zcliangcn@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="3601362"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:MF4jqtZb06uJcAiPjL84J05+phc= sha256:owD0JvXvE4/0gdJOZdCBd4tbI6l6mu2aNapPsDbPlyw= sha1:04tzhASvr7M9XXydBYiI2+imfc4= sha256:oNDmbk7Ifko+yaXU9u0yKbrRG4e9WVwl2UEcv3hQX04= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 8E4E9125D72; Sun, 22 Nov 2026 11:52:31 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.4 X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Wtm5va16-sb6; Sun, 22 Nov 2026 11:52:23 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-368613-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 153CF125D6F; Sun, 22 Nov 2026 11:52:14 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 640002C5F8; Sun, 22 Nov 2026 08:52:13 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795337532; b=S6LLOZxO9IfCkrUVMhJLl/nL+iu3uSgFq04BAe7TQ5jcTmXzu1qsQxmRYnWNnGw20kvC 3H6lYfW+dGDo1+oeNKce731sPMwan8R4RhHE44YEumBnz4Slwanz71XbIjmBWCppcpV/d ZUMqM4J+eSXITwaU0aSp7ZLkMkZwl+8XN+gM4EqSQ8r/dgy3KoXwQFmhPCUaJuEgVjnZs fsJAinxbuVW2yt6Ct0MT6EjOYyYGt8PPLDv690AO806HC1PbQSnMRFY/gWaekb2nPkYqB TCLqM0xaOlEMPsyXe/aqPIsK2shATZ67j3Oy8JF1ynT8RJYEI9ZHnsLJQ4sG4MNmcVw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795337532; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=vQ1as1hC0osgBBN+KjF/Z20TmN/rtQEdZKFnWt6gL+A=; b=z45waCmirQFJ7Czsa9h8zlvicrfeR54tPRl0BEW6K8aU1ln9SJ1M71fc+4HPiD/8YMsN 0rx34tzBbzObRUHq0lhli5IOrVJwMaoloPT+MIvgYsTkfIxWEiuw6H55GeeyY1jyz8tHY lr/drQJNRzTBLK04VRTXnyMstdOVhJSWxnT2yK/cKthBKapai3f1c9VrtqQV/mk4sGGzu TG0YVBPatfdJ7Fx0ItVfonNST2R8vsX5344KGRdAT40Wq6HxhQuZaxVXa6qZjhp+Qmv+e Y5qEQVbedauW5YjfCQSjJfsMYUv+5AG6x+OX6Xi6VPkJB6cHM4/6eYBrVKUTqgS5A/Q== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=dDaDNHji; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CD354606A336; Sun, 22 Nov 2026 08:52:12 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=dDaDNHji X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795337527; b=mO4mvx/cYUc15Hgi8mKnmI1WvJsm5pnkFF+0BoEjzS1Z2W3oIqg4xaXsQ6BFsnpH8oQw dGu565QtaBz49Zd4qEwqU4atcIRbS3uKVoEDw6xmqNZLus2Qt+9Zou9YsNzZbZ3/tMtfY gt/rU2yZmosIuwqqled85nYVNMAwSc3CgClFTdV4//hcsGE+GgVqhg+1c3dQHOLuFQ2JB 1Wg8s1uJ1WrJAvJhVbNaxQA6o03csFtBv2U+7scT4jWnvkqefLkyWzLh+paQ/6IPLPey5 dPEeb3G9YqH0ZIj7+iczNR071/H3m1wato+8nveg5Lfxaek/6eT6FuoNuqs8ckHlF9Q== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795337527; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=vQ1as1hC0osgBBN+KjF/Z20TmN/rtQEdZKFnWt6gL+A=; b=blkVFsX35/BJRRFm8T8jR00YBQS585UYDcBvC+r+PVCiqUnJ3/YqASDPaAFtxmBko3zy j4urfiyNWYyxnmyRJodGUDbEaSyKpNRWLAncK91wNFuI/EKx/jYq/9Uvdw+typUu2fr2j RLbmLueTR8wCrf7N1PzKBoNqLAI8UvPiIUP/GZbP+wL5Nb/yQVQ3ZRl8ibACGnUSK/jeL zH58pBoIW7hL0ZsTWSbLBLIZwrUN8Sg4BR1qAzWAWMQOSBfJ0IEOJW1Fo1cMhWG0K3qA3 5P2sSgEY+m9kCKbu4qCtBsJWjtzDM6ku7iHhR9cPvLdXbA2EhagVk4SPwjlsuNGMZdg== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=dDaDNHji; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E732C606A32A; Sun, 22 Nov 2026 08:52:06 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id C598E1F000C0; Sun, 22 Nov 2026 08:52:05 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795337526; bh=vQ1as1hC0osgBBN+KjF/Z20TmN/rtQEdZKFnWt6gL+A=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=dDaDNHji0peunfhp+cMM9xc6K+qMeuoeQl4+IMuYTR9Ijx0uKair+8IltQluP2PXe HqfYzE6vRikROmZNg23cIKwlYS/Yj+/bzgQEV27aiv3nbzk1mAGFZwOM6CgHPi1Y6G d4zMwYxOHY1DQquX+AxaWoyCW4MkE5QQc9Bx67rkiZ8xtSKRtVtsk/JyoMHnWzSMxX fKfFEQPoQH5jTgNvv8Z0eXSBF7Z1uTvOxbmLAzrUVZWmnBXr87pzdK+b4rk45P9mxi BLpY+AsUnki3YLS8bNmdeArKyVMss5OIPUwl12CEnQyIVVnlE5vczzSudMfXSt+lJd AyT88RenkOU3A== X-Cc: aconole@redhat.com, echaudro@redhat.com, i.maximets@ovn.org, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, pshelar@nicira.com, jesse@nicira.com, netdev@vger.kernel.org, dev@openvswitch.org, linux-kernel@vger.kernel.org X-In-Reply-To: <4e124b37fc972925a825881c50f95eb6b3c2e231.1794989369.git.zcliangcn@gmail.com> X-sashiko-severity: Medium X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list