* [PATCH stable 7.1 6.18 0/2] selftests/bpf: Fix verifier_map_ptr failure after bpf_map excl field backport
@ 2026-07-28 7:25 Shung-Hsi Yu
2026-07-28 7:25 ` [PATCH stable 7.1 6.18 1/2] selftests/bpf: Adjust verifier_map_ptr for the map's excl field Shung-Hsi Yu
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Shung-Hsi Yu @ 2026-07-28 7:25 UTC (permalink / raw)
To: stable; +Cc: Shung-Hsi Yu
The BPF selftest "verifier_map_ptr/bpf_map_ptr: read non-existent field
rejected" currently fails on 7.1 and 6.18.
VERIFIER LOG:
=============
[...]
3: (61) r6 = \*(u32 \*)(r1 +33)
access beyond the end of member excl (mend:36) in struct bpf_map with off 33 size 4
=============
EXPECTED SUBSTR: 'cannot access ptr member ops with moff 32 in struct bpf_map with off 33 size 4'
#630/5 verifier_map_ptr/bpf_map_ptr: read non-existent field rejected:FAIL
Root cause is due to both branches having backported upstream commit
0fb6c9ed6493 ("libbpf: Reject non-exclusive metadata maps in the signed
loader") that adds a new "u32 excl" member to struct bpf_map at offset
32, which pushes the ops pointer from offset 32 to offset 40, but
missing the update on BPF selftests' side.
Patch 1 updates the expected verifier message for the offset-33 read to
the "access beyond the end of member excl" rejection, making the test
pass again. However, that alone was not enough.
Patch 2 is the upstream follow-up to patch 1. It updates the probing
offset so it actually reads the ops pointer again
Tested on 6.18[1] and 7.1[2] and confirm that with this patchset
applied, verifier_map_ptr/bpf_map_ptr no longer fails. (Note: there are
currently several other failures, they'll be addressed separately).
1: https://github.com/kernel-patches/linux-stable/actions/runs/30335038494/
2: https://github.com/kernel-patches/linux-stable/actions/runs/30334621104/
Daniel Borkmann (1):
selftests/bpf: Keep verifier_map_ptr exercising ops pointer access
KP Singh (1):
selftests/bpf: Adjust verifier_map_ptr for the map's excl field
.../selftests/bpf/progs/verifier_map_ptr.c | 36 ++++++++++++++++---
1 file changed, 32 insertions(+), 4 deletions(-)
base-commit: 155b42bec9cbb6b8cdc47dd9bd09503a81fbe493
--
2.55.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH stable 7.1 6.18 1/2] selftests/bpf: Adjust verifier_map_ptr for the map's excl field
2026-07-28 7:25 [PATCH stable 7.1 6.18 0/2] selftests/bpf: Fix verifier_map_ptr failure after bpf_map excl field backport Shung-Hsi Yu
@ 2026-07-28 7:25 ` Shung-Hsi Yu
2026-07-28 7:25 ` [PATCH stable 7.1 6.18 2/2] selftests/bpf: Keep verifier_map_ptr exercising ops pointer access Shung-Hsi Yu
2026-07-28 16:10 ` [PATCH stable 7.1 6.18 0/2] selftests/bpf: Fix verifier_map_ptr failure after bpf_map excl field backport Sasha Levin
2 siblings, 0 replies; 4+ messages in thread
From: Shung-Hsi Yu @ 2026-07-28 7:25 UTC (permalink / raw)
To: stable; +Cc: Shung-Hsi Yu, KP Singh, Daniel Borkmann, Alexei Starovoitov
From: KP Singh <kpsingh@kernel.org>
commit 38498c0ebacd54dbaac3513a548a13f1a8455c4e upstream.
Adding the u32 excl field at offset 32 of struct bpf_map right after the
sha[SHA256_DIGEST_SIZE] hash shifts the ops pointer from offset 32 to 40.
Therefore, fix up the test case.
# LDLIBS=-static PKG_CONFIG='pkg-config --static' ./vmtest.sh -- ./test_progs -t verifier_map_ptr
[...]
#637/1 verifier_map_ptr/bpf_map_ptr: read with negative offset rejected:OK
#637/2 verifier_map_ptr/bpf_map_ptr: read with negative offset rejected @unpriv:OK
#637/3 verifier_map_ptr/bpf_map_ptr: write rejected:OK
#637/4 verifier_map_ptr/bpf_map_ptr: write rejected @unpriv:OK
#637/5 verifier_map_ptr/bpf_map_ptr: read non-existent field rejected:OK
#637/6 verifier_map_ptr/bpf_map_ptr: read non-existent field rejected @unpriv:OK
#637/7 verifier_map_ptr/bpf_map_ptr: read ops field accepted:OK
#637/8 verifier_map_ptr/bpf_map_ptr: read ops field accepted @unpriv:OK
[...]
Summary: 2/18 PASSED, 0 SKIPPED, 0 FAILED
Signed-off-by: KP Singh <kpsingh@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/r/20260601150248.394863-7-daniel@iogearbox.net
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Shung-Hsi Yu <shung-hsi.yu@suse.com>
---
tools/testing/selftests/bpf/progs/verifier_map_ptr.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/bpf/progs/verifier_map_ptr.c b/tools/testing/selftests/bpf/progs/verifier_map_ptr.c
index e2767d27d8aa..d8e822d1a8ba 100644
--- a/tools/testing/selftests/bpf/progs/verifier_map_ptr.c
+++ b/tools/testing/selftests/bpf/progs/verifier_map_ptr.c
@@ -70,13 +70,15 @@ __naked void bpf_map_ptr_write_rejected(void)
: __clobber_all);
}
-/* The first element of struct bpf_map is a SHA256 hash of 32 bytes, accessing
- * into this array is valid. The opts field is now at offset 33.
+/*
+ * struct bpf_map starts with the SHA256 hash sha[32] at offset 0 (a readable
+ * byte array), followed by the u32 excl field at offset 32. Reading a u32 at
+ * offset 33 runs past the end of excl and is rejected.
*/
SEC("socket")
__description("bpf_map_ptr: read non-existent field rejected")
__failure
-__msg("cannot access ptr member ops with moff 32 in struct bpf_map with off 33 size 4")
+__msg("access beyond the end of member excl (mend:36) in struct bpf_map with off 33 size 4")
__failure_unpriv
__msg_unpriv("access is allowed only to CAP_PERFMON and CAP_SYS_ADMIN")
__flag(BPF_F_ANY_ALIGNMENT)
--
2.55.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH stable 7.1 6.18 2/2] selftests/bpf: Keep verifier_map_ptr exercising ops pointer access
2026-07-28 7:25 [PATCH stable 7.1 6.18 0/2] selftests/bpf: Fix verifier_map_ptr failure after bpf_map excl field backport Shung-Hsi Yu
2026-07-28 7:25 ` [PATCH stable 7.1 6.18 1/2] selftests/bpf: Adjust verifier_map_ptr for the map's excl field Shung-Hsi Yu
@ 2026-07-28 7:25 ` Shung-Hsi Yu
2026-07-28 16:10 ` [PATCH stable 7.1 6.18 0/2] selftests/bpf: Fix verifier_map_ptr failure after bpf_map excl field backport Sasha Levin
2 siblings, 0 replies; 4+ messages in thread
From: Shung-Hsi Yu @ 2026-07-28 7:25 UTC (permalink / raw)
To: stable; +Cc: Shung-Hsi Yu, Daniel Borkmann, Alexei Starovoitov
From: Daniel Borkmann <daniel@iogearbox.net>
commit 082c412097716b93ff1365689fc4ddcd1ce8296f upstream.
sashiko complained that 38498c0ebacd ("selftests/bpf: Adjust verifier_map_ptr
for the map's excl field") would slightly decrease the test coverage given
before the test was against the verifier rejecting the ops pointer. Recover
the old test with the right offsets and add the existing one as an additional
test case.
# LDLIBS=-static PKG_CONFIG='pkg-config --static' ./vmtest.sh -- ./test_progs -t verifier_map_ptr
[ 1.672932] bpf_testmod: module verification failed: signature and/or required key missing - tainting kernel
#637/1 verifier_map_ptr/bpf_map_ptr: read with negative offset rejected:OK
#637/2 verifier_map_ptr/bpf_map_ptr: read with negative offset rejected @unpriv:OK
#637/3 verifier_map_ptr/bpf_map_ptr: write rejected:OK
#637/4 verifier_map_ptr/bpf_map_ptr: write rejected @unpriv:OK
#637/5 verifier_map_ptr/bpf_map_ptr: read non-existent field rejected:OK
#637/6 verifier_map_ptr/bpf_map_ptr: read non-existent field rejected @unpriv:OK
#637/7 verifier_map_ptr/bpf_map_ptr: read beyond excl field rejected:OK
#637/8 verifier_map_ptr/bpf_map_ptr: read beyond excl field rejected @unpriv:OK
#637/9 verifier_map_ptr/bpf_map_ptr: read ops field accepted:OK
#637/10 verifier_map_ptr/bpf_map_ptr: read ops field accepted @unpriv:OK
#637/11 verifier_map_ptr/bpf_map_ptr: r = 0, map_ptr = map_ptr + r:OK
#637/12 verifier_map_ptr/bpf_map_ptr: r = 0, map_ptr = map_ptr + r @unpriv:OK
#637/13 verifier_map_ptr/bpf_map_ptr: r = 0, r = r + map_ptr:OK
#637/14 verifier_map_ptr/bpf_map_ptr: r = 0, r = r + map_ptr @unpriv:OK
#637 verifier_map_ptr:OK
[...]
Summary: 2/20 PASSED, 0 SKIPPED, 0 FAILED
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/r/20260602133052.423725-4-daniel@iogearbox.net
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Shung-Hsi Yu <shung-hsi.yu@suse.com>
---
.../selftests/bpf/progs/verifier_map_ptr.c | 34 ++++++++++++++++---
1 file changed, 30 insertions(+), 4 deletions(-)
diff --git a/tools/testing/selftests/bpf/progs/verifier_map_ptr.c b/tools/testing/selftests/bpf/progs/verifier_map_ptr.c
index d8e822d1a8ba..166193659870 100644
--- a/tools/testing/selftests/bpf/progs/verifier_map_ptr.c
+++ b/tools/testing/selftests/bpf/progs/verifier_map_ptr.c
@@ -72,17 +72,43 @@ __naked void bpf_map_ptr_write_rejected(void)
/*
* struct bpf_map starts with the SHA256 hash sha[32] at offset 0 (a readable
- * byte array), followed by the u32 excl field at offset 32. Reading a u32 at
- * offset 33 runs past the end of excl and is rejected.
+ * byte array), the u32 excl field at offset 32, and the ops pointer at offset
+ * 40. Reading a u32 at offset 41 reaches into the middle of the ops pointer,
+ * i.e. a partial pointer access, which is rejected.
*/
SEC("socket")
__description("bpf_map_ptr: read non-existent field rejected")
__failure
+__msg("cannot access ptr member ops with moff 40 in struct bpf_map with off 41 size 4")
+__failure_unpriv
+__msg_unpriv("access is allowed only to CAP_PERFMON and CAP_SYS_ADMIN")
+__flag(BPF_F_ANY_ALIGNMENT)
+__naked void read_non_existent_field_rejected(void)
+{
+ asm volatile (" \
+ r6 = 0; \
+ r1 = %[map_array_48b] ll; \
+ r6 = *(u32*)(r1 + 41); \
+ r0 = 1; \
+ exit; \
+" :
+ : __imm_addr(map_array_48b)
+ : __clobber_all);
+}
+
+/*
+ * The u32 excl field spans offsets 32..35 (mend 36). Reading a u32 at offset
+ * 33 starts inside excl but extends past its end, which the verifier rejects
+ * as an out-of-bounds scalar access.
+ */
+SEC("socket")
+__description("bpf_map_ptr: read beyond excl field rejected")
+__failure
__msg("access beyond the end of member excl (mend:36) in struct bpf_map with off 33 size 4")
__failure_unpriv
__msg_unpriv("access is allowed only to CAP_PERFMON and CAP_SYS_ADMIN")
__flag(BPF_F_ANY_ALIGNMENT)
-__naked void read_non_existent_field_rejected(void)
+__naked void read_beyond_excl_field_rejected(void)
{
asm volatile (" \
r6 = 0; \
@@ -105,7 +131,7 @@ __naked void ptr_read_ops_field_accepted(void)
asm volatile (" \
r6 = 0; \
r1 = %[map_array_48b] ll; \
- r6 = *(u64*)(r1 + 0); \
+ r6 = *(u64*)(r1 + 40); \
r0 = 1; \
exit; \
" :
--
2.55.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH stable 7.1 6.18 0/2] selftests/bpf: Fix verifier_map_ptr failure after bpf_map excl field backport
2026-07-28 7:25 [PATCH stable 7.1 6.18 0/2] selftests/bpf: Fix verifier_map_ptr failure after bpf_map excl field backport Shung-Hsi Yu
2026-07-28 7:25 ` [PATCH stable 7.1 6.18 1/2] selftests/bpf: Adjust verifier_map_ptr for the map's excl field Shung-Hsi Yu
2026-07-28 7:25 ` [PATCH stable 7.1 6.18 2/2] selftests/bpf: Keep verifier_map_ptr exercising ops pointer access Shung-Hsi Yu
@ 2026-07-28 16:10 ` Sasha Levin
2 siblings, 0 replies; 4+ messages in thread
From: Sasha Levin @ 2026-07-28 16:10 UTC (permalink / raw)
To: stable; +Cc: Sasha Levin, Shung-Hsi Yu
> The BPF selftest "verifier_map_ptr/bpf_map_ptr: read non-existent field
> rejected" currently fails on 7.1 and 6.18.
Queued the series for 6.18 and 7.1, thanks.
--
Thanks,
Sasha
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-07-28 16:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-28 7:25 [PATCH stable 7.1 6.18 0/2] selftests/bpf: Fix verifier_map_ptr failure after bpf_map excl field backport Shung-Hsi Yu
2026-07-28 7:25 ` [PATCH stable 7.1 6.18 1/2] selftests/bpf: Adjust verifier_map_ptr for the map's excl field Shung-Hsi Yu
2026-07-28 7:25 ` [PATCH stable 7.1 6.18 2/2] selftests/bpf: Keep verifier_map_ptr exercising ops pointer access Shung-Hsi Yu
2026-07-28 16:10 ` [PATCH stable 7.1 6.18 0/2] selftests/bpf: Fix verifier_map_ptr failure after bpf_map excl field backport Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox