]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
Merge branch 'bpf-fix-end-of-list-detection-in-cgroup_storage_get_next_key'
authorAlexei Starovoitov <ast@kernel.org>
Mon, 6 Apr 2026 01:45:05 +0000 (18:45 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Mon, 6 Apr 2026 01:45:06 +0000 (18:45 -0700)
Weiming Shi says:

====================
bpf: fix end-of-list detection in cgroup_storage_get_next_key()

list_next_entry() never returns NULL, so the NULL check in
cgroup_storage_get_next_key() is dead code. When iterating past the last
element, the function reads storage->key from a bogus pointer that aliases
internal map fields and copies the result to userspace.

Patch 1 replaces the NULL check with list_entry_is_head() so the function
correctly returns -ENOENT when there are no more entries.

Patch 2 adds a selftest to cover this corner case, as suggested by Sun Jian
and Paul Chaignon.

v2:
  - Added selftest (Paul Chaignon)
  - Collected Reviewed-by and Acked-by tags
====================

Link: https://patch.msgid.link/20260403132951.43533-1-bestswngs@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>

Trivial merge