1 // SPDX-License-Identifier: GPL-2.0-only 2 3 #include <test_progs.h> 4 5 #include "cap_helpers.h" 6 #include "verifier_and.skel.h" 7 #include "verifier_array_access.skel.h" 8 #include "verifier_basic_stack.skel.h" 9 #include "verifier_bounds_deduction.skel.h" 10 #include "verifier_bounds_deduction_non_const.skel.h" 11 #include "verifier_bounds_mix_sign_unsign.skel.h" 12 #include "verifier_cfg.skel.h" 13 #include "verifier_cgroup_inv_retcode.skel.h" 14 #include "verifier_cgroup_skb.skel.h" 15 #include "verifier_cgroup_storage.skel.h" 16 #include "verifier_const_or.skel.h" 17 #include "verifier_ctx_sk_msg.skel.h" 18 #include "verifier_direct_stack_access_wraparound.skel.h" 19 #include "verifier_div0.skel.h" 20 #include "verifier_div_overflow.skel.h" 21 #include "verifier_helper_access_var_len.skel.h" 22 #include "verifier_helper_packet_access.skel.h" 23 #include "verifier_helper_restricted.skel.h" 24 #include "verifier_helper_value_access.skel.h" 25 #include "verifier_int_ptr.skel.h" 26 #include "verifier_ld_ind.skel.h" 27 #include "verifier_leak_ptr.skel.h" 28 #include "verifier_map_ptr.skel.h" 29 #include "verifier_map_ret_val.skel.h" 30 #include "verifier_masking.skel.h" 31 #include "verifier_meta_access.skel.h" 32 #include "verifier_raw_stack.skel.h" 33 #include "verifier_raw_tp_writable.skel.h" 34 #include "verifier_ringbuf.skel.h" 35 #include "verifier_spill_fill.skel.h" 36 #include "verifier_stack_ptr.skel.h" 37 #include "verifier_uninit.skel.h" 38 #include "verifier_value_adj_spill.skel.h" 39 #include "verifier_value.skel.h" 40 #include "verifier_value_or_null.skel.h" 41 #include "verifier_var_off.skel.h" 42 #include "verifier_xadd.skel.h" 43 #include "verifier_xdp.skel.h" 44 #include "verifier_xdp_direct_packet_access.skel.h" 45 46 __maybe_unused 47 static void run_tests_aux(const char *skel_name, skel_elf_bytes_fn elf_bytes_factory) 48 { 49 struct test_loader tester = {}; 50 __u64 old_caps; 51 int err; 52 53 /* test_verifier tests are executed w/o CAP_SYS_ADMIN, do the same here */ 54 err = cap_disable_effective(1ULL << CAP_SYS_ADMIN, &old_caps); 55 if (err) { 56 PRINT_FAIL("failed to drop CAP_SYS_ADMIN: %i, %s\n", err, strerror(err)); 57 return; 58 } 59 60 test_loader__run_subtests(&tester, skel_name, elf_bytes_factory); 61 test_loader_fini(&tester); 62 63 err = cap_enable_effective(old_caps, NULL); 64 if (err) 65 PRINT_FAIL("failed to restore CAP_SYS_ADMIN: %i, %s\n", err, strerror(err)); 66 } 67 68 #define RUN(skel) run_tests_aux(#skel, skel##__elf_bytes) 69 70 void test_verifier_and(void) { RUN(verifier_and); } 71 void test_verifier_array_access(void) { RUN(verifier_array_access); } 72 void test_verifier_basic_stack(void) { RUN(verifier_basic_stack); } 73 void test_verifier_bounds_deduction(void) { RUN(verifier_bounds_deduction); } 74 void test_verifier_bounds_deduction_non_const(void) { RUN(verifier_bounds_deduction_non_const); } 75 void test_verifier_bounds_mix_sign_unsign(void) { RUN(verifier_bounds_mix_sign_unsign); } 76 void test_verifier_cfg(void) { RUN(verifier_cfg); } 77 void test_verifier_cgroup_inv_retcode(void) { RUN(verifier_cgroup_inv_retcode); } 78 void test_verifier_cgroup_skb(void) { RUN(verifier_cgroup_skb); } 79 void test_verifier_cgroup_storage(void) { RUN(verifier_cgroup_storage); } 80 void test_verifier_const_or(void) { RUN(verifier_const_or); } 81 void test_verifier_ctx_sk_msg(void) { RUN(verifier_ctx_sk_msg); } 82 void test_verifier_direct_stack_access_wraparound(void) { RUN(verifier_direct_stack_access_wraparound); } 83 void test_verifier_div0(void) { RUN(verifier_div0); } 84 void test_verifier_div_overflow(void) { RUN(verifier_div_overflow); } 85 void test_verifier_helper_access_var_len(void) { RUN(verifier_helper_access_var_len); } 86 void test_verifier_helper_packet_access(void) { RUN(verifier_helper_packet_access); } 87 void test_verifier_helper_restricted(void) { RUN(verifier_helper_restricted); } 88 void test_verifier_helper_value_access(void) { RUN(verifier_helper_value_access); } 89 void test_verifier_int_ptr(void) { RUN(verifier_int_ptr); } 90 void test_verifier_ld_ind(void) { RUN(verifier_ld_ind); } 91 void test_verifier_leak_ptr(void) { RUN(verifier_leak_ptr); } 92 void test_verifier_map_ptr(void) { RUN(verifier_map_ptr); } 93 void test_verifier_map_ret_val(void) { RUN(verifier_map_ret_val); } 94 void test_verifier_masking(void) { RUN(verifier_masking); } 95 void test_verifier_meta_access(void) { RUN(verifier_meta_access); } 96 void test_verifier_raw_stack(void) { RUN(verifier_raw_stack); } 97 void test_verifier_raw_tp_writable(void) { RUN(verifier_raw_tp_writable); } 98 void test_verifier_ringbuf(void) { RUN(verifier_ringbuf); } 99 void test_verifier_spill_fill(void) { RUN(verifier_spill_fill); } 100 void test_verifier_stack_ptr(void) { RUN(verifier_stack_ptr); } 101 void test_verifier_uninit(void) { RUN(verifier_uninit); } 102 void test_verifier_value_adj_spill(void) { RUN(verifier_value_adj_spill); } 103 void test_verifier_value(void) { RUN(verifier_value); } 104 void test_verifier_value_or_null(void) { RUN(verifier_value_or_null); } 105 void test_verifier_var_off(void) { RUN(verifier_var_off); } 106 void test_verifier_xadd(void) { RUN(verifier_xadd); } 107 void test_verifier_xdp(void) { RUN(verifier_xdp); } 108 void test_verifier_xdp_direct_packet_access(void) { RUN(verifier_xdp_direct_packet_access); } 109