bpf, selftests: Add verifier test case for jmp32's jeq/jne
authorDaniel Borkmann <daniel@iogearbox.net>
Fri, 1 Jul 2022 12:47:27 +0000 (14:47 +0200)
committerAndrii Nakryiko <andrii@kernel.org>
Fri, 1 Jul 2022 19:56:27 +0000 (12:56 -0700)
commita49b8ce7306cf8031361a6a4f7f6bc7a775a39c8
tree53dee9ecd3cb124fa265c7600fe53f307d8ea9e7
parent73c4936f916de73fa3faec204a4deb37c25e18c1
bpf, selftests: Add verifier test case for jmp32's jeq/jne

Add a test case to trigger the verifier's incorrect conclusion in the
case of jmp32's jeq/jne. Also here, make use of dead code elimination,
so that we can see the verifier bailing out on unfixed kernels.

Before:

  # ./test_verifier 724
  #724/p jeq32/jne32: bounds checking FAIL
  Failed to load prog 'Permission denied'!
  R4 !read_ok
  verification time 8 usec
  stack depth 0
  processed 8 insns (limit 1000000) max_states_per_insn 0 total_states 1 peak_states 1 mark_read 0
  Summary: 0 PASSED, 0 SKIPPED, 1 FAILED

After:

  # ./test_verifier 724
  #724/p jeq32/jne32: bounds checking OK
  Summary: 1 PASSED, 0 SKIPPED, 0 FAILED

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20220701124727.11153-4-daniel@iogearbox.net
tools/testing/selftests/bpf/verifier/jmp32.c