tools/testing/selftests/bpf/progs/verifier_live_stack.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/progs/verifier_live_stack.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/progs/verifier_live_stack.c- Extension
.c- Size
- 74182 bytes
- Lines
- 2843
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bpf.hbpf/bpf_helpers.h../../../include/linux/filter.hbpf_misc.h
Detected Declarations
function simple_read_simple_writefunction read_write_joinfunction must_write_not_same_slotfunction must_write_not_same_typefunction caller_stack_writefunction write_first_paramfunction caller_stack_readfunction read_first_paramfunction arg_track_join_convergencefunction arg_track_join_convergence_subprogfunction caller_stack_pruningfunction read_first_param2function __msgfunction loop_cbfunction syzbot_postorder_bug1function __msgfunction write_tail_callfunction subprog_precise_stack_accessfunction precise_read_twofunction subprog_multilevel_conservativefunction forward_to_innerfunction inner_calleefunction callee_consumed_caller_stackfunction consume_and_call_innerfunction do_nothing2function __msgfunction maybe_clobber_keyfunction maybe_clobber_keyfunction modifier2function modifier2function spill_reload_reader2function __kfunc_btf_rootfunction kfunc_iter_stack_livenessfunction stacksafefunction four_byte_write_kills_slotfunction dead_half_spi_writefunction four_byte_read_upper_halffunction two_byte_write_no_killfunction one_byte_write_no_killfunction high_stack_second_bitmask_wordfunction two_four_byte_writes_kill_full_spifunction both_branches_kill_slotfunction halffunction Afunction spis_set_allfunction __msgfunction conditional_stx_in_subprogfunction cond_writer
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/* Copyright (c) 2025 Meta Platforms, Inc. and affiliates. */
#include <linux/bpf.h>
#include <bpf/bpf_helpers.h>
#include "../../../include/linux/filter.h"
#include "bpf_misc.h"
char _license[] SEC("license") = "GPL";
struct {
__uint(type, BPF_MAP_TYPE_HASH);
__uint(max_entries, 1);
__type(key, int);
__type(value, long long);
} map SEC(".maps");
struct {
__uint(type, BPF_MAP_TYPE_ARRAY);
__uint(max_entries, 1);
__type(key, __u32);
__type(value, __u64);
} array_map_8b SEC(".maps");
const char snprintf_u64_fmt[] = "%llu";
SEC("socket")
__log_level(2)
__msg("0: (79) r1 = *(u64 *)(r10 -8) ; use: fp0-8")
__msg("1: (79) r2 = *(u64 *)(r10 -24) ; use: fp0-24")
__msg("2: (7b) *(u64 *)(r10 -8) = r1 ; def: fp0-8")
__naked void simple_read_simple_write(void)
{
asm volatile (
"r1 = *(u64 *)(r10 - 8);"
"r2 = *(u64 *)(r10 - 24);"
"*(u64 *)(r10 - 8) = r1;"
"r0 = 0;"
"exit;"
::: __clobber_all);
}
SEC("socket")
__log_level(2)
__msg("2: (79) r0 = *(u64 *)(r10 -8) ; use: fp0-8")
__msg("6: (79) r0 = *(u64 *)(r10 -16) ; use: fp0-16")
__naked void read_write_join(void)
{
asm volatile (
"call %[bpf_get_prandom_u32];"
"if r0 > 42 goto 1f;"
"r0 = *(u64 *)(r10 - 8);"
"*(u64 *)(r10 - 32) = r0;"
"*(u64 *)(r10 - 40) = r0;"
"exit;"
"1:"
"r0 = *(u64 *)(r10 - 16);"
"*(u64 *)(r10 - 32) = r0;"
"exit;"
:: __imm(bpf_get_prandom_u32)
: __clobber_all);
}
SEC("socket")
__log_level(2)
__msg("stack use/def subprog#0 must_write_not_same_slot (d0,cs0):")
__msg("6: (7b) *(u64 *)(r2 +0) = r0{{$}}")
__msg("Live regs before insn:")
__naked void must_write_not_same_slot(void)
{
asm volatile (
"call %[bpf_get_prandom_u32];"
"r1 = -8;"
"if r0 > 42 goto 1f;"
"r1 = -16;"
"1:"
"r2 = r10;"
"r2 += r1;"
"*(u64 *)(r2 + 0) = r0;"
"exit;"
:: __imm(bpf_get_prandom_u32)
: __clobber_all);
}
SEC("socket")
__log_level(2)
__msg("0: (7a) *(u64 *)(r10 -8) = 0 ; def: fp0-8")
__msg("5: (85) call bpf_map_lookup_elem#1 ; use: fp0-8h")
__naked void must_write_not_same_type(void)
{
asm volatile (
Annotation
- Immediate include surface: `linux/bpf.h`, `bpf/bpf_helpers.h`, `../../../include/linux/filter.h`, `bpf_misc.h`.
- Detected declarations: `function simple_read_simple_write`, `function read_write_join`, `function must_write_not_same_slot`, `function must_write_not_same_type`, `function caller_stack_write`, `function write_first_param`, `function caller_stack_read`, `function read_first_param`, `function arg_track_join_convergence`, `function arg_track_join_convergence_subprog`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
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.