linux-stable/tools/testing/selftests/bpf/verifier
Tiezhu Yang 0b50478fd8 selftests/bpf: Skip callback tests if jit is disabled in test_verifier
If CONFIG_BPF_JIT_ALWAYS_ON is not set and bpf_jit_enable is 0, there
exist 6 failed tests.

  [root@linux bpf]# echo 0 > /proc/sys/net/core/bpf_jit_enable
  [root@linux bpf]# echo 0 > /proc/sys/kernel/unprivileged_bpf_disabled
  [root@linux bpf]# ./test_verifier | grep FAIL
  #106/p inline simple bpf_loop call FAIL
  #107/p don't inline bpf_loop call, flags non-zero FAIL
  #108/p don't inline bpf_loop call, callback non-constant FAIL
  #109/p bpf_loop_inline and a dead func FAIL
  #110/p bpf_loop_inline stack locations for loop vars FAIL
  #111/p inline bpf_loop call in a big program FAIL
  Summary: 768 PASSED, 15 SKIPPED, 6 FAILED

The test log shows that callbacks are not allowed in non-JITed programs,
interpreter doesn't support them yet, thus these tests should be skipped
if jit is disabled.

Add an explicit flag F_NEEDS_JIT_ENABLED to those tests to mark that they
require JIT enabled in bpf_loop_inline.c, check the flag and jit_disabled
at the beginning of do_test_single() to handle this case.

With this patch:

  [root@linux bpf]# echo 0 > /proc/sys/net/core/bpf_jit_enable
  [root@linux bpf]# echo 0 > /proc/sys/kernel/unprivileged_bpf_disabled
  [root@linux bpf]# ./test_verifier | grep FAIL
  Summary: 768 PASSED, 21 SKIPPED, 0 FAILED

Suggested-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20240123090351.2207-3-yangtiezhu@loongson.cn
2024-01-23 20:27:41 -08:00
..
.gitignore
atomic_and.c bpf, x86: Fix BPF_FETCH atomic and/or/xor with r0 as src 2021-02-22 18:03:11 +01:00
atomic_bounds.c
atomic_cmpxchg.c bpf: Fix accesses to uninit stack slots 2023-12-08 14:19:00 -08:00
atomic_fetch.c bpf, selftests: Add test case for atomic fetch on spilled pointer 2021-12-14 19:33:06 -08:00
atomic_fetch_add.c
atomic_invalid.c bpf: Small BPF verifier log improvements 2022-03-03 16:54:10 +01:00
atomic_or.c bpf: Explicitly zero-extend R0 after 32-bit cmpxchg 2021-03-04 19:06:03 -08:00
atomic_xchg.c
atomic_xor.c selftests/bpf: Fix endianness issues in atomic tests 2021-02-10 11:55:22 -08:00
basic.c
basic_call.c
basic_instr.c selftests/bpf: Fix a test_verifier failure 2023-07-27 18:54:16 -07:00
basic_stx_ldx.c
bpf_loop_inline.c selftests/bpf: Skip callback tests if jit is disabled in test_verifier 2024-01-23 20:27:41 -08:00
bpf_st_mem.c selftests/bpf: Add test for immediate spilled to stack 2023-11-01 22:30:27 -07:00
calls.c bpf: Fix accesses to uninit stack slots 2023-12-08 14:19:00 -08:00
ctx_sk_lookup.c selftests/bpf: Add tests for accessing ingress_ifindex in bpf_sk_lookup 2021-11-10 16:29:59 -08:00
ctx_skb.c selftests/bpf: Add F_NEEDS_EFFICIENT_UNALIGNED_ACCESS to some tests 2023-07-05 14:34:23 +02:00
dead_code.c selftests, bpf: Test that dead ldx_w insns are accepted 2021-08-13 17:46:26 +02:00
direct_value_access.c
event_output.c
jit.c bpf: add selftests for lsh, rsh, arsh with reg operand 2022-10-19 16:53:51 -07:00
jmp32.c selftests/bpf: Add F_NEEDS_EFFICIENT_UNALIGNED_ACCESS to some tests 2023-07-05 14:34:23 +02:00
jset.c bpf, selftests: Adjust few selftest outcomes wrt unreachable code 2021-06-14 23:06:38 +02:00
jump.c bpf, selftests: Add verifier test case for imm=0,umin=0,umax=1 scalar 2022-07-01 12:56:27 -07:00
junk_insn.c
ld_abs.c
ld_dw.c
ld_imm64.c bpf: handle ldimm64 properly in check_cfg() 2023-11-09 20:11:20 -08:00
map_kptr.c selftests/bpf: Add F_NEEDS_EFFICIENT_UNALIGNED_ACCESS to some tests 2023-07-05 14:34:23 +02:00
perf_event_sample_period.c selftests/bpf: Use __BYTE_ORDER__ 2021-10-25 20:39:42 -07:00
precise.c bpf: Assign ID to scalars on spill 2024-01-23 14:40:23 -08:00
scale.c
sleepable.c bpf: Allow BPF_PROG_TYPE_STRUCT_OPS programs to be sleepable 2023-01-25 10:25:57 -08:00
wide_access.c