🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #1579

Re: [PATCH net v2] ipv4: fib_trie: prevent speculative out-of-bounds child access

#1579
From: Eric Dumazet
Date: Sat, 10 Oct 2026 06:32
68 lines
9553 bytes
Le sam. 10 oct. 2026 à 07:37, Daniël Trujillo via B4 Relay
<devnull+datrujillo.nvidia.com@kernel.org> a écrit :
>
> From: Daniël Trujillo <datrujillo@nvidia.com>
>
> fib_table_lookup() checks the child index against the bounds before
> passing it to get_child_rcu().
>
> The index is derived from the lookup key, which in turn is derived from
> flp->daddr. A userspace process can therefore influence the index by
> triggering lookups for chosen destination IPv4 addresses.
>
> If this bounds check is mispredicted as in-bounds, an out-of-bounds index
> can be transiently passed to get_child_rcu(). The value loaded beyond the
> child array is then treated as a node pointer. A later transient
> dereference of that pointer can cause a data-dependent cache footprint.
>
> This was found during Spectre-v1 research. Leakage was demonstrated with
> instrumentation that delays branch resolution with a CLFLUSH before the
> mispredicted branch and makes the leaked location
> deterministic for reproducible measurement. In that setup, a
> userspace-controlled IPv4 lookup key was able to trigger a transient
> out-of-bounds child access. The transient use of the loaded value as a
> pointer caused a data-dependent cache footprint that was recoverable from
> userspace using Prime+Probe. A real-world attacker would likely
> need to delay branch resolution, which was not demonstrated end-to-end
> without the added CLFLUSH.
>
> Sanitize the index with array_index_nospec() before accessing the child
> array. This removed the observed leakage in the described setup.
>
> Apply the hardening before setting cindex in fib_table_lookup(), because
> cindex can later be used by the backtrace path to load another child
> pointer. fib_find_node() has the same pattern, with the checked index
> derived from a user-provided key in fib_table_insert() and
> fib_table_delete(). leaf_walk_rcu() has a similar checked cindex before
> get_child_rcu(), and the traversed state can be influenced by userspace
> actions. fib_find_node() runs under RTNL and
> leaf_walk_rcu() is not on the packet lookup hot path, so harden those
> analogous accesses in the same way.
>
> Fixes: 9f9e636d4f89 ("fib_trie: Optimize fib_table_lookup to avoid wasting time on loops/variables")
> Cc: stable@vger.kernel.org
> Assisted-by: LLM
> Signed-off-by: Daniël Trujillo <datrujillo@nvidia.com>
> ---
> Changes in v2:
> - Move array_index_nospec() before cindex is set in
>   fib_table_lookup() so the backtrace path cannot use an out-of-bounds index
>   (Eric Dumazet).
> - Apply the same hardening to fib_find_node() and leaf_walk_rcu()
>   (Eric Dumazet).
> - Add discovery/testing details of the gadget to the changelog.
> - Link to v1: https://patch.msgid.link/20261008-fib-trie-nospec-v1-1-fa18726d485e@nvidia.com
>

This looks good to me, let's wait for final Sashiko findings.

Choice of net vs net-next tree is also debatable given that
performance impacts are unknown.

Thanks.

Reviewed-by: Eric Dumazet <edumazet@kernel.org>
Technical Details
Message-ID: <CAL4WiiqALaRC5U+H_tc5nUmkN932pHPE8Z94x4cB5X7vbuGRCA@mail.gmail.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-344073-linux-kernel-netdev=dewy.ru
References: <20261010-fib-trie-nospec-v2-1-30319b4db8d0@nvidia.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-344073-linux-kernel-netdev=dewy.ru
From: edumazet@kernel.org (Eric Dumazet)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v2] ipv4: fib_trie: prevent speculative out-of-bounds
 child access
Date: Sat, 10 Oct 2026 08:32:48 +0200
Organization: Usenet Network
Message-ID: <CAL4WiiqALaRC5U+H_tc5nUmkN932pHPE8Z94x4cB5X7vbuGRCA@mail.gmail.com>
References: <20261010-fib-trie-nospec-v2-1-30319b4db8d0@nvidia.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
	logging-data="1272664"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:qL4utxNZv6pavp8/wOgimdbj3es= sha256:wkOMBBkgIkmA+zrSRKVupSdhxb4Bd3czNF9L1+Wrm2Y=
	sha1:l4b+gwNzqeYfRA/k4fQddlS87u4= sha256:zcQ/t2ow7AJctlyLiB8sjDgHfpt292NDNFUOGTXN3BI=
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 5E12A10F860; Sat, 10 Oct 2026 09:33:14 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.64
X-Spam-Status: No, score=-3.64 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.241, 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 aGXKjlZYPEsz;
	Sat, 10 Oct 2026 09:33:10 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-344073-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 B65C610F855; Sat, 10 Oct 2026 09:33:05 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1])
	by sea.lore.kernel.org (Postfix) with ESMTP id 2D1462644C; Sat, 10 Oct 2026 06:33:04 +0000 (UTC)
