linux-bl808/tools/testing/selftests/bpf/prog_tests
Yonghong Song d923021c2c bpf: Add tests for PTR_TO_BTF_ID vs. null comparison
Add two tests for PTR_TO_BTF_ID vs. null ptr comparison,
one for PTR_TO_BTF_ID in the ctx structure and the
other for PTR_TO_BTF_ID after one level pointer chasing.
In both cases, the test ensures condition is not
removed.

For example, for this test
 struct bpf_fentry_test_t {
     struct bpf_fentry_test_t *a;
 };
 int BPF_PROG(test7, struct bpf_fentry_test_t *arg)
 {
     if (arg == 0)
         test7_result = 1;
     return 0;
 }
Before the previous verifier change, we have xlated codes:
  int test7(long long unsigned int * ctx):
  ; int BPF_PROG(test7, struct bpf_fentry_test_t *arg)
     0: (79) r1 = *(u64 *)(r1 +0)
  ; int BPF_PROG(test7, struct bpf_fentry_test_t *arg)
     1: (b4) w0 = 0
     2: (95) exit
After the previous verifier change, we have:
  int test7(long long unsigned int * ctx):
  ; int BPF_PROG(test7, struct bpf_fentry_test_t *arg)
     0: (79) r1 = *(u64 *)(r1 +0)
  ; if (arg == 0)
     1: (55) if r1 != 0x0 goto pc+4
  ; test7_result = 1;
     2: (18) r1 = map[id:6][0]+48
     4: (b7) r2 = 1
     5: (7b) *(u64 *)(r1 +0) = r2
  ; int BPF_PROG(test7, struct bpf_fentry_test_t *arg)
     6: (b4) w0 = 0
     7: (95) exit

Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Link: https://lore.kernel.org/bpf/20200630171241.2523875-1-yhs@fb.com
2020-06-30 22:21:29 +02:00
..
.gitignore .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
align.c selftests/bpf: Move test_align under test_progs 2020-05-16 01:18:14 +02:00
attach_probe.c
bpf_iter.c tools/bpf: selftests: Add bpf_iter selftests 2020-05-09 17:05:27 -07:00
bpf_obj_id.c selftests/bpf: Test bpf_link's get_next_id, get_fd_by_id, and get_obj_info 2020-04-28 17:27:08 -07:00
bpf_tcp_ca.c bpf: Add tests for bpf_sk_storage to bpf_tcp_ca 2020-03-23 20:51:55 +01:00
bpf_verif_scale.c
btf_dump.c selftests/bpf: Fix mix of tabs and spaces 2020-03-20 21:46:12 +01:00
btf_map_in_map.c libbpf: Add BTF-defined map-in-map support 2020-04-28 17:35:03 -07:00
cgroup_attach_autodetach.c
cgroup_attach_multi.c bpf: cgroup: Allow multi-attach program to replace itself 2020-06-09 11:21:43 -07:00
cgroup_attach_override.c
cgroup_link.c selftests/bpf: Test FD-based cgroup attachment 2020-03-30 17:36:41 -07:00
cgroup_skb_sk_lookup.c selftests/bpf: Test for sk helpers in cgroup skb 2020-05-14 18:41:08 -07:00
cls_redirect.c selftests/bpf: Add cls_redirect classifier 2020-04-26 10:00:36 -07:00
connect_force_port.c bpf, testing: Add get{peer, sock}name selftests to test_progs 2020-05-19 11:32:04 -07:00
core_extern.c
core_reloc.c selftests/bpf: Fix invalid memory reads in core_relo selftest 2020-04-28 19:48:05 -07:00
cpu_mask.c
enable_stats.c bpf: Add selftest for BPF_ENABLE_STATS 2020-05-01 10:36:32 -07:00
fentry_fexit.c bpf: Add tests for PTR_TO_BTF_ID vs. null comparison 2020-06-30 22:21:29 +02:00
fentry_test.c bpf: Add test ops for BPF_PROG_TYPE_TRACING 2020-03-04 13:41:06 -08:00
fexit_bpf2bpf.c selftests/bpf: Move existing common networking parts into network_helpers 2020-05-09 00:48:20 +02:00
fexit_stress.c
fexit_test.c bpf: Add test ops for BPF_PROG_TYPE_TRACING 2020-03-04 13:41:06 -08:00
flow_dissector.c selftests: bpf: Pass program to bpf_prog_detach in flow_dissector 2020-06-30 10:46:39 -07:00
flow_dissector_load_bytes.c selftests/bpf: Move existing common networking parts into network_helpers 2020-05-09 00:48:20 +02:00
flow_dissector_reattach.c selftests: bpf: Pass program and target_fd in flow_dissector_reattach 2020-06-30 10:46:39 -07:00
get_stack_raw_tp.c bpf: Test_progs, add test to catch retval refine error handling 2020-03-30 15:00:30 -07:00
global_data.c selftests/bpf: Move existing common networking parts into network_helpers 2020-05-09 00:48:20 +02:00
global_data_init.c selftests: Add test for overriding global data value before load 2020-03-30 01:17:35 +02:00
hashmap.c selftests/bpf: Convert test_hashmap into test_progs test 2020-04-28 19:48:05 -07:00
kfree_skb.c selftests/bpf: Move existing common networking parts into network_helpers 2020-05-09 00:48:20 +02:00
l4lb_all.c selftests/bpf: Move existing common networking parts into network_helpers 2020-05-09 00:48:20 +02:00
link_pinning.c
load_bytes_relative.c selftests/bpf: Add cgroup_skb/egress test for load_bytes_relative 2020-06-11 16:05:56 +02:00
map_lock.c selftests/bpf: Move existing common networking parts into network_helpers 2020-05-09 00:48:20 +02:00
mmap.c bpf: Prevent mmap()'ing read-only maps as writable 2020-05-20 20:21:53 -07:00
modify_return.c bpf: Add selftests for BPF_MODIFY_RETURN 2020-03-04 13:41:06 -08:00
ns_current_pid_tgid.c selftests/bpf: Fix bpf_link leak in ns_current_pid_tgid selftest 2020-04-28 19:48:05 -07:00
obj_name.c
perf_branches.c
perf_buffer.c selftests/bpf: Disable ASAN instrumentation for mmap()'ed memory read 2020-04-28 19:48:05 -07:00
pinning.c
pkt_access.c selftests/bpf: Move existing common networking parts into network_helpers 2020-05-09 00:48:20 +02:00
pkt_md_access.c selftests/bpf: Move existing common networking parts into network_helpers 2020-05-09 00:48:20 +02:00
probe_user.c
prog_run_xattr.c selftests/bpf: Move existing common networking parts into network_helpers 2020-05-09 00:48:20 +02:00
queue_stack_map.c selftests/bpf: Move existing common networking parts into network_helpers 2020-05-09 00:48:20 +02:00
raw_tp_writable_reject_nbd_invalid.c
raw_tp_writable_test_run.c
rdonly_maps.c
reference_tracking.c
ringbuf.c selftests/bpf: Fix ringbuf selftest sample counting undeterminism 2020-06-08 16:00:42 +02:00
ringbuf_multi.c selftests/bpf: Add BPF ringbuf selftests 2020-06-01 14:38:22 -07:00
section_names.c libbpf: Always specify expected_attach_type on program load if supported 2020-04-15 13:22:43 +02:00
select_reuseport.c selftests: bpf: Enable UDP sockmap reuseport tests 2020-03-09 22:34:59 +01:00
send_signal.c
send_signal_sched_switch.c selftests/bpf: Add send_signal_sched_switch test 2020-03-05 14:02:41 -08:00
signal_pending.c selftests/bpf: Move existing common networking parts into network_helpers 2020-05-09 00:48:20 +02:00
sk_assign.c selftests/bpf: Use SOCKMAP for server sockets in bpf_sk_assign test 2020-04-29 23:31:00 +02:00
skb_ctx.c selftests/bpf: Move existing common networking parts into network_helpers 2020-05-09 00:48:20 +02:00
skb_helpers.c bpf, selftests: Test probe_* helpers from SCHED_CLS 2020-06-01 14:38:21 -07:00
skeleton.c libbpf: Support pre-initializing .bss global variables 2020-06-12 15:27:47 -07:00
sockmap_basic.c bpf, selftests: Add sk_msg helpers load and attach test 2020-06-01 14:38:20 -07:00
sockmap_ktls.c
sockmap_listen.c selftests/bpf: Fix spurious failures in accept due to EAGAIN 2020-03-13 21:37:06 +01:00
sockopt.c
sockopt_inherit.c
sockopt_multi.c
sockopt_sk.c selftests/bpf: Make sure optvals > PAGE_SIZE are bypassed 2020-06-17 10:54:05 -07:00
spinlock.c selftests/bpf: Move existing common networking parts into network_helpers 2020-05-09 00:48:20 +02:00
stacktrace_build_id.c
stacktrace_build_id_nmi.c
stacktrace_map.c
stacktrace_map_raw_tp.c
tailcalls.c
task_fd_query_rawtp.c
task_fd_query_tp.c
tcp_estats.c
tcp_rtt.c selftests/bpf: Generalize helpers to control background listener 2020-05-09 00:48:20 +02:00
test_global_funcs.c
test_lsm.c bpf, lsm: Fix the file_mprotect LSM test. 2020-04-02 19:42:52 -07:00
test_overhead.c selftest/bpf: Fmod_ret prog and implement test_overhead as part of bench 2020-05-13 12:19:38 -07:00
tp_attach_query.c
trampoline_count.c
vmlinux.c selftests/bpf: Fix nanosleep for real this time 2020-03-17 19:29:12 +01:00
xdp.c selftests/bpf: Move existing common networking parts into network_helpers 2020-05-09 00:48:20 +02:00
xdp_adjust_tail.c selftests/bpf: Xdp_adjust_tail add grow tail tests 2020-05-14 21:21:57 -07:00
xdp_attach.c selftests/bpf: Check for correct program attach/detach in xdp_attach test 2020-04-15 13:26:08 +02:00
xdp_bpf2bpf.c selftests/bpf: Move existing common networking parts into network_helpers 2020-05-09 00:48:20 +02:00
xdp_devmap_attach.c bpf: Selftests and tools use struct bpf_devmap_val from uapi 2020-06-09 11:36:19 -07:00
xdp_info.c selftests/bpf: Add test for bpf_get_link_xdp_id 2020-04-08 01:35:24 +02:00
xdp_noinline.c selftests/bpf: Move existing common networking parts into network_helpers 2020-05-09 00:48:20 +02:00
xdp_perf.c