tools/testing/selftests/bpf/progs/verifier_raw_stack.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/progs/verifier_raw_stack.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/progs/verifier_raw_stack.c- Extension
.c- Size
- 8604 bytes
- Lines
- 373
- 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.hbpf_misc.h
Detected Declarations
function __msg_unprivfunction __msgfunction __msgfunction __msgfunction __retvalfunction __retvalfunction __retvalfunction __msgfunction __msgfunction __retvalfunction __msgfunction __msgfunction __msgfunction __msgfunction __msgfunction __msgfunction __retval
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/* Converted from tools/testing/selftests/bpf/verifier/raw_stack.c */
#include <linux/bpf.h>
#include <bpf/bpf_helpers.h>
#include "bpf_misc.h"
SEC("socket")
__description("raw_stack: no skb_load_bytes")
__success
__failure_unpriv __msg_unpriv("invalid read from stack R6 off=-8 size=8")
__naked void stack_no_skb_load_bytes(void)
{
asm volatile (" \
r2 = 4; \
r6 = r10; \
r6 += -8; \
r3 = r6; \
r4 = 8; \
/* Call to skb_load_bytes() omitted. */ \
r0 = *(u64*)(r6 + 0); \
exit; \
" ::: __clobber_all);
}
SEC("tc")
__description("raw_stack: skb_load_bytes, negative len")
__failure __msg("R4 min value is negative")
__naked void skb_load_bytes_negative_len(void)
{
asm volatile (" \
r2 = 4; \
r6 = r10; \
r6 += -8; \
r3 = r6; \
r4 = -8; \
call %[bpf_skb_load_bytes]; \
r0 = *(u64*)(r6 + 0); \
exit; \
" :
: __imm(bpf_skb_load_bytes)
: __clobber_all);
}
SEC("tc")
__description("raw_stack: skb_load_bytes, negative len 2")
__failure __msg("R4 min value is negative")
__naked void load_bytes_negative_len_2(void)
{
asm volatile (" \
r2 = 4; \
r6 = r10; \
r6 += -8; \
r3 = r6; \
r4 = %[__imm_0]; \
call %[bpf_skb_load_bytes]; \
r0 = *(u64*)(r6 + 0); \
exit; \
" :
: __imm(bpf_skb_load_bytes),
__imm_const(__imm_0, ~0)
: __clobber_all);
}
SEC("tc")
__description("raw_stack: skb_load_bytes, zero len")
__failure __msg("R4 invalid zero-sized read: u64=[0,0]")
__naked void skb_load_bytes_zero_len(void)
{
asm volatile (" \
r2 = 4; \
r6 = r10; \
r6 += -8; \
r3 = r6; \
r4 = 0; \
call %[bpf_skb_load_bytes]; \
r0 = *(u64*)(r6 + 0); \
exit; \
" :
: __imm(bpf_skb_load_bytes)
: __clobber_all);
}
SEC("tc")
__description("raw_stack: skb_load_bytes, no init")
__success __retval(0)
__naked void skb_load_bytes_no_init(void)
{
asm volatile (" \
r2 = 4; \
Annotation
- Immediate include surface: `linux/bpf.h`, `bpf/bpf_helpers.h`, `bpf_misc.h`.
- Detected declarations: `function __msg_unpriv`, `function __msg`, `function __msg`, `function __msg`, `function __retval`, `function __retval`, `function __retval`, `function __msg`, `function __msg`, `function __retval`.
- 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.