Skip to content

Commit 19b6dbc

Browse files
kkdwivediAlexei Starovoitov
authored and
Alexei Starovoitov
committed
selftests/bpf: Add test for narrow spill into 64-bit spilled scalar
Add a test case to verify that without CAP_PERFMON, the test now succeeds instead of failing due to a verification error. Acked-by: Eduard Zingerman <[email protected]> Signed-off-by: Kumar Kartikeya Dwivedi <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent f513c36 commit 19b6dbc

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tools/testing/selftests/bpf/progs/verifier_spill_fill.c

+17
Original file line numberDiff line numberDiff line change
@@ -1262,4 +1262,21 @@ __naked void stack_noperfmon_reject_invalid_read(void)
12621262
" ::: __clobber_all);
12631263
}
12641264

1265+
SEC("socket")
1266+
__description("stack_noperfmon: narrow spill onto 64-bit scalar spilled slots")
1267+
__success
1268+
__caps_unpriv(CAP_BPF)
1269+
__success_unpriv
1270+
__naked void stack_noperfmon_spill_32bit_onto_64bit_slot(void)
1271+
{
1272+
asm volatile(" \
1273+
r0 = 0; \
1274+
*(u64 *)(r10 - 8) = r0; \
1275+
*(u32 *)(r10 - 8) = r0; \
1276+
exit; \
1277+
" :
1278+
:
1279+
: __clobber_all);
1280+
}
1281+
12651282
char _license[] SEC("license") = "GPL";

0 commit comments

Comments
 (0)