tools/testing/selftests/seccomp/seccomp_bpf.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/seccomp/seccomp_bpf.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/seccomp/seccomp_bpf.c- Extension
.c- Size
- 136262 bytes
- Lines
- 5307
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
sys/types.hasm/siginfo.herrno.hlinux/filter.hsys/prctl.hsys/ptrace.hsys/time.hsys/user.hlinux/prctl.hlinux/ptrace.hlinux/seccomp.hpthread.hsemaphore.hsignal.hstddef.hstdbool.hstring.htime.hlimits.hlinux/elf.hsys/uio.hsys/utsname.hsys/fcntl.hsys/mman.hsys/times.hsys/socket.hsys/ioctl.hlinux/kcmp.hsys/resource.hsys/capability.hlinux/perf_event.hunistd.h
Detected Declarations
struct seccomp_datastruct seccomp_metadatastruct seccomp_notifstruct seccomp_notif_respstruct seccomp_notif_sizesstruct seccomp_notif_addfdstruct seccomp_notif_addfd_smallstruct seccomp_notif_addfd_bigstruct local_sigsysstruct tracer_args_poke_tstruct tsync_siblingstruct tsync_vs_thread_leader_argsenum kill_tfunction seccompfunction __filecmpfunction TESTfunction TESTfunction kill_thread_or_groupfunction ASSERT_EQfunction TRAP_actionfunction tracer_stopfunction start_tracerfunction ASSERT_EQfunction cont_handlerfunction teardown_trace_fixturefunction tracer_pokefunction get_syscallfunction EXPECT_EQfunction __change_syscallfunction EXPECT_EQfunction change_syscall_nrfunction change_syscall_retfunction tracer_seccompfunction EXPECT_EQfunction EXPECT_EQfunction tracer_ptracefunction EXPECT_EQfunction ASSERT_NEfunction EXPECT_EQfunction EXPECT_EQfunction tsync_start_siblingfunction ASSERT_EQfunction ASSERT_EQfunction ASSERT_EQfunction ASSERT_EQfunction ASSERT_EQfunction ASSERT_EQfunction EXPECT_EQ
Annotated Snippet
struct seccomp_data {
int nr;
__u32 arch;
__u64 instruction_pointer;
__u64 args[6];
};
#endif
#ifndef SECCOMP_RET_KILL_PROCESS
#define SECCOMP_RET_KILL_PROCESS 0x80000000U /* kill the process */
#define SECCOMP_RET_KILL_THREAD 0x00000000U /* kill the thread */
#endif
#ifndef SECCOMP_RET_KILL
#define SECCOMP_RET_KILL SECCOMP_RET_KILL_THREAD
#define SECCOMP_RET_TRAP 0x00030000U /* disallow and force a SIGSYS */
#define SECCOMP_RET_ERRNO 0x00050000U /* returns an errno */
#define SECCOMP_RET_TRACE 0x7ff00000U /* pass to a tracer or disallow */
#define SECCOMP_RET_ALLOW 0x7fff0000U /* allow */
#endif
#ifndef SECCOMP_RET_LOG
#define SECCOMP_RET_LOG 0x7ffc0000U /* allow after logging */
#endif
#ifndef __NR_seccomp
# if defined(__i386__)
# define __NR_seccomp 354
# elif defined(__x86_64__)
# define __NR_seccomp 317
# elif defined(__arm__)
# define __NR_seccomp 383
# elif defined(__aarch64__)
# define __NR_seccomp 277
# elif defined(__riscv)
# define __NR_seccomp 277
# elif defined(__csky__)
# define __NR_seccomp 277
# elif defined(__loongarch__)
# define __NR_seccomp 277
# elif defined(__hppa__)
# define __NR_seccomp 338
# elif defined(__powerpc__)
# define __NR_seccomp 358
# elif defined(__s390__)
# define __NR_seccomp 348
# elif defined(__xtensa__)
# define __NR_seccomp 337
# elif defined(__sh__)
# define __NR_seccomp 372
# elif defined(__mc68000__)
# define __NR_seccomp 380
# else
# warning "seccomp syscall number unknown for this architecture"
# define __NR_seccomp 0xffff
# endif
#endif
#ifndef __NR_uretprobe
# if defined(__x86_64__)
# define __NR_uretprobe 335
# endif
#endif
#ifndef __NR_uprobe
# if defined(__x86_64__)
# define __NR_uprobe 336
# endif
#endif
#ifndef SECCOMP_SET_MODE_STRICT
#define SECCOMP_SET_MODE_STRICT 0
#endif
#ifndef SECCOMP_SET_MODE_FILTER
#define SECCOMP_SET_MODE_FILTER 1
#endif
#ifndef SECCOMP_GET_ACTION_AVAIL
#define SECCOMP_GET_ACTION_AVAIL 2
#endif
#ifndef SECCOMP_GET_NOTIF_SIZES
#define SECCOMP_GET_NOTIF_SIZES 3
#endif
#ifndef SECCOMP_FILTER_FLAG_TSYNC
#define SECCOMP_FILTER_FLAG_TSYNC (1UL << 0)
#endif
#ifndef SECCOMP_FILTER_FLAG_LOG
#define SECCOMP_FILTER_FLAG_LOG (1UL << 1)
Annotation
- Immediate include surface: `sys/types.h`, `asm/siginfo.h`, `errno.h`, `linux/filter.h`, `sys/prctl.h`, `sys/ptrace.h`, `sys/time.h`, `sys/user.h`.
- Detected declarations: `struct seccomp_data`, `struct seccomp_metadata`, `struct seccomp_notif`, `struct seccomp_notif_resp`, `struct seccomp_notif_sizes`, `struct seccomp_notif_addfd`, `struct seccomp_notif_addfd_small`, `struct seccomp_notif_addfd_big`, `struct local_sigsys`, `struct tracer_args_poke_t`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.