tools/testing/selftests/bpf/progs/test_probe_user.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/progs/test_probe_user.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/progs/test_probe_user.c- Extension
.c- Size
- 1217 bytes
- Lines
- 57
- 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.hbpf/bpf_helpers.hbpf/bpf_tracing.hbpf/bpf_core_read.hbpf_misc.h
Detected Declarations
struct test_pro_bssfunction handle_sys_connect_commonfunction BPF_KSYSCALLfunction BPF_KSYSCALL
Annotated Snippet
struct test_pro_bss {
struct sockaddr_in old;
__u32 test_pid;
};
struct test_pro_bss bss;
static int handle_sys_connect_common(struct sockaddr_in *uservaddr)
{
struct sockaddr_in new;
__u32 cur = bpf_get_current_pid_tgid() >> 32;
if (bss.test_pid && cur != bss.test_pid)
return 0;
bpf_probe_read_user(&bss.old, sizeof(bss.old), uservaddr);
__builtin_memset(&new, 0xab, sizeof(new));
bpf_probe_write_user(uservaddr, &new, sizeof(new));
return 0;
}
SEC("ksyscall/connect")
int BPF_KSYSCALL(handle_sys_connect, int fd, struct sockaddr_in *uservaddr,
int addrlen)
{
return handle_sys_connect_common(uservaddr);
}
#if defined(bpf_target_s390)
#ifndef SYS_CONNECT
#define SYS_CONNECT 3
#endif
SEC("ksyscall/socketcall")
int BPF_KSYSCALL(handle_sys_socketcall, int call, unsigned long *args)
{
if (call == SYS_CONNECT) {
struct sockaddr_in *uservaddr;
bpf_probe_read_user(&uservaddr, sizeof(uservaddr), &args[1]);
return handle_sys_connect_common(uservaddr);
}
return 0;
}
#endif
char _license[] SEC("license") = "GPL";
Annotation
- Immediate include surface: `vmlinux.h`, `bpf/bpf_helpers.h`, `bpf/bpf_tracing.h`, `bpf/bpf_core_read.h`, `bpf_misc.h`.
- Detected declarations: `struct test_pro_bss`, `function handle_sys_connect_common`, `function BPF_KSYSCALL`, `function BPF_KSYSCALL`.
- 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.