linux_dsm_epyc7002/tools/testing/selftests/bpf/prog_tests
Yonghong Song d6f1837107 selftests/bpf: fix segfault of test_progs when prog loading failed
The test_progs subtests, test_spin_lock() and test_map_lock(),
requires BTF present to run successfully.
Currently, when BTF failed to load, test_progs will segfault,
  $ ./test_progs
  ...
  12: (bf) r1 = r8
  13: (85) call bpf_spin_lock#93
  map 'hash_map' has to have BTF in order to use bpf_spin_lock

  libbpf: -- END LOG --
  libbpf: failed to load program 'map_lock_demo'
  libbpf: failed to load object './test_map_lock.o'
  test_map_lock:bpf_prog_load errno 13
  Segmentation fault

The segfault is caused by uninitialized variable "obj", which
is used in bpf_object__close(obj), when bpf prog failed to load.

Initializing variable "obj" to NULL in two occasions fixed the problem.
  $ ./test_progs
  ...
  Summary: 219 PASSED, 2 FAILED

Fixes: b4d4556c32 ("selftests/bpf: add bpf_spin_lock verifier tests")
Fixes: ba72a7b4ba ("selftests/bpf: test for BPF_F_LOCK")
Reported-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Yonghong Song <yhs@fb.com>
Acked-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
2019-03-12 21:55:54 +01:00
..
.gitignore
bpf_obj_id.c selftests: bpf: break up test_progs - misc 2019-03-02 11:10:40 -08:00
flow_dissector.c selftests: bpf: break up test_progs - misc 2019-03-02 11:10:40 -08:00
get_stack_raw_tp.c selftests: bpf: break up test_progs - tracepoint 2019-03-02 11:10:40 -08:00
l4lb_all.c selftests: bpf: break up test_progs - misc 2019-03-02 11:10:40 -08:00
map_lock.c selftests/bpf: fix segfault of test_progs when prog loading failed 2019-03-12 21:55:54 +01:00
obj_name.c selftests: bpf: break up test_progs - misc 2019-03-02 11:10:40 -08:00
pkt_access.c selftests: bpf: break up test_progs - pkt access 2019-03-02 11:10:40 -08:00
pkt_md_access.c selftests: bpf: break up test_progs - pkt access 2019-03-02 11:10:40 -08:00
prog_run_xattr.c selftests: bpf: break up test_progs - misc 2019-03-02 11:10:40 -08:00
queue_stack_map.c selftests: bpf: break up test_progs - misc 2019-03-02 11:10:40 -08:00
reference_tracking.c selftests: bpf: break up test_progs - misc 2019-03-02 11:10:40 -08:00
signal_pending.c selftests: bpf: test_progs: initialize duration in singal_pending test 2019-03-07 10:46:25 +01:00
spinlock.c selftests/bpf: fix segfault of test_progs when prog loading failed 2019-03-12 21:55:54 +01:00
stacktrace_build_id_nmi.c selftests: bpf: break up test_progs - stackmap 2019-03-02 11:10:40 -08:00
stacktrace_build_id.c selftests: bpf: break up test_progs - stackmap 2019-03-02 11:10:40 -08:00
stacktrace_map_raw_tp.c selftests: bpf: break up test_progs - stackmap 2019-03-02 11:10:40 -08:00
stacktrace_map.c selftests: bpf: break up test_progs - stackmap 2019-03-02 11:10:40 -08:00
task_fd_query_rawtp.c selftests: bpf: break up test_progs - tracepoint 2019-03-02 11:10:40 -08:00
task_fd_query_tp.c selftests: bpf: break up test_progs - tracepoint 2019-03-02 11:10:40 -08:00
tcp_estats.c selftests: bpf: break up test_progs - misc 2019-03-02 11:10:40 -08:00
tp_attach_query.c selftests: bpf: break up test_progs - tracepoint 2019-03-02 11:10:40 -08:00
xdp_adjust_tail.c selftests: bpf: break up test_progs - xdp 2019-03-02 11:10:40 -08:00
xdp_noinline.c selftests: bpf: break up test_progs - xdp 2019-03-02 11:10:40 -08:00
xdp.c selftests: bpf: break up test_progs - xdp 2019-03-02 11:10:40 -08:00