tools/testing/selftests/bpf/progs/verifier_vfs_accept.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/progs/verifier_vfs_accept.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/progs/verifier_vfs_accept.c- Extension
.c- Size
- 2122 bytes
- Lines
- 104
- 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
vmlinux.herrno.hbpf/bpf_helpers.hbpf/bpf_tracing.hbpf_misc.hbpf_experimental.h
Detected Declarations
function BPF_PROGfunction BPF_PROGfunction BPF_PROGfunction BPF_PROGfunction BPF_PROGfunction BPF_PROG
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/* Copyright (c) 2024 Google LLC. */
#include <vmlinux.h>
#include <errno.h>
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_tracing.h>
#include "bpf_misc.h"
#include "bpf_experimental.h"
static char buf[64];
SEC("lsm.s/file_open")
__success
int BPF_PROG(get_task_exe_file_and_put_kfunc_from_current_sleepable)
{
struct file *acquired;
acquired = bpf_get_task_exe_file(bpf_get_current_task_btf());
if (!acquired)
return 0;
bpf_put_file(acquired);
return 0;
}
SEC("lsm/file_open")
__success
int BPF_PROG(get_task_exe_file_and_put_kfunc_from_current_non_sleepable, struct file *file)
{
struct file *acquired;
acquired = bpf_get_task_exe_file(bpf_get_current_task_btf());
if (!acquired)
return 0;
bpf_put_file(acquired);
return 0;
}
SEC("lsm.s/task_alloc")
__success
int BPF_PROG(get_task_exe_file_and_put_kfunc_from_argument,
struct task_struct *task)
{
struct file *acquired;
acquired = bpf_get_task_exe_file(task);
if (!acquired)
return 0;
bpf_put_file(acquired);
return 0;
}
SEC("lsm.s/inode_getattr")
__success
int BPF_PROG(path_d_path_from_path_argument, struct path *path)
{
int ret;
ret = bpf_path_d_path(path, buf, sizeof(buf));
__sink(ret);
return 0;
}
SEC("lsm.s/file_open")
__success
int BPF_PROG(path_d_path_from_file_argument, struct file *file)
{
int ret;
const struct path *path;
/* The f_path member is a path which is embedded directly within a
* file. Therefore, a pointer to such embedded members are still
* recognized by the BPF verifier as being PTR_TRUSTED as it's
* essentially PTR_TRUSTED w/ a non-zero fixed offset.
*/
path = &file->f_path;
ret = bpf_path_d_path(path, buf, sizeof(buf));
__sink(ret);
return 0;
}
SEC("lsm.s/inode_rename")
__success
int BPF_PROG(inode_rename, struct inode *old_dir, struct dentry *old_dentry,
struct inode *new_dir, struct dentry *new_dentry,
unsigned int flags)
Annotation
- Immediate include surface: `vmlinux.h`, `errno.h`, `bpf/bpf_helpers.h`, `bpf/bpf_tracing.h`, `bpf_misc.h`, `bpf_experimental.h`.
- Detected declarations: `function BPF_PROG`, `function BPF_PROG`, `function BPF_PROG`, `function BPF_PROG`, `function BPF_PROG`, `function BPF_PROG`.
- 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.