[RFC bpf-next v2 2/3] selftests/bpf: bring back verifier tests for bpf lsm

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add back 'test 3' from Xu Kuohai, which was previously removed because BPF
verifier signed range deduction was not precise enough. With last patch in this
series applied this test no longer fails.

Link: https://lore.kernel.org/bpf/CAADnVQJ2bE0cAp8DNh1m6VqphNvWLkq8p=gwyPbbcdopaKcCCA@xxxxxxxxxxxxxx/
Signed-off-by: Xu Kuohai <xukuohai@xxxxxxxxxx>
Signed-off-by: Shung-Hsi Yu <shung-hsi.yu@xxxxxxxx>
---
 tools/testing/selftests/bpf/progs/verifier_lsm.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/tools/testing/selftests/bpf/progs/verifier_lsm.c b/tools/testing/selftests/bpf/progs/verifier_lsm.c
index 32e5e779cb96..08251c517154 100644
--- a/tools/testing/selftests/bpf/progs/verifier_lsm.c
+++ b/tools/testing/selftests/bpf/progs/verifier_lsm.c
@@ -26,6 +26,22 @@ __naked int errno_zero_retval_test2(void *ctx)
 	::: __clobber_all);
 }
 
+SEC("lsm/file_alloc_security")
+__description("lsm bpf prog with -4095~0 retval. test 3")
+__success
+__naked int errno_zero_retval_test3(void *ctx)
+{
+	asm volatile (
+	"call %[bpf_get_prandom_u32];"
+	"r0 <<= 63;"
+	"r0 s>>= 63;"
+	"r0 &= -13;"
+	"exit;"
+	:
+	: __imm(bpf_get_prandom_u32)
+	: __clobber_all);
+}
+
 SEC("lsm/file_mprotect")
 __description("lsm bpf prog with -4095~0 retval. test 4")
 __failure __msg("R0 has smin=-4096 smax=-4096 should have been in [-4095, 0]")
-- 
2.47.0





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux