🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #5623

Re: [PATCH net 1/1] bpf: reject raw iteration over managed sk_storage values

#5623
From: bot+bpf-ci
Date: Tue, 20 Oct 2026 18:43
62 lines
10153 bytes
--===============8583768830564627741==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

> bpf: reject raw iteration over managed sk_storage values

TL;DR: Fix only covers sk_storage iterators; the bpf_map_elem iterator in
map_iter.c may still let programs read or overwrite __kptr fields via raw
value buffers, as agreed in the v1 review.

> diff --git a/net/core/bpf_sk_storage.c b/net/core/bpf_sk_storage.c
> index ecd659f79fd4..b4936f2e5918 100644
> --- a/net/core/bpf_sk_storage.c
> +++ b/net/core/bpf_sk_storage.c
> @@ -865,6 +865,12 @@ static int bpf_iter_attach_map(struct bpf_prog *prog,
>  	if (map->map_type != BPF_MAP_TYPE_SK_STORAGE)
>  		goto put_map;
>  
> +	/* The iterator exposes values as raw buffers, bypassing field checks. */
> +	if (map->record && prog->aux->max_rdwr_access) {
> +		err = -EACCES;
> +		goto put_map;
> +	}
> +
>  	if (prog->aux->max_rdwr_access > map->value_size) {
>  		err = -EACCES;
>  		goto put_map;

Does the iter/bpf_map_elem path need the same check?

The sibling attach callback in kernel/bpf/map_iter.c validates only the
access sizes against the key and value sizes:

kernel/bpf/map_iter.c:bpf_iter_attach_map() {
    ...
	if (key_acc_size > key_size || value_acc_size > value_size) {
		err = -EACCES;
		goto put_map;
	}
    ...
}

Its value argument is also registered as a writable PTR_TO_BUF (HASH,
LRU_HASH, ARRAY and the per-cpu variants), so a program attached there can
still read or overwrite special fields such as __kptr in the same way the
commit message describes for sk_storage.

This was raised in the v1 review, with a request to cover that path as well.
It was agreed to extend the fix in a respin, but this commit only touches
net/core/bpf_sk_storage.c and no later version has been posted.

Should the bpf_map_elem iterator be handled as part of this fix?


---
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/39475541232
--===============8583768830564627741==--
Technical Details
Message-ID: <8e8c6aaacd577f4daa13c8e97702e38c9982a98684f964fc564880bfcd624413@mail.kernel.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-349462-linux-kernel-netdev=dewy.ru
References: <1fa798d444efac579e91ee0716e228902a8f9afe.1791980149.git.zhilinz@nebusec.ai>

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-349462-linux-kernel-netdev=dewy.ru
From: bot+bpf-ci@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net 1/1] bpf: reject raw iteration over managed sk_storage values
Date: Tue, 20 Oct 2026 18:43:21 +0000 (UTC)
Organization: Usenet Network
Message-ID: <8e8c6aaacd577f4daa13c8e97702e38c9982a98684f964fc564880bfcd624413@mail.kernel.org>
References: <1fa798d444efac579e91ee0716e228902a8f9afe.1791980149.git.zhilinz@nebusec.ai>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="===============8583768830564627741=="
Injection-Info: usenet.network;
	logging-data="3924752"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:azQwSag4SfhMmuFrrIAzW+hyqyM= sha256:FDvnIyUFbQtaS+z/AW9+olyV/UgjfcKYrGCvbcA4eCA=
	sha1:PFl/tnyw8DPfKJ97c6C8yBAs7aM= sha256:VRWNIXnM9AiaSOWKlFh4UswW9iktOnAJFibE4EDZCNM=
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 101D9110DC3; Tue, 20 Oct 2026 21:44:34 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.729
X-Spam-Status: No, score=-3.729 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.329, 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 eV-2h3jWeE25;
	Tue, 20 Oct 2026 21:44:31 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-349462-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 B0326110DCA; Tue, 20 Oct 2026 21:44:21 +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 4818237A6E; Tue, 20 Oct 2026 18:43:39 +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=1792521811;
	b=3o38MP0NNsvzjlpMUXh8wnjhGlEHSoCrzvUzBgxYGxuvSmFRNMR+sysKsdcPCIFZ8DY/
	 WrmG5tryRwM4Mt8u8iUxWMfG1s0EBliNtr9mgXuod9vMEbOyKGnPgu44Futg3Ug4fh9G9
	 YV+E6LKzRkrJdaIUm33g7838xr00c2x+wVAfitYU6OI/kRCVU9K0XXDALLdCEONxMXIoM
	 Rai26CH9osT/1zdOhOmQUg8o0B9/i/mn1g6ahg/RDlAo3I9iYJw5jNZfB2bJDehK3D5Wm
	 HPtBLnHuE5YNFkksjQ3Ds4VE+qBVlSh0Y7N1waH5weHFciEmMSeipTma9AianQhHL2A==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792521811;
	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=Cg5i28eI8ZmgAEQYGaNmNXxb4FmSuruGqb2BKhaEY1g=;
	b=sVE4K/cGGxU5QvCxPDhMbdhZXYk4LyC+l+tJEuYojZGAYvDd6qkg/w49pSiB9mtGwHHZ
	 dPKOVYJ/FZrNApBjhqzTKxGH5eUIyX/ntLO+wKXGqOTNU5LTFZswp5vgXn61oF+0y1OX7
	 Z+c2pVd3mGrd7TYkM0oh6eHfBT+PFlqLIlRGV5cOF2eiaf8WJ/rqrkpBuzyTaBgmqbj8/
	 Px0bIu84tqQ7h5Qq/uKvqqAyXAfc1kBCLr9LOd7gqPrJTim5hrvpkZ3fkyQ7QR8N/+CH2
	 ALl2VJ6n9v7zhfg2NIvjk3qelGewUcSgM62fVdOPvrKYKvGSaJnDiLw4OqgM0ZBUQrA==
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=H+jRGeKM;
	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 4DD9B606A326;
	Tue, 20 Oct 2026 18:43:31 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=H+jRGeKM
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=1792521802;
	b=k9ne+pWK7JXVFJEPGnvsPDVs778/1wJ7nUa0Gh+KmDFMDqCoIGKa3K/spcEsq/05CfVy
	 o9zPnIyrzehVZyKwqfNec++2KgxfBeXzJGcildxZyRofcUo6Wn/Z2X+LGqhRlS4I8HS34
	 RKA9b5UADGTxtDWUnJzUjn+qX7vF9ChXR5rW+8GxYrus3j3Iex//Mnie3bOrKt+q2CVH4
	 qxd+DbOANMf7OPg933NMpfiL+LEtYJ4ytVOTLB2OOOCP/v9uCTmcDbQaZKbyd6jX8HyYr
	 puBF2twdJNRM7xdj3LQVqmEXUelOiOr6bGCf8HLOi0oPjn1xKD4rQkyMW4prfCWbUVQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792521802;
	h=Received:DKIM-Signature:Content-Type:MIME-Version:Message-Id:
	 In-Reply-To:References:Subject:From:To:Cc:Date;
	bh=Cg5i28eI8ZmgAEQYGaNmNXxb4FmSuruGqb2BKhaEY1g=;
	b=RnmHOFTzvl6gxUwnSGW4MFjybnagwIShA0VbDe/eG+3fuoHsC/24Jk0laXn5rhpkX24o
	 idx9lCxiIqBKmyxHcqf4N15ElEdQVmNXVeQq0Q+F/z0sGQSYKouWsCfSjHP9MumkB72SF
	 cWESAm2s9iwvw/LYRYtDyCFa7Elj1lDwVUzJmNwxSLg1IZoMjiTqLue7bib1pJ/OCK0jw
	 5jjaNTdXmDTQvmdqxIuffr94CS1ULcEzOTuFpz4A/hEqNI786y7U7OKS+MNk9nuf2r8N5
	 /O9nIhFHDgTmvMM2bGhBzulJwH4T4wVrAPvFH7R4TDl1Jjr6K7ULbJUrLUDBnpGE9ag==
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=H+jRGeKM;
	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 95162606A31D;
	Tue, 20 Oct 2026 18:43:22 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id BD6551F000C9;
	Tue, 20 Oct 2026 18:43:21 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1792521802;
	bh=Cg5i28eI8ZmgAEQYGaNmNXxb4FmSuruGqb2BKhaEY1g=;
	h=In-Reply-To:References:Subject:From:To:Cc:Date;
	b=H+jRGeKMfGRWKUtlHBGIdLEHaq5YucF5IvOpzpz2lyiHEKg4uplaXyzx+1Y/HCef9
	 U0OobKH0D8VOS3fa92ErsElC0y0s/S6zb3wZ9LotduqSn1qYqbqLVuhzQIKKDESb+H
	 5SP/e/f6Qe/K8igdgz3OeQkdUG9JnOm9TFh7isYa6l5pf/jY0HMTsbsvMmJlggSmTH
	 9X7gMKoXEp6IWvni/b/p5XkznwfsU1imXCv2JY2NkSR7hQ9NgZ2XO2StClqNqgZH53
	 pF+mKgUbV58WK6kofBTrouuXZXuy2uJ6U9eSTfLUVb1HKvLMXf37SucGH6AbxfM5G/
	 kvGG7haFlF3dA==
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: <1fa798d444efac579e91ee0716e228902a8f9afe.1791980149.git.zhilinz@nebusec.ai>
X-Cc: davem@davemloft.net,edumazet@kernel.org,pabeni@redhat.com,horms@kernel.org,ameryhung@gmail.com,ast@kernel.org,martin.lau@kernel.org,daniel@iogearbox.net,leon.hwang@linux.dev,mattbobrowski@google.com,zhilinz@nebusec.ai,menglong8.dong@gmail.com,kees@kernel.org,bestswngs@gmail.com,memxor@gmail.com,vega@nebusec.ai,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