tools/testing/selftests/bpf/progs/verifier_bpf_trap.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/progs/verifier_bpf_trap.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/progs/verifier_bpf_trap.c- Extension
.c- Size
- 1535 bytes
- Lines
- 72
- 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.
Dependency Surface
vmlinux.hbpf/bpf_helpers.hbpf_misc.h
Detected Declarations
function __msgfunction __msgfunction __msgfunction dead_bpf_trap_in_middlefunction __msg
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/* Copyright (c) 2025 Meta Platforms, Inc. and affiliates. */
#include <vmlinux.h>
#include <bpf/bpf_helpers.h>
#include "bpf_misc.h"
#if __clang_major__ >= 21 && 0
SEC("socket")
__description("__builtin_trap with simple c code")
__failure __msg("unexpected __bpf_trap() due to uninitialized variable?")
void bpf_builtin_trap_with_simple_c(void)
{
__builtin_trap();
}
#endif
SEC("socket")
__description("__bpf_trap with simple c code")
__failure __msg("unexpected __bpf_trap() due to uninitialized variable?")
void bpf_trap_with_simple_c(void)
{
__bpf_trap();
}
SEC("socket")
__description("__bpf_trap as the second-from-last insn")
__failure __msg("unexpected __bpf_trap() due to uninitialized variable?")
__naked void bpf_trap_at_func_end(void)
{
asm volatile (
"r0 = 0;"
"call %[__bpf_trap];"
"exit;"
:
: __imm(__bpf_trap)
: __clobber_all);
}
SEC("socket")
__description("dead code __bpf_trap in the middle of code")
__success
__naked void dead_bpf_trap_in_middle(void)
{
asm volatile (
"r0 = 0;"
"if r0 == 0 goto +1;"
"call %[__bpf_trap];"
"r0 = 2;"
"exit;"
:
: __imm(__bpf_trap)
: __clobber_all);
}
SEC("socket")
__description("reachable __bpf_trap in the middle of code")
__failure __msg("unexpected __bpf_trap() due to uninitialized variable?")
__naked void live_bpf_trap_in_middle(void)
{
asm volatile (
"r0 = 0;"
"if r0 == 1 goto +1;"
"call %[__bpf_trap];"
"r0 = 2;"
"exit;"
:
: __imm(__bpf_trap)
: __clobber_all);
}
char _license[] SEC("license") = "GPL";
Annotation
- Immediate include surface: `vmlinux.h`, `bpf/bpf_helpers.h`, `bpf_misc.h`.
- Detected declarations: `function __msg`, `function __msg`, `function __msg`, `function dead_bpf_trap_in_middle`, `function __msg`.
- 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.