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" 18*01a09255SEduard Zingerman #include "verifier_div0.skel.h" 1955108621SEduard Zingerman 2055108621SEduard Zingerman __maybe_unused 2155108621SEduard Zingerman static void run_tests_aux(const char *skel_name, skel_elf_bytes_fn elf_bytes_factory) 2255108621SEduard Zingerman { 2355108621SEduard Zingerman struct test_loader tester = {}; 2455108621SEduard Zingerman __u64 old_caps; 2555108621SEduard Zingerman int err; 2655108621SEduard Zingerman 2755108621SEduard Zingerman /* test_verifier tests are executed w/o CAP_SYS_ADMIN, do the same here */ 2855108621SEduard Zingerman err = cap_disable_effective(1ULL << CAP_SYS_ADMIN, &old_caps); 2955108621SEduard Zingerman if (err) { 3055108621SEduard Zingerman PRINT_FAIL("failed to drop CAP_SYS_ADMIN: %i, %s\n", err, strerror(err)); 3155108621SEduard Zingerman return; 3255108621SEduard Zingerman } 3355108621SEduard Zingerman 3455108621SEduard Zingerman test_loader__run_subtests(&tester, skel_name, elf_bytes_factory); 3555108621SEduard Zingerman test_loader_fini(&tester); 3655108621SEduard Zingerman 3755108621SEduard Zingerman err = cap_enable_effective(old_caps, NULL); 3855108621SEduard Zingerman if (err) 3955108621SEduard Zingerman PRINT_FAIL("failed to restore CAP_SYS_ADMIN: %i, %s\n", err, strerror(err)); 4055108621SEduard Zingerman } 4155108621SEduard Zingerman 4255108621SEduard Zingerman #define RUN(skel) run_tests_aux(#skel, skel##__elf_bytes) 439d0f1568SEduard Zingerman 449d0f1568SEduard Zingerman void test_verifier_and(void) { RUN(verifier_and); } 45a3c830aeSEduard Zingerman void test_verifier_array_access(void) { RUN(verifier_array_access); } 460ccbe495SEduard Zingerman void test_verifier_basic_stack(void) { RUN(verifier_basic_stack); } 477605f94bSEduard Zingerman void test_verifier_bounds_deduction(void) { RUN(verifier_bounds_deduction); } 48b14a702aSEduard Zingerman void test_verifier_bounds_mix_sign_unsign(void) { RUN(verifier_bounds_mix_sign_unsign); } 492f2047c2SEduard Zingerman void test_verifier_cfg(void) { RUN(verifier_cfg); } 50047687a7SEduard Zingerman void test_verifier_cgroup_inv_retcode(void) { RUN(verifier_cgroup_inv_retcode); } 51b1b63725SEduard Zingerman void test_verifier_cgroup_skb(void) { RUN(verifier_cgroup_skb); } 528f16f3c0SEduard Zingerman void test_verifier_cgroup_storage(void) { RUN(verifier_cgroup_storage); } 53a2777eaaSEduard Zingerman void test_verifier_const_or(void) { RUN(verifier_const_or); } 54a58475a9SEduard Zingerman void test_verifier_ctx_sk_msg(void) { RUN(verifier_ctx_sk_msg); } 5584988478SEduard Zingerman void test_verifier_direct_stack_access_wraparound(void) { RUN(verifier_direct_stack_access_wraparound); } 56*01a09255SEduard Zingerman void test_verifier_div0(void) { RUN(verifier_div0); } 57