Article View: linux.kernel.netdev
Article #19245Re: [PATCH net v2] tcp_metrics: hash the destination address with SipHash
From: netdev-bot+sashiko
Date: Thu, 19 Nov 2026 16:12
Date: Thu, 19 Nov 2026 16:12
118 lines
12309 bytes
12309 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] In net/ipv4/tcp_metrics.c, tcpm_addr_hash() hashes only the
peer address, with one global key (tcpm_hash_key) shared by every…
--
tcp_metrics: hash the destination address with SipHash
This commit changes how a tcp_metrics bucket is picked. It used the
ipv4_addr_hash()/ipv6_addr_hash() fold of the peer address and now uses
SipHash of the address with a random key. The goal is to stop attackers
from computing colliding addresses and recovering net_hash_mix(), which
is still XORed in afterwards to separate namespaces.
> diff --git a/net/ipv4/tcp_metrics.c b/net/ipv4/tcp_metrics.c
> index ae551546422fe..1d6c88bc35cc8 100644
> --- a/net/ipv4/tcp_metrics.c
> +++ b/net/ipv4/tcp_metrics.c
[ ... ]
> @@ -95,6 +96,22 @@ static unsigned int tcp_metrics_hash_log __read_mostly;
> static DEFINE_SPINLOCK(tcp_metrics_lock);
> static DEFINE_SEQLOCK(fastopen_seqlock);
>
> +static siphash_aligned_key_t tcpm_hash_key __read_mostly;
> +
> +static u32 tcpm_addr_hash(const struct inetpeer_addr *a)
> +{
> + net_get_random_once(&tcpm_hash_key, sizeof(tcpm_hash_key));
> +
> + if (a->family == AF_INET)
> + return siphash_1u32((__force u32)a->a4.addr, &tcpm_hash_key);
> +
> + return siphash_4u32((__force u32)a->a6.s6_addr32[0],
> + (__force u32)a->a6.s6_addr32[1],
> + (__force u32)a->a6.s6_addr32[2],
> + (__force u32)a->a6.s6_addr32[3],
> + &tcpm_hash_key);
> +}
> +
[ ... ]
> @@ -329,6 +342,7 @@ static struct tcp_metrics_block *tcp_get_metrics(struct sock *sk,
> return NULL;
>
> net = sock_net(sk);
> + hash = tcpm_addr_hash(&daddr);
> hash ^= net_hash_mix(net);
> hash = hash_32(hash, tcp_metrics_hash_log);
[Severity: Medium]
Is net_hash_mix() still enough to keep the namespaces apart here?
tcpm_addr_hash() takes no netns input and uses one global tcpm_hash_key.
So S(addr) = siphash(addr, tcpm_hash_key) is the same in every netns. The
namespace only comes in after that, in tcp_get_metrics(),
__tcp_get_metrics_req() and the netlink paths through __parse_nl_addr().
For two namespaces A and B, the bucket maps then differ only by the
constant mix_A ^ mix_B. That constant is applied before the invertible
multiply in hash_32(). This is the XOR-then-multiply structure the
changelog calls not a PRF.
tcp_metrics_hash is global. A local user who owns a netns (a container,
or unshare -Urn where unprivileged user namespaces are allowed) seems to
have both oracles the attack needs:
- tcpm_new() reclaim reuses the oldest entry in the bucket no matter
which netns owns it. So another netns, such as init_net, can evict
the user's own entries.
- TCP_METRICS_CMD_GET has no GENL_ADMIN_PERM and the family is
netnsok. tcp_metrics_nl_dump() returns the caller's own entries in
bucket order.
Because S(X) is shared, take an address X that the attacker controls.
If X collides with a victim address V in the attacker's own namespaces,
it also collides in the victim's netns.
Another route is to solve for mix_A ^ mix_B from cross-netns evictions.
Either way, the attacker could watch V's bucket in the victim netns and
tell whether V connected.
It isn't clear how cheap this is in practice. The S-collision route needs
on the order of 2^32 own-netns tests. The other route needs more than the
few hundred answers described for the remote attack.
Still, the changelog says:
net_hash_mix() and hash_32() are kept, to separate
namespaces and to reduce the result to the table size.
With this construction the namespaces don't get independent bucket maps.
Could the namespace be part of the keyed hash input instead? For IPv4
that could be siphash_2u32(addr, net_hash_mix(net), &tcpm_hash_key), and
IPv6 could add the mix to its input the same way. inet_ehashfn() does
something similar: it feeds net_hash_mix(net) into the hash seed instead
of XORing it into the output.
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261117041029.80543-1-juanagusnicco%40gmail.com
Technical Details
Message-ID:
<179510476492.3136.15185317023274420078@kernel.org>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-367141-linux-kernel-netdev=dewy.ruReferences:
<20261117041029.80543-1-juanagusnicco@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-367141-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net v2] tcp_metrics: hash the destination address with SipHash Date: Thu, 19 Nov 2026 16:12:44 +0000 Organization: Usenet Network Message-ID: <179510476492.3136.15185317023274420078@kernel.org> References: <20261117041029.80543-1-juanagusnicco@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2922814"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:LZNY+t4cYB9S7JBQsHEtHQP1dEM= sha256:MH5SKR0nxZnMpPORo4+HOvT6SZ33quwenB8ICfQGl9s= sha1:pYUJSKFMeghNaMC7coiFLsoSNSw= sha256:CMX8yHpqTr6FpQNiyVgDiE3HQfUFSAmceb1Vrc/Kvzs= 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 BB5F11156DF; Thu, 19 Nov 2026 19:13:18 +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 ULvdcJgZiZWu; Thu, 19 Nov 2026 19:13:15 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-367141-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id A957F1156BA; Thu, 19 Nov 2026 19:13:06 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id EBD56E8B39; Thu, 19 Nov 2026 16:12:55 +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=1795104772; b=r4GgOMmKtiEr6Y1OrGYLwgQ4JmTcP2OzNeF9mE9cC6W2lOxpkB9E3MRNOiHPhFNXOGo6 RkYqSngQcglAxWoj4NDy7cF3bSa7ZAQo4O2SetoJd+MYWpF/UCv/Lf4ZmlKgO/jGLzJOj dKA9ok6RWiHK3YOOviYYkllNxzcGP6BxESohVGFjVZPqLPtAEs9N1+eVbUIaQTuw4Bimj 5m3vE0AnGpYKCV00QqEGZPJ0/19p1HVQg1RA2WPLhLTMZMnoiAki9q3rGH66pd0R+amWG P2FAera7wVsza0wyB2aTf3C+QWYbqTBut5EJWSTXV8tKHFO8UX1Ur/IlY+8VWpMhDzA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795104772; 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=cznu7/FJf5X6yA8PX2MK/dNb3k5+oDDvUDyT6bScaDk=; b=G8x/prGumNwuTxe7qI2xLNc7O1ASXy1IsWgWqYPwaLHD0OJekT0aSwwgs3W3rG0cFpzB INnjMs/vothVv6UNjb0n2Y93QNM0VAuNazVycDOKc752il1HhXJAXioEj+VVYM8SAH4dK s2VSXmfzP1oXGlK51c35CA/8Hjftu0mSx43ixSFgeu/eeHKEqiNpclKLZER4pMWXMnUy+ bfn2Z/L8eDkszLkQU79MMoXwHddsISQuY/LacWDKgerkfzRnS/XWM+No1JhoQViVzaxro i1XXCcApRWmVvw5f/0JUjYRjAuBRiIseK79ZTWjtiog04RMYfwNZGa5gdb5EgQZxsOw== 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=bkOC4kD0; 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 35776606A333; Thu, 19 Nov 2026 16:12:52 +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=bkOC4kD0 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=1795104766; b=txUQY6RH9WmwdP/Ctmnrth/TnPzXuhO2hpP0asIkrzXQmxmfkbS/utzJtErqk+cwx8gv LXoEeRGvcgD275IpJ7MfriXt4LYU2WKODnVKfvVlM/qbGA91TEZelLvq3qBjIoheVnBFs 4EmunLujrL/KFEZiPd2pyJPR8QMYBu5/QefTdTbGD23RIGMXLdKr0x6skRy7Awu7BEq4O itFwOg8IeHmvz1rZCKAvl0uxJmIULCorS30pc5R/k5X0WFv7yXZQeI8qvEes4tSO9jqcp YQX9jBiiv5MfHpoBFbORUVRpT5PvCP8l9xKdn2fW/sfQfB1yjjutEIVd7Kq0wxQtkMA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795104766; 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=cznu7/FJf5X6yA8PX2MK/dNb3k5+oDDvUDyT6bScaDk=; b=wRks5/TffaoYq3APtA8M/6HbKS5m5CKGn0tNPVRYKDk+fkK7TmoIr8ko1bJ+SEkmWXbB M/l0Arl5MOQDLoiHuYuM3Q3oJtzY+UuT2kM9xb4dFGYIKSp4CeBG69e5/YR/LwjUQPsP7 6IVYyk3QjDyNJ/MbT00k4KZRPSo8IooCn8hwRIdPJ97xJ1WksJvGrOSuM0NH6RYepky+E iH1TNrALl7R4MsVKyoLzFRtp/i2QVEHVIt7bTNCPj3oOYJZCwAKpaCb1Vx5LDI4EzL+2Z seOI4uRSgqQ8IhYnthuHsnjAlMe0UOUbiqcv5H3OlOoqhyquHBJ/n8L2xNhxgeV95pg== 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=bkOC4kD0; 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 53CEF606A320; Thu, 19 Nov 2026 16:12:46 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 60FBF1F000C7; Thu, 19 Nov 2026 16:12:45 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795104765; bh=cznu7/FJf5X6yA8PX2MK/dNb3k5+oDDvUDyT6bScaDk=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=bkOC4kD0LhiZeN4Uli/ZwTrewOsKke9SpIvQAfaLu9fZNjL/k/vMYywG/5gMQxf3Z bVZYzJ5If6KyWfAaAoFiuhqjdeKonkvnUYbFSdXXKhucO+66OMpPJxvgyMLCuTwfRc Snp3k0PrWCQSx8hFGA4QlefSO4jwPhuRoRLXsj1//0JnQvi20LWa5H6Qa0+i/f2fDX GuOj9Fv6PdwEdWqcSScEj51oq589gPTB+ASR6MougyL7ehVONdi3aGQy9qGgv6EMtE /LXG68E1SVdAqFjs7Iq0uXq/3CXoFaT0NwHYGgUvCeNwL4mpiSuLDPhtFXZso2wUFm UHxgiXj9rA7nQ== X-Cc: edumazet@kernel.org, ncardwell@google.com, kuniyu@google.com, davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org X-In-Reply-To: <20261117041029.80543-1-juanagusnicco@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