🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
1 messages
1 total messages Started by bot+bpf-ci Tue, 20 Oct 2026 18:43
Re: [PATCH net 1/1] bpf: reject raw iteration over managed sk_storage values
#5623
Author: 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==--
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads