tools/testing/selftests/bpf/test_verifier.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/test_verifier.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/test_verifier.c- Extension
.c- Size
- 49088 bytes
- Lines
- 1855
- 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.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
endian.hasm/types.hlinux/types.hstdint.hstdio.hstdlib.hunistd.herrno.hstring.hstddef.hstdbool.hsched.hlimits.hassert.hlinux/unistd.hlinux/filter.hlinux/bpf_perf_event.hlinux/bpf.hlinux/if_ether.hlinux/btf.hbpf/btf.hbpf/bpf.hbpf/libbpf.hautoconf_helper.hunpriv_helpers.hcap_helpers.hbpf_rand.hbpf_util.htest_btf.h../../../include/linux/filter.htesting_helpers.hverifier/tests.h
Detected Declarations
struct kfunc_btf_id_pairstruct bpf_teststruct test_valstruct other_valfunction bpf_fill_ld_abs_vlan_push_popfunction bpf_fill_jump_around_ld_absfunction bpf_fill_rand_ld_dwfunction bpf_fill_scale1function bpf_fill_scale2function bpf_fill_scalefunction bpf_fill_torturous_jumps_insn_1function bpf_fill_torturous_jumps_insn_2function bpf_fill_torturous_jumpsfunction bpf_fill_big_prog_with_loop_1function probe_filter_lengthfunction skip_unsupported_mapfunction __create_mapfunction create_mapfunction update_mapfunction create_prog_dummy_simplefunction create_prog_dummy_loopfunction create_prog_arrayfunction create_map_in_mapfunction create_cgroup_storagefunction load_btf_specfunction load_btffunction load_btf_for_testfunction create_map_spin_lockfunction create_sk_storage_mapfunction create_map_timerfunction create_map_kptrfunction set_rootfunction ptr_to_u64function kfuncs_cleanupfunction fixup_prog_kfuncsfunction do_test_fixupfunction set_adminfunction do_prog_test_runfunction cmp_str_seqfunction is_null_insnfunction is_skip_insnfunction null_terminated_insn_lenfunction compare_masked_insnfunction find_insn_subseqfunction find_skip_insn_markerfunction find_all_insn_subseqsfunction print_insnfunction check_xlated_program
Annotated Snippet
struct kfunc_btf_id_pair {
const char *kfunc;
int insn_idx;
};
struct bpf_test {
const char *descr;
struct bpf_insn insns[MAX_INSNS];
struct bpf_insn *fill_insns;
/* If specified, test engine looks for this sequence of
* instructions in the BPF program after loading. Allows to
* test rewrites applied by verifier. Use values
* INSN_OFF_MASK and INSN_IMM_MASK to mask `off` and `imm`
* fields if content does not matter. The test case fails if
* specified instructions are not found.
*
* The sequence could be split into sub-sequences by adding
* SKIP_INSNS instruction at the end of each sub-sequence. In
* such case sub-sequences are searched for one after another.
*/
struct bpf_insn expected_insns[MAX_EXPECTED_INSNS];
/* If specified, test engine applies same pattern matching
* logic as for `expected_insns`. If the specified pattern is
* matched test case is marked as failed.
*/
struct bpf_insn unexpected_insns[MAX_UNEXPECTED_INSNS];
int fixup_map_hash_8b[MAX_FIXUPS];
int fixup_map_hash_48b[MAX_FIXUPS];
int fixup_map_hash_16b[MAX_FIXUPS];
int fixup_map_array_48b[MAX_FIXUPS];
int fixup_map_sockmap[MAX_FIXUPS];
int fixup_map_sockhash[MAX_FIXUPS];
int fixup_map_xskmap[MAX_FIXUPS];
int fixup_map_stacktrace[MAX_FIXUPS];
int fixup_prog1[MAX_FIXUPS];
int fixup_prog2[MAX_FIXUPS];
int fixup_map_in_map[MAX_FIXUPS];
int fixup_cgroup_storage[MAX_FIXUPS];
int fixup_percpu_cgroup_storage[MAX_FIXUPS];
int fixup_map_spin_lock[MAX_FIXUPS];
int fixup_map_array_ro[MAX_FIXUPS];
int fixup_map_array_wo[MAX_FIXUPS];
int fixup_map_array_small[MAX_FIXUPS];
int fixup_sk_storage_map[MAX_FIXUPS];
int fixup_map_event_output[MAX_FIXUPS];
int fixup_map_reuseport_array[MAX_FIXUPS];
int fixup_map_ringbuf[MAX_FIXUPS];
int fixup_map_timer[MAX_FIXUPS];
int fixup_map_kptr[MAX_FIXUPS];
struct kfunc_btf_id_pair fixup_kfunc_btf_id[MAX_FIXUPS];
/* Expected verifier log output for result REJECT or VERBOSE_ACCEPT.
* Can be a tab-separated sequence of expected strings. An empty string
* means no log verification.
*/
const char *errstr;
const char *errstr_unpriv;
uint32_t insn_processed;
int prog_len;
enum {
UNDEF,
ACCEPT,
REJECT,
VERBOSE_ACCEPT,
} result, result_unpriv;
enum bpf_prog_type prog_type;
uint8_t flags;
void (*fill_helper)(struct bpf_test *self);
int runs;
#define bpf_testdata_struct_t \
struct { \
uint32_t retval, retval_unpriv; \
union { \
__u8 data[TEST_DATA_LEN]; \
__u64 data64[TEST_DATA_LEN / 8]; \
}; \
}
union {
bpf_testdata_struct_t;
bpf_testdata_struct_t retvals[MAX_TEST_RUNS];
};
enum bpf_attach_type expected_attach_type;
const char *kfunc;
struct bpf_func_info func_info[MAX_FUNC_INFOS];
int func_info_cnt;
char btf_strings[MAX_BTF_STRINGS];
/* A set of BTF types to load when specified,
* use macro definitions from test_btf.h,
* must end with BTF_END_RAW
*/
__u32 btf_types[MAX_BTF_TYPES];
Annotation
- Immediate include surface: `endian.h`, `asm/types.h`, `linux/types.h`, `stdint.h`, `stdio.h`, `stdlib.h`, `unistd.h`, `errno.h`.
- Detected declarations: `struct kfunc_btf_id_pair`, `struct bpf_test`, `struct test_val`, `struct other_val`, `function bpf_fill_ld_abs_vlan_push_pop`, `function bpf_fill_jump_around_ld_abs`, `function bpf_fill_rand_ld_dw`, `function bpf_fill_scale1`, `function bpf_fill_scale2`, `function bpf_fill_scale`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.