STRUCT SECCOMP_FILTER(9)
bestie, you just opened the struct seccomp_filter(9) page from the Kernel API Manual, and it is literally giving βcontainer for seccomp BPF programsβ energy π«Άβ¨
π NAME π
struct seccomp_filter - container for seccomp BPF programs
β¨ SYNOPSIS β¨
struct seccomp_filter {
refcount_t refs;
refcount_t users;
bool log;
bool wait_killable_recv;
struct action_cache cache;
struct seccomp_filter *prev;
struct bpf_prog *prog;
struct notification *notif;
struct mutex notify_lock;
wait_queue_head_t wqh;
};
π Members π
refsβ the reference count that manages the object lifetime. A filterβs reference count is incremented for each directly attached task, once for the dependent filter, and if requested for the user notifier. Whenrefsreaches zero, the filter can be freed. πusersβ a filterβs users count is incremented for each directly attached task (filter installation,fork,thread_sync), and once for the dependent filter (tracked infilter->prev). When it reaches zero it indicates that no direct or indirect users of that filter exist. No new tasks can get associated with this filter after reaching0. The users count is always smaller or equal torefs. Hence, reaching0for users does not mean the filter can be freed. π«Άlogβtrueif all actions except forSECCOMP_RET_ALLOWshould be logged.wait_killable_recvβ put notifying process in killable state once the notification is received by the userspace listener.cacheβ cache of arch/syscall mappings to actions.prevβ points to a previously installed, or inherited, filter.progβ the BPF program to evaluate.notifβ the struct that holds all notification related information.notify_lockβ a lock for all notification-related accesses.wqhβ a wait queue for poll if a notifier is in use.
π¦ Description π¦
okay so hereβs the whole vibe: seccomp_filter objects are organized in a tree linked via the prev pointer. For any task, it appears to be a singly-linked list starting with current->seccomp.filter, the most recently attached or inherited filter. However, multiple filters may share a prev node, by way of fork, which results in a unidirectional tree existing in memory. This is similar to how namespaces work. π
π¨ no cap, this part matters:seccomp_filterobjects should never be modified after being attached to atask_struct(other thanrefs).
π SEE ALSO π
Kernel file ./kernel/seccomp.c plus these besties:
struct seccomp_kaddfd(9)struct notification(9)struct action_cache(9)seccomp_check_filter(9)seccomp_cache_check_allow(9)seccomp_run_filters(9)seccomp_can_sync_threads(9)seccomp_filter_release(9)seccomp_sync_threads(9)seccomp_prepare_filter(9)seccomp_prepare_user_filter(9)seccomp_is_const_allow(9)seccomp_cache_prepare(9)seccomp_attach_filter(9)seccomp_set_mode_strict(9)seccomp_set_mode_filter(9)prctl_set_seccomp(9)
mwah π this iconic little page comes from source/version ./kernel, dated October 2026, and itβs the struct seccomp_filter(9) manual page. bye bestie, go be flawless with your filters πΈπ
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms