tools/testing/selftests/bpf/prog_tests/verifier.c

Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/prog_tests/verifier.c

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/bpf/prog_tests/verifier.c
Extension
.c
Size
15791 bytes
Lines
327
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: implementation source
Status
source implementation candidate

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

struct test_val {
	unsigned int index;
	int foo[MAX_ENTRIES];
};

__maybe_unused
static void run_tests_aux(const char *skel_name,
			  skel_elf_bytes_fn elf_bytes_factory,
			  pre_execution_cb pre_execution_cb)
{
	struct test_loader tester = {};
	__u64 old_caps;
	int err;

	/* test_verifier tests are executed w/o CAP_SYS_ADMIN, do the same here */
	err = cap_disable_effective(1ULL << CAP_SYS_ADMIN, &old_caps);
	if (err) {
		PRINT_FAIL("failed to drop CAP_SYS_ADMIN: %i, %s\n", err, strerror(-err));
		return;
	}

	test_loader__set_pre_execution_cb(&tester, pre_execution_cb);
	test_loader__run_subtests(&tester, skel_name, elf_bytes_factory);
	test_loader_fini(&tester);

	err = cap_enable_effective(old_caps, NULL);
	if (err)
		PRINT_FAIL("failed to restore CAP_SYS_ADMIN: %i, %s\n", err, strerror(-err));
}

#define RUN(skel) run_tests_aux(#skel, skel##__elf_bytes, NULL)

void test_verifier_align(void)                { RUN(verifier_align); }
void test_verifier_and(void)                  { RUN(verifier_and); }
void test_verifier_arena(void)                { RUN(verifier_arena); }
void test_verifier_arena_large(void)          { RUN(verifier_arena_large); }
void test_verifier_arena_globals1(void)       { RUN(verifier_arena_globals1); }
void test_verifier_arena_globals2(void)       { RUN(verifier_arena_globals2); }
void test_verifier_basic_stack(void)          { RUN(verifier_basic_stack); }
void test_verifier_bitfield_write(void)       { RUN(verifier_bitfield_write); }
void test_verifier_bounds(void)               { RUN(verifier_bounds); }
void test_verifier_bounds_deduction(void)     { RUN(verifier_bounds_deduction); }
void test_verifier_bounds_deduction_non_const(void)     { RUN(verifier_bounds_deduction_non_const); }
void test_verifier_bounds_mix_sign_unsign(void) { RUN(verifier_bounds_mix_sign_unsign); }
void test_verifier_bpf_get_stack(void)        { RUN(verifier_bpf_get_stack); }
void test_verifier_bpf_trap(void)             { RUN(verifier_bpf_trap); }
void test_verifier_bswap(void)                { RUN(verifier_bswap); }
void test_verifier_btf_ctx_access(void)       { RUN(verifier_btf_ctx_access); }
void test_verifier_btf_unreliable_prog(void)  { RUN(verifier_btf_unreliable_prog); }
void test_verifier_call_large_imm(void)       { RUN(verifier_call_large_imm); }
void test_verifier_cfg(void)                  { RUN(verifier_cfg); }
void test_verifier_cgroup_inv_retcode(void)   { RUN(verifier_cgroup_inv_retcode); }
void test_verifier_cgroup_skb(void)           { RUN(verifier_cgroup_skb); }
void test_verifier_cgroup_storage(void)       { RUN(verifier_cgroup_storage); }
void test_verifier_const(void)                { RUN(verifier_const); }
void test_verifier_const_or(void)             { RUN(verifier_const_or); }
void test_verifier_ctx(void)                  { RUN_TESTS(verifier_ctx); }
void test_verifier_ctx_sk_msg(void)           { RUN(verifier_ctx_sk_msg); }
void test_verifier_d_path(void)               { RUN(verifier_d_path); }
void test_verifier_default_trusted_ptr(void)  { RUN_TESTS(verifier_default_trusted_ptr); }
void test_verifier_direct_packet_access(void) { RUN(verifier_direct_packet_access); }
void test_verifier_direct_stack_access_wraparound(void) { RUN(verifier_direct_stack_access_wraparound); }
void test_verifier_div0(void)                 { RUN(verifier_div0); }
void test_verifier_div_mod_bounds(void)       { RUN(verifier_div_mod_bounds); }
void test_verifier_div_overflow(void)         { RUN(verifier_div_overflow); }
void test_verifier_flow_keys(void)            { RUN(verifier_flow_keys); }
void test_verifier_global_subprogs(void)      { RUN(verifier_global_subprogs); }
void test_verifier_global_ptr_args(void)      { RUN(verifier_global_ptr_args); }
void test_verifier_gotol(void)                { RUN(verifier_gotol); }
void test_verifier_gotox(void)                { RUN(verifier_gotox); }
void test_verifier_helper_access_var_len(void) { RUN(verifier_helper_access_var_len); }
void test_verifier_helper_packet_access(void) { RUN(verifier_helper_packet_access); }
void test_verifier_helper_restricted(void)    { RUN(verifier_helper_restricted); }
void test_verifier_helper_value_access(void)  { RUN(verifier_helper_value_access); }
void test_verifier_int_ptr(void)              { RUN(verifier_int_ptr); }
void test_verifier_iterating_callbacks(void)  { RUN(verifier_iterating_callbacks); }
void test_verifier_jeq_infer_not_null(void)   { RUN(verifier_jeq_infer_not_null); }
void test_verifier_jit_convergence(void)      { RUN(verifier_jit_convergence); }
void test_verifier_load_acquire(void)         { RUN(verifier_load_acquire); }
void test_verifier_ld_ind(void)               { RUN(verifier_ld_ind); }
void test_verifier_ldsx(void)                  { RUN(verifier_ldsx); }
void test_verifier_leak_ptr(void)             { RUN(verifier_leak_ptr); }
void test_verifier_linked_scalars(void)       { RUN(verifier_linked_scalars); }
void test_verifier_live_stack(void)           { RUN(verifier_live_stack); }
void test_verifier_liveness_exp(void)         { RUN(verifier_liveness_exp); }
void test_verifier_loops1(void)               { RUN(verifier_loops1); }
void test_verifier_lwt(void)                  { RUN(verifier_lwt); }
void test_verifier_map_in_map(void)           { RUN(verifier_map_in_map); }
void test_verifier_map_ptr(void)              { RUN(verifier_map_ptr); }
void test_verifier_map_ptr_mixing(void)       { RUN(verifier_map_ptr_mixing); }

Annotation

Implementation Notes