1 .TH "seccomp_init" 3 "25 July 2012" "paul@paul-moore.com" "libseccomp Documentation"
2 .\" //////////////////////////////////////////////////////////////////////////
4 .\" //////////////////////////////////////////////////////////////////////////
5 seccomp_init, seccomp_reset \- Initialize the seccomp filter state
6 .\" //////////////////////////////////////////////////////////////////////////
8 .\" //////////////////////////////////////////////////////////////////////////
10 .B #include <seccomp.h>
12 .B typedef void * scmp_filter_ctx;
14 .BI "scmp_filter_ctx seccomp_init(uint32_t " def_action ");"
15 .BI "int seccomp_reset(scmp_filter_ctx " ctx ", uint32_t " def_action ");"
17 Link with \fI\-lseccomp\fP.
19 .\" //////////////////////////////////////////////////////////////////////////
21 .\" //////////////////////////////////////////////////////////////////////////
27 functions (re)initialize the internal seccomp filter state, prepares it for
28 use, and sets the default action based on the
32 function must be called before any other libseccomp functions as the rest
33 of the library API will fail if the filter context is not initialized properly.
36 function releases the existing filter context state before reinitializing it
37 and can only be called after a call to
41 When the caller is finished configuring the seccomp filter and has loaded it
42 into the kernel, the caller should call
43 .BR seccomp_release (3)
44 to release all of the filter context state.
48 values are as follows:
51 The thread will be terminated by the kernel with SIGSYS when it calls a syscall
52 that does not match any of the configured seccomp filter rules. The thread
53 will not be able to catch the signal.
56 The thread will be sent a SIGSYS signal when it calls a syscall that does not
57 match any of the configured seccomp filter rules. It may catch this and change
58 its behavior accordingly. When using SA_SIGINFO with
60 si_code will be set to SYS_SECCOMP, si_syscall will be set to the syscall that
61 failed the rules, and si_arch will be set to the AUDIT_ARCH for the active ABI.
63 .B SCMP_ACT_ERRNO(uint16_t errno)
64 The thread will receive a return value of
66 when it calls a syscall that does not match any of the configured seccomp filter
69 .B SCMP_ACT_TRACE(uint16_t msg_num)
70 If the thread is being traced and the tracing process specified the
71 .B PTRACE_O_TRACESECCOMP
74 the tracing process will be notified, via
75 .BR PTRACE_EVENT_SECCOMP ,
76 and the value provided in
78 can be retrieved using the
83 The seccomp filter will have no effect on the thread calling the syscall if it
84 does not match any of the configured seccomp filter rules.
85 .\" //////////////////////////////////////////////////////////////////////////
87 .\" //////////////////////////////////////////////////////////////////////////
90 function returns a filter context on success, NULL on failure. The
92 function returns zero on success, negative errno values on failure.
93 .\" //////////////////////////////////////////////////////////////////////////
95 .\" //////////////////////////////////////////////////////////////////////////
99 int main(int argc, char *argv[])
104 ctx = seccomp_init(SCMP_ACT_KILL);
110 rc = seccomp_reset(ctx, SCMP_ACT_KILL);
117 seccomp_release(ctx);
121 .\" //////////////////////////////////////////////////////////////////////////
123 .\" //////////////////////////////////////////////////////////////////////////
125 While the seccomp filter can be generated independent of the kernel, kernel
126 support is required to load and enforce the seccomp filter generated by
129 The libseccomp project site, with more information and the source code
130 repository, can be found at https://github.com/seccomp/libseccomp. This tool,
131 as well as the libseccomp library, is currently under development, please
132 report any bugs at the project site or directly to the author.
133 .\" //////////////////////////////////////////////////////////////////////////
135 .\" //////////////////////////////////////////////////////////////////////////
136 Paul Moore <paul@paul-moore.com>
137 .\" //////////////////////////////////////////////////////////////////////////
139 .\" //////////////////////////////////////////////////////////////////////////
140 .BR seccomp_release (3)