X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 8572B414409;
	Sat, 10 Oct 2026 06:33:03 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="AAc/Q2au"
X-Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 69E0540B10C
	for <netdev@vger.kernel.org>; Sat, 10 Oct 2026 06:33:00 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18
X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1791613983; cv=none; b=cHhYJNxTBDG6auRLYOwiO08viKNkxLIxbzke9Ua3257Lha8XZsQl1VAv87NtrmUkfW2Eq+CqLLx7K4TwEWCi8YPOepF77AQ8Ko/AAOdzeslubB0sFPH/48ehYXuXZzsoo/o9MRcCb42OJ1RwWB7o4dAoMboDuNISEIOnK1eBy8E=
X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1791613983; c=relaxed/simple;
	bh=js99Rxw6d4LTQnUdeK4/G0TvZ029qAkf0Iwu2klLhiA=;
	h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject:
	 To:Cc:Content-Type; b=ewPgoEkTqaTG/NbVp8PyMSHzp+sL97Er7tpY/Teb+28ouB3yaAM242HDiGy8EQCYJbbSHtwvhESlajtDY7tnTR+VUyer/T+NoREgNu8fO0t/tNv4eK0/cOIuwDa+ZIpAG4QPOVUQ9wz99oNv43toLLsnlLyma1WOkVgrrLPo1qE=
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AAc/Q2au; arc=none smtp.client-ip=100.103.45.18
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id BA37D1F00898
	for <netdev@vger.kernel.org>; Sat, 10 Oct 2026 06:32:59 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1791613979;
	bh=b16zzei5UU6y9ZD9txjezNSP6bvSMZ1kmlNghkWbFz8=;
	h=References:In-Reply-To:From:Date:Subject:To:Cc;
	b=AAc/Q2auzXjSpVXcsaVhWISGHKrj3x5UiTJNzPACL1YXdbxK7Cm5cskufzGIVIFwd
	 hGTr3L6MFHLzB1uTih/FxI5u8pz/3KXQpshRMAqYBQXyBEKUNKIY4G3zJrwbGiiZeq
	 4bEmyPiNui+mK8jT7xo5ds0KrpBnGocp/plFt2Hx2dHeOF3eKOTdBZPYsDiZ0O50Wq
	 FOJ1+iiN0vxiu8bwjaiyMD8UNFtizaUV3vDQGGVMcpTVaRCnF7Vt92lMcuwwfs6F+L
	 mDATorta9/uOoribRgbSxCc2SFIVob1TEBhd4tnGBiWXLvCuSHkT55sN/Ib9LLvd+8
	 sSttQTqLt8O/Q==
X-Received: by mail-oo1-f54.google.com with SMTP id 006d021491bc7-6de2f213b7aso210451eaf.0
        for <netdev@vger.kernel.org>; Fri, 09 Oct 2026 23:32:59 -0700 (PDT)
X-Forwarded-Encrypted: i=1; AKwUvByb2NQMm+d6ZEizY+jDOmSTl6Sc9OcFqAfrSTXi2np8xVJwCk/mWaCD37XqGhp5XCUUCnVYLnI=@vger.kernel.org
X-Gm-Message-State: AFq9FYJgiDr7+Jq956RuUg8vqypZHpa0H57XVxFwmOCxxsDVsVFhQETP
	ZQh6g4o2yljoqFpyxtMjkzSbGdOqgcyCx+jpMRNZcbY+IjjXlG3j7c+GAq6UpsKBxoiG0heUqqb
	UnXzmkY1PXfatFwdKeRpc3HOy6hqjw7Q=
X-Received: by 2002:a05:6820:4dc4:b0:6e0:1599:a5c with SMTP id
 006d021491bc7-6ef1009c43dmr2740104eaf.71.1791613978986; Fri, 09 Oct 2026
 23:32:58 -0700 (PDT)
X-Precedence: bulk
X-Mailing-List: netdev@vger.kernel.org
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-In-Reply-To: <20261010-fib-trie-nospec-v2-1-30319b4db8d0@nvidia.com>
X-Gmail-Original-Message-ID: <CAL4WiiqALaRC5U+H_tc5nUmkN932pHPE8Z94x4cB5X7vbuGRCA@mail.gmail.com>
X-Gm-Features: AclHuK_jW0xWSuvSePWtjINEueMh-yMLMabcZhyjAtOV1tnHpIDfomRToV0aEFo
X-Cc: David Ahern <dsahern@kernel.org>, Ido Schimmel <idosch@nvidia.com>, 
	"David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, 
	Simon Horman <horms@kernel.org>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, 
	stable@vger.kernel.org, Alexander Duyck <alexander.h.duyck@redhat.com>