]> www.infradead.org Git - users/jedix/linux-maple.git/commit
selftests/bpf: Add a test case to write strtol result into .rodata
authorDaniel Borkmann <daniel@iogearbox.net>
Fri, 13 Sep 2024 19:17:53 +0000 (21:17 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 13 Sep 2024 20:17:56 +0000 (13:17 -0700)
commit2e3f066020478316d7e13e0e2b9fe571c2f7f5af
tree625e7ff3c881c7916d13203c9d1abf9a974de91c
parentb073b82d4d3cee703d17e099c7e739082f15bd2e
selftests/bpf: Add a test case to write strtol result into .rodata

Add a test case which attempts to write into .rodata section of the
BPF program, and for comparison this adds test cases also for .bss
and .data section.

Before fix:

  # ./vmtest.sh -- ./test_progs -t verifier_const
  [...]
  ./test_progs -t verifier_const
  tester_init:PASS:tester_log_buf 0 nsec
  process_subtest:PASS:obj_open_mem 0 nsec
  process_subtest:PASS:specs_alloc 0 nsec
  run_subtest:PASS:obj_open_mem 0 nsec
  run_subtest:FAIL:unexpected_load_success unexpected success: 0
  #465/1   verifier_const/rodata: write rejected:FAIL
  #465/2   verifier_const/bss: write accepted:OK
  #465/3   verifier_const/data: write accepted:OK
  #465     verifier_const:FAIL
  [...]

After fix:

  # ./vmtest.sh -- ./test_progs -t verifier_const
  [...]
  ./test_progs -t verifier_const
  #465/1   verifier_const/rodata: write rejected:OK
  #465/2   verifier_const/bss: write accepted:OK
  #465/3   verifier_const/data: write accepted:OK
  #465     verifier_const:OK
  [...]

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Shung-Hsi Yu <shung-hsi.yu@suse.com>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/r/20240913191754.13290-8-daniel@iogearbox.net
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/prog_tests/verifier.c
tools/testing/selftests/bpf/progs/verifier_const.c [new file with mode: 0644]