Skip to content

Commit

Permalink
selftests/bpf: Add test for narrow spill into 64-bit spilled scalar
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
kkdwivedi authored and Alexei Starovoitov committed Dec 4, 2024
1 parent f513c36 commit 19b6dbc
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tools/testing/selftests/bpf/progs/verifier_spill_fill.c
Original file line number Diff line number Diff line change
Expand Up @@ -1262,4 +1262,21 @@ __naked void stack_noperfmon_reject_invalid_read(void)
" ::: __clobber_all);
}

SEC("socket")
__description("stack_noperfmon: narrow spill onto 64-bit scalar spilled slots")
__success
__caps_unpriv(CAP_BPF)
__success_unpriv
__naked void stack_noperfmon_spill_32bit_onto_64bit_slot(void)
{
asm volatile(" \
r0 = 0; \
*(u64 *)(r10 - 8) = r0; \
*(u32 *)(r10 - 8) = r0; \
exit; \
" :
:
: __clobber_all);
}

char _license[] SEC("license") = "GPL";

0 comments on commit 19b6dbc

Please sign in to comment.