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" 24*01481e67SEduard Zingerman #include "verifier_int_ptr.skel.h" 2555108621SEduard Zingerman 2655108621SEduard Zingerman __maybe_unused 2755108621SEduard Zingerman static void run_tests_aux(const char *skel_name, skel_elf_bytes_fn elf_bytes_factory) 2855108621SEduard Zingerman { 2955108621SEduard Zingerman struct test_loader tester = {}; 3055108621SEduard Zingerman __u64 old_caps; 3155108621SEduard Zingerman int err; 3255108621SEduard Zingerman 3355108621SEduard Zingerman /* test_verifier tests are executed w/o CAP_SYS_ADMIN, do the same here */ 3455108621SEduard Zingerman err = cap_disable_effective(1ULL << CAP_SYS_ADMIN, &old_caps); 3555108621SEduard Zingerman if (err) { 3655108621SEduard Zingerman PRINT_FAIL("failed to drop CAP_SYS_ADMIN: %i, %s\n", err, strerror(err)); 3755108621SEduard Zingerman return; 3855108621SEduard Zingerman } 3955108621SEduard Zingerman 4055108621SEduard Zingerman test_loader__run_subtests(&tester, skel_name, elf_bytes_factory); 4155108621SEduard Zingerman test_loader_fini(&tester); 4255108621SEduard Zingerman 4355108621SEduard Zingerman err = cap_enable_effective(old_caps, NULL); 4455108621SEduard Zingerman if (err) 4555108621SEduard Zingerman PRINT_FAIL("failed to restore CAP_SYS_ADMIN: %i, %s\n", err, strerror(err)); 4655108621SEduard Zingerman } 4755108621SEduard Zingerman 4855108621SEduard Zingerman #define RUN(skel) run_tests_aux(#skel, skel##__elf_bytes) 499d0f1568SEduard Zingerman 509d0f1568SEduard Zingerman void test_verifier_and(void) { RUN(verifier_and); } 51a3c830aeSEduard Zingerman void test_verifier_array_access(void) { RUN(verifier_array_access); } 520ccbe495SEduard Zingerman void test_verifier_basic_stack(void) { RUN(verifier_basic_stack); } 537605f94bSEduard Zingerman void test_verifier_bounds_deduction(void) { RUN(verifier_bounds_deduction); } 54b14a702aSEduard Zingerman void test_verifier_bounds_mix_sign_unsign(void) { RUN(verifier_bounds_mix_sign_unsign); } 552f2047c2SEduard Zingerman void test_verifier_cfg(void) { RUN(verifier_cfg); } 56047687a7SEduard Zingerman void test_verifier_cgroup_inv_retcode(void) { RUN(verifier_cgroup_inv_retcode); } 57b1b63725SEduard Zingerman void test_verifier_cgroup_skb(void) { RUN(verifier_cgroup_skb); } 588f16f3c0SEduard Zingerman void test_verifier_cgroup_storage(void) { RUN(verifier_cgroup_storage); } 59a2777eaaSEduard Zingerman void test_verifier_const_or(void) { RUN(verifier_const_or); } 60a58475a9SEduard Zingerman void test_verifier_ctx_sk_msg(void) { RUN(verifier_ctx_sk_msg); } 6184988478SEduard Zingerman void test_verifier_direct_stack_access_wraparound(void) { RUN(verifier_direct_stack_access_wraparound); } 6201a09255SEduard Zingerman void test_verifier_div0(void) { RUN(verifier_div0); } 639553de70SEduard Zingerman void test_verifier_div_overflow(void) { RUN(verifier_div_overflow); } 64b37d776bSEduard Zingerman void test_verifier_helper_access_var_len(void) { RUN(verifier_helper_access_var_len); } 65fb179fe6SEduard Zingerman void test_verifier_helper_packet_access(void) { RUN(verifier_helper_packet_access); } 6677aa2563SEduard Zingerman void test_verifier_helper_restricted(void) { RUN(verifier_helper_restricted); } 67ecc42482SEduard Zingerman void test_verifier_helper_value_access(void) { RUN(verifier_helper_value_access); } 68*01481e67SEduard Zingerman void test_verifier_int_ptr(void) { RUN(verifier_int_ptr); } 69