tools/testing/selftests/bpf/progs/verifier_meta_access.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/progs/verifier_meta_access.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/progs/verifier_meta_access.c- Extension
.c- Size
- 7301 bytes
- Lines
- 285
- 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 __retvalfunction __msgfunction __msgfunction __msgfunction __msgfunction __msgfunction __retvalfunction __retvalfunction __msgfunction __msgfunction __retvalfunction __retval
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/* Converted from tools/testing/selftests/bpf/verifier/meta_access.c */
#include <linux/bpf.h>
#include <bpf/bpf_helpers.h>
#include "bpf_misc.h"
SEC("xdp")
__description("meta access, test1")
__success __retval(0)
__naked void meta_access_test1(void)
{
asm volatile (" \
r2 = *(u32*)(r1 + %[xdp_md_data_meta]); \
r3 = *(u32*)(r1 + %[xdp_md_data]); \
r0 = r2; \
r0 += 8; \
if r0 > r3 goto l0_%=; \
r0 = *(u8*)(r2 + 0); \
l0_%=: r0 = 0; \
exit; \
" :
: __imm_const(xdp_md_data, offsetof(struct xdp_md, data)),
__imm_const(xdp_md_data_meta, offsetof(struct xdp_md, data_meta))
: __clobber_all);
}
SEC("xdp")
__description("meta access, test2")
__failure __msg("R0 min value is negative")
__naked void meta_access_test2(void)
{
asm volatile (" \
r2 = *(u32*)(r1 + %[xdp_md_data_meta]); \
r3 = *(u32*)(r1 + %[xdp_md_data]); \
r0 = r2; \
r0 -= 8; \
r4 = r2; \
r4 += 8; \
if r4 > r3 goto l0_%=; \
r0 = *(u8*)(r0 + 0); \
l0_%=: r0 = 0; \
exit; \
" :
: __imm_const(xdp_md_data, offsetof(struct xdp_md, data)),
__imm_const(xdp_md_data_meta, offsetof(struct xdp_md, data_meta))
: __clobber_all);
}
SEC("xdp")
__description("meta access, test3")
__failure __msg("invalid access to packet")
__naked void meta_access_test3(void)
{
asm volatile (" \
r2 = *(u32*)(r1 + %[xdp_md_data_meta]); \
r3 = *(u32*)(r1 + %[xdp_md_data_end]); \
r0 = r2; \
r0 += 8; \
if r0 > r3 goto l0_%=; \
r0 = *(u8*)(r2 + 0); \
l0_%=: r0 = 0; \
exit; \
" :
: __imm_const(xdp_md_data_end, offsetof(struct xdp_md, data_end)),
__imm_const(xdp_md_data_meta, offsetof(struct xdp_md, data_meta))
: __clobber_all);
}
SEC("xdp")
__description("meta access, test4")
__failure __msg("invalid access to packet")
__naked void meta_access_test4(void)
{
asm volatile (" \
r2 = *(u32*)(r1 + %[xdp_md_data_meta]); \
r3 = *(u32*)(r1 + %[xdp_md_data_end]); \
r4 = *(u32*)(r1 + %[xdp_md_data]); \
r0 = r4; \
r0 += 8; \
if r0 > r3 goto l0_%=; \
r0 = *(u8*)(r2 + 0); \
l0_%=: r0 = 0; \
exit; \
" :
: __imm_const(xdp_md_data, offsetof(struct xdp_md, data)),
__imm_const(xdp_md_data_end, offsetof(struct xdp_md, data_end)),
__imm_const(xdp_md_data_meta, offsetof(struct xdp_md, data_meta))
: __clobber_all);
}
Annotation
- Immediate include surface: `linux/bpf.h`, `bpf/bpf_helpers.h`, `bpf_misc.h`.
- Detected declarations: `function __retval`, `function __msg`, `function __msg`, `function __msg`, `function __msg`, `function __msg`, `function __retval`, `function __retval`, `function __msg`, `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.