Commit 19b6dbc0 authored by Kumar Kartikeya Dwivedi's avatar Kumar Kartikeya Dwivedi Committed by Alexei Starovoitov
Browse files

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: default avatarEduard Zingerman <eddyz87@gmail.com>
Signed-off-by: default avatarKumar Kartikeya Dwivedi <memxor@gmail.com>
Link: https://lore.kernel.org/r/20241204044757.1483141-6-memxor@gmail.com


Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent f513c363
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -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";