155108621SEduard Zingerman // SPDX-License-Identifier: GPL-2.0-only 255108621SEduard Zingerman 355108621SEduard Zingerman #include <test_progs.h> 455108621SEduard Zingerman 555108621SEduard Zingerman #include "cap_helpers.h" 69d0f1568SEduard Zingerman #include "verifier_and.skel.h" 7a3c830aeSEduard Zingerman #include "verifier_array_access.skel.h" 80ccbe495SEduard Zingerman #include "verifier_basic_stack.skel.h" 97605f94bSEduard Zingerman #include "verifier_bounds_deduction.skel.h" 10b14a702aSEduard Zingerman #include "verifier_bounds_mix_sign_unsign.skel.h" 112f2047c2SEduard Zingerman #include "verifier_cfg.skel.h" 12047687a7SEduard Zingerman #include "verifier_cgroup_inv_retcode.skel.h" 13b1b63725SEduard Zingerman #include "verifier_cgroup_skb.skel.h" 148f16f3c0SEduard Zingerman #include "verifier_cgroup_storage.skel.h" 15a2777eaaSEduard Zingerman #include "verifier_const_or.skel.h" 16a58475a9SEduard Zingerman #include "verifier_ctx_sk_msg.skel.h" 1784988478SEduard Zingerman #include "verifier_direct_stack_access_wraparound.skel.h" 1801a09255SEduard Zingerman #include "verifier_div0.skel.h" 199553de70SEduard Zingerman #include "verifier_div_overflow.skel.h" 20b37d776bSEduard Zingerman #include "verifier_helper_access_var_len.skel.h" 21fb179fe6SEduard Zingerman #include "verifier_helper_packet_access.skel.h" 2277aa2563SEduard Zingerman #include "verifier_helper_restricted.skel.h" 23ecc42482SEduard Zingerman #include "verifier_helper_value_access.skel.h" 2401481e67SEduard Zingerman #include "verifier_int_ptr.skel.h" 25e2978755SEduard Zingerman #include "verifier_ld_ind.skel.h" 26583c7ce5SEduard Zingerman #include "verifier_leak_ptr.skel.h" 27caf345cfSEduard Zingerman #include "verifier_map_ptr.skel.h" 2805e474ecSEduard Zingerman #include "verifier_map_ret_val.skel.h" 29ade3f08fSEduard Zingerman #include "verifier_masking.skel.h" 3065428312SEduard Zingerman #include "verifier_meta_access.skel.h" 315a77a01fSEduard Zingerman #include "verifier_raw_stack.skel.h" 3218cdc2b5SEduard Zingerman #include "verifier_raw_tp_writable.skel.h" 33b7e42030SEduard Zingerman #include "verifier_ringbuf.skel.h" 34f4fe3cfeSEduard Zingerman #include "verifier_spill_fill.skel.h" 35edff37b2SEduard Zingerman #include "verifier_stack_ptr.skel.h" 36ab839a58SEduard Zingerman #include "verifier_uninit.skel.h" 3703391494SEduard Zingerman #include "verifier_value_adj_spill.skel.h" 388f59e87aSEduard Zingerman #include "verifier_value.skel.h" 39d3305286SEduard Zingerman #include "verifier_value_or_null.skel.h" 40d15f5b68SEduard Zingerman #include "verifier_var_off.skel.h" 41*a8036aeaSEduard Zingerman #include "verifier_xadd.skel.h" 4255108621SEduard Zingerman 4355108621SEduard Zingerman __maybe_unused 4455108621SEduard Zingerman static void run_tests_aux(const char *skel_name, skel_elf_bytes_fn elf_bytes_factory) 4555108621SEduard Zingerman { 4655108621SEduard Zingerman struct test_loader tester = {}; 4755108621SEduard Zingerman __u64 old_caps; 4855108621SEduard Zingerman int err; 4955108621SEduard Zingerman 5055108621SEduard Zingerman /* test_verifier tests are executed w/o CAP_SYS_ADMIN, do the same here */ 5155108621SEduard Zingerman err = cap_disable_effective(1ULL << CAP_SYS_ADMIN, &old_caps); 5255108621SEduard Zingerman if (err) { 5355108621SEduard Zingerman PRINT_FAIL("failed to drop CAP_SYS_ADMIN: %i, %s\n", err, strerror(err)); 5455108621SEduard Zingerman return; 5555108621SEduard Zingerman } 5655108621SEduard Zingerman 5755108621SEduard Zingerman test_loader__run_subtests(&tester, skel_name, elf_bytes_factory); 5855108621SEduard Zingerman test_loader_fini(&tester); 5955108621SEduard Zingerman 6055108621SEduard Zingerman err = cap_enable_effective(old_caps, NULL); 6155108621SEduard Zingerman if (err) 6255108621SEduard Zingerman PRINT_FAIL("failed to restore CAP_SYS_ADMIN: %i, %s\n", err, strerror(err)); 6355108621SEduard Zingerman } 6455108621SEduard Zingerman 6555108621SEduard Zingerman #define RUN(skel) run_tests_aux(#skel, skel##__elf_bytes) 669d0f1568SEduard Zingerman 679d0f1568SEduard Zingerman void test_verifier_and(void) { RUN(verifier_and); } 68a3c830aeSEduard Zingerman void test_verifier_array_access(void) { RUN(verifier_array_access); } 690ccbe495SEduard Zingerman void test_verifier_basic_stack(void) { RUN(verifier_basic_stack); } 707605f94bSEduard Zingerman void test_verifier_bounds_deduction(void) { RUN(verifier_bounds_deduction); } 71b14a702aSEduard Zingerman void test_verifier_bounds_mix_sign_unsign(void) { RUN(verifier_bounds_mix_sign_unsign); } 722f2047c2SEduard Zingerman void test_verifier_cfg(void) { RUN(verifier_cfg); } 73047687a7SEduard Zingerman void test_verifier_cgroup_inv_retcode(void) { RUN(verifier_cgroup_inv_retcode); } 74b1b63725SEduard Zingerman void test_verifier_cgroup_skb(void) { RUN(verifier_cgroup_skb); } 758f16f3c0SEduard Zingerman void test_verifier_cgroup_storage(void) { RUN(verifier_cgroup_storage); } 76a2777eaaSEduard Zingerman void test_verifier_const_or(void) { RUN(verifier_const_or); } 77a58475a9SEduard Zingerman void test_verifier_ctx_sk_msg(void) { RUN(verifier_ctx_sk_msg); } 7884988478SEduard Zingerman void test_verifier_direct_stack_access_wraparound(void) { RUN(verifier_direct_stack_access_wraparound); } 7901a09255SEduard Zingerman void test_verifier_div0(void) { RUN(verifier_div0); } 809553de70SEduard Zingerman void test_verifier_div_overflow(void) { RUN(verifier_div_overflow); } 81b37d776bSEduard Zingerman void test_verifier_helper_access_var_len(void) { RUN(verifier_helper_access_var_len); } 82fb179fe6SEduard Zingerman void test_verifier_helper_packet_access(void) { RUN(verifier_helper_packet_access); } 8377aa2563SEduard Zingerman void test_verifier_helper_restricted(void) { RUN(verifier_helper_restricted); } 84ecc42482SEduard Zingerman void test_verifier_helper_value_access(void) { RUN(verifier_helper_value_access); } 8501481e67SEduard Zingerman void test_verifier_int_ptr(void) { RUN(verifier_int_ptr); } 86e2978755SEduard Zingerman void test_verifier_ld_ind(void) { RUN(verifier_ld_ind); } 87583c7ce5SEduard Zingerman void test_verifier_leak_ptr(void) { RUN(verifier_leak_ptr); } 88caf345cfSEduard Zingerman void test_verifier_map_ptr(void) { RUN(verifier_map_ptr); } 8905e474ecSEduard Zingerman void test_verifier_map_ret_val(void) { RUN(verifier_map_ret_val); } 90ade3f08fSEduard Zingerman void test_verifier_masking(void) { RUN(verifier_masking); } 9165428312SEduard Zingerman void test_verifier_meta_access(void) { RUN(verifier_meta_access); } 925a77a01fSEduard Zingerman void test_verifier_raw_stack(void) { RUN(verifier_raw_stack); } 9318cdc2b5SEduard Zingerman void test_verifier_raw_tp_writable(void) { RUN(verifier_raw_tp_writable); } 94b7e42030SEduard Zingerman void test_verifier_ringbuf(void) { RUN(verifier_ringbuf); } 95f4fe3cfeSEduard Zingerman void test_verifier_spill_fill(void) { RUN(verifier_spill_fill); } 96edff37b2SEduard Zingerman void test_verifier_stack_ptr(void) { RUN(verifier_stack_ptr); } 97ab839a58SEduard Zingerman void test_verifier_uninit(void) { RUN(verifier_uninit); } 9803391494SEduard Zingerman void test_verifier_value_adj_spill(void) { RUN(verifier_value_adj_spill); } 998f59e87aSEduard Zingerman void test_verifier_value(void) { RUN(verifier_value); } 100d3305286SEduard Zingerman void test_verifier_value_or_null(void) { RUN(verifier_value_or_null); } 101d15f5b68SEduard Zingerman void test_verifier_var_off(void) { RUN(verifier_var_off); } 102*a8036aeaSEduard Zingerman void test_verifier_xadd(void) { RUN(verifier_xadd); } 103