🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #16019

Re: [PATCH bpf] bpf: mask speculative out-of-bounds skb helper loads

#16019
From: bot+bpf-ci
Date: Fri, 13 Nov 2026 20:46
76 lines
10438 bytes
--===============6062532438743464253==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

> bpf: mask speculative out-of-bounds skb helper loads

TL;DR: The nospec masking may be incomplete: inline classic BPF ABS/MSH loads
from convert_bpf_ld_abs() on efficient-unaligned-access architectures bypass
the helpers, so a short packet could still transiently read out of bounds.

> diff --git a/net/core/filter.c b/net/core/filter.c
> --- a/net/core/filter.c
> +++ b/net/core/filter.c

[ ... ]

> +static __always_inline const void *
> +bpf_skb_load_nospec(const struct sk_buff *skb, const void *data,
> +		    int headlen, int offset, int len)
> +{

[ ... ]

> +	/* Out-of-bounds transient offsets select NULL as the load address. */
> +	return (const void *)(((unsigned long)data + (long)offset) & mask);
> +}
> +
>  BPF_CALL_4(bpf_skb_load_helper_8, const struct sk_buff *, skb, const void *,
>  	   data, int, headlen, int, offset)
>  {

[ ... ]

>  	if (headlen - offset >= len)
> -		return *(u8 *)(data + offset);
> +		return *(const u8 *)bpf_skb_load_nospec(skb, data, headlen,
> +							  offset, len);

This isn't a bug in the hunk itself, but is the mitigation complete?

On architectures with HAVE_EFFICIENT_UNALIGNED_ACCESS, a classic
BPF_LD|BPF_ABS load with k >= 0, and BPF_LDX|BPF_MSH|BPF_B, do not reach
these helpers.  convert_bpf_ld_abs() emits an inline check and load
instead:

    TMP = H - k;
    if (TMP s< size) goto helper;
    A = *(size *)(D + k);   /* BPF_REG_D == cached skb->data */

This is the same bounds-check-then-load pattern described in the commit
message, and nothing masks it.  An unprivileged SO_ATTACH_FILTER program
chooses k, and packet size controls the linear length.  After training the
branch with long packets, a short packet could transiently load from
skb->data + k past the linear area.  The value could then go through
BPF_LSH/BPF_TAX into a BPF_IND load, which reaches
bpf_skb_load_helper_*() and passes the new mask because the shifted index
is in range.

The commit message says "For indirect loads, packet data can determine the
offset", yet the patch also masks ABS loads that go through the helpers.

Should convert_bpf_ld_abs() get the same treatment (for example, always
calling the helpers, or masking D + k in the emitted code), or should the
changelog explain why constant-offset loads are out of scope?

[ ... ]


---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/43500835329
--===============6062532438743464253==--
Technical Details
Message-ID: <651acc6e21aae9067dd3b8ccce4aa38da032b57324836cc75a1fbaa959e2ef10@mail.kernel.org>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-362915-linux-kernel-netdev=dewy.ru
References: <20261113-cbpf-ind-nospec-v1-bpf-v1-1-764ac4c14573@nvidia.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-362915-linux-kernel-netdev=dewy.ru
From: bot+bpf-ci@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH bpf] bpf: mask speculative out-of-bounds skb helper loads
Date: Fri, 13 Nov 2026 20:46:36 +0000 (UTC)
Organization: Usenet Network
Message-ID: <651acc6e21aae9067dd3b8ccce4aa38da032b57324836cc75a1fbaa959e2ef10@mail.kernel.org>
References: <20261113-cbpf-ind-nospec-v1-bpf-v1-1-764ac4c14573@nvidia.com>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="===============6062532438743464253=="
Injection-Info: usenet.network;
	logging-data="1450875"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:z8gKBsPAR89RS5pnUMQzefWGqXQ= sha256:AYsppLtFRbZf54gAvQ31K+9G+7FmtUKGP3GTZAXXLVw=
	sha1:IiCHCLLwC3wzOzWbNSqMiYipfRw= sha256:ll+YRhBGOCA8lxz/9j4LqBDsrpti434GjxA57L2MDUE=
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 366BD1146A7; Sat, 14 Nov 2026 01:08:46 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 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] 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 dRYARuYGyCO5;
	Sat, 14 Nov 2026 01:08:42 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-362915-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 0B4C811460C; Sat, 14 Nov 2026 01:08:31 +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 4227F2A55A0; Fri, 13 Nov 2026 20:46:43 +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=1794602800;
	b=1WyauVMdZo7vIBp4opELD5pUFpRSdZW1ZK+9rnbXxBENF3UKsvCCv0dPGU+sCYxsdQco
	 0H5n+RgxRavdPBuiHwwe/eXzyto3VjYx/kFAI9k8zISvL+O14hkVGJdsilFoR/67y1zMR
	 GJqg84ge2/lzaK21dx5T3r3s7ts6Rxz+wO6nuVq/T+RRP2OEwbivFeCZCL42lZrJCF1MV
	 2/QY73Asvgowgs2ReErVDuE0BNGaXiOLuYo2nslL8maq/dHMG3hXE5p4Zce6kMKUhXEtp
	 SPZ2stZWs1jjlXimwbTwbC2E7sJ15ucKZHtCaEiA2RfxoDz80w2u8TSYjbbHGRF/Huw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794602800;
	h=X-Original-To:Received:Received:DKIM-Signature:Content-Type:
	 X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:Message-Id:
	 In-Reply-To:References:Subject:From:To:Cc:Date;
	bh=mvDC8AgZ3N1caSO2w8AjVA+n1IhC5yWLMz1RCK3jyqY=;
	b=loyHk7KhBX7sKmjA0npiW8FxT8No9gNO1MUS4kIfFIW2a+EqNbA/0Ou/9rAfLXKj7fvJ
	 68AtmsMxbV9CWTIsGwVuPhJZj/egAHybiselEyjxoKEQb+uKoZ1lMtgeRWSLAvqZH7HZj
	 MWdFUg1j9DNcW3/3qt1Oliz7o+BpQ5iwm846IQqng2krDq9YH2QL0G1qe5eVer8cbr4Hk
	 ngmwRob6nccjX2soysYidlsHmDLg/QjTIunmrRQB3UvgyqWy83ZftRFXF2P0wz+7y1KRt
	 rC1IIeR4cwiESFY5CtR2E+bHBCkoipYqJsmcndNUeyqwzMQo49kHnGJT55KPeaCum/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=j0q+0SFk;
	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 EFABD606A887;
	Fri, 13 Nov 2026 20:46:39 +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=j0q+0SFk
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=1794602799;
	b=SJqj2Q8+h78PKm8joXcELldwwoJXUF8hm2LmS7uKdUW+pFrR90htMHBG5qQmnBI4Vc00
	 pL7Z6yUOVKDi/ortQ4R+wJkQtjHUsX0BaQF8EOChHf/wV71KARVQOJO0IVcfV95GPanL0
	 LtyLu3DCZ7yQyGOl3Zv5RJH07RLM+OpVDC1kXueiLfKsMdTayiB2BhzlLNom8Mv/QybB+
	 nieo4t7j4Uoz9HBfnDvmujbrj0xXg9Y/UcUeOfy8eMcjhxyJ0Z5mAdAYB6JzMtnvys/V5
	 az/UZfvqR4/16RFTWrQcrgjuNGcmpjs4HvdJ75bf26L7ZQY7hj72VAgAbcWuJIilmrg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794602799;
	h=Received:DKIM-Signature:Content-Type:MIME-Version:Message-Id:
	 In-Reply-To:References:Subject:From:To:Cc:Date;
	bh=mvDC8AgZ3N1caSO2w8AjVA+n1IhC5yWLMz1RCK3jyqY=;
	b=3tU+WVHxlvCysKAtqazHNC+8y7+TC2pLtF76OEMaNXYwY8tyxYRfNgdPLyFN9MeubfH8
	 A8DT/kr799O/NsBV9YSHMZeHEfBqje+WPPpvEgs+UGa3+JWBc9xh/7rA1I7dprgS7LSPM
	 lmiKyAB306HhXLhvuA+y4mnLw3wkAbBZggSmZbsacclhseTRQZpZ70NR9Kx8nW5RcXnuq
	 zRqbGyRHRsn/3BoRSxPi+RUaaFQMJB4fG52NSMf41sxM+qJ5ltTZvmf7mSzShQ/AsNEBD
	 cspOJXwi1awiVHDsUVF7VaS/v3d18Sn+FizUSewSjs5BdbPAJn3vpaSfR/qmDEO0DDQ==
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=j0q+0SFk;
	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 1B32C606A337;
	Fri, 13 Nov 2026 20:46:38 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 36CD91F000C8;
	Fri, 13 Nov 2026 20:46:36 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1794602798;
	bh=mvDC8AgZ3N1caSO2w8AjVA+n1IhC5yWLMz1RCK3jyqY=;
	h=In-Reply-To:References:Subject:From:To:Cc:Date;
	b=j0q+0SFkiBXQSraN4EqvJBROKR2mcquGuAPCbOw0DgeacG6PMuxZawuosKEih7CED
	 QgYF0XyOo7iFI+scNPKIIt6n8Afo9cykJo9eomLUGMFqoA0xLfxj/T5iF7VrbnIVR+
	 sSLp4D0Uz6whxGQcMJb95LXEe2yzgI/nIXooRk/GvHoCrpV38terTMDZ8kVLNjSxlZ
	 GKdZkpybhNC/aFTkS8vjFyZUpVLs+ik0tHxJ7BbgOGLVhJIunDkfuPzEJow1Ts0qxJ
	 OPh92ofxKEjSzJlTF+9roDgYqWIeuOEwDq0yQS9Buw2EYscKBOrrGQ957LKmjo/+nW
	 cInVamCDKEASw==
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
X-In-Reply-To: <20261113-cbpf-ind-nospec-v1-bpf-v1-1-764ac4c14573@nvidia.com>
X-Cc: bpf@vger.kernel.org,netdev@vger.kernel.org,linux-kernel@vger.kernel.org,datrujillo@nvidia.com,ast@kernel.org,andrii@kernel.org,daniel@iogearbox.net,martin.lau@kernel.org,eddyz87@gmail.com,yonghong.song@linux.dev,mason@kernel.org,ihor.solodrai@linux.dev