1seccomp_load(3) libseccomp Documentation seccomp_load(3)
2
3
4
6 seccomp_load - Load the current seccomp filter into the kernel
7
9 #include <seccomp.h>
10
11 typedef void * scmp_filter_ctx;
12
13 int seccomp_load(scmp_filter_ctx ctx);
14
15 Link with -lseccomp.
16
18 Loads the seccomp filter provided by ctx into the kernel; if the func‐
19 tion succeeds the new seccomp filter will be active when the function
20 returns.
21
22 As it is possible to have multiple stacked seccomp filters for a given
23 task (defined as either a process or a thread), it is important to re‐
24 member that each of the filters loaded for a given task are executed
25 when a syscall is made and the "strictest" rule is the rule that is ap‐
26 plied. In the case of seccomp, "strictest" is defined as the action
27 with the lowest value (e.g. SCMP_ACT_KILL is "stricter" than
28 SCMP_ACT_ALLOW).
29
31 Returns zero on success or one of the following error codes on failure:
32
33 -ECANCELED
34 There was a system failure beyond the control of the library.
35
36 -EFAULT
37 Internal libseccomp failure.
38
39 -EINVAL
40 Invalid input, either the context or architecture token is in‐
41 valid.
42
43 -ENOMEM
44 The library was unable to allocate enough memory.
45
46 -ESRCH Unable to load the filter due to thread issues.
47
48 If the SCMP_FLTATR_API_SYSRAWRC filter attribute is non-zero then addi‐
49 tional error codes may be returned to the caller; these additional er‐
50 ror codes are the negative errno values returned by the system. Unfor‐
51 tunately libseccomp can make no guarantees about these return values.
52
54 #include <seccomp.h>
55
56 int main(int argc, char *argv[])
57 {
58 int rc = -1;
59 scmp_filter_ctx ctx;
60
61 ctx = seccomp_init(SCMP_ACT_KILL);
62 if (ctx == NULL)
63 goto out;
64
65 /* ... */
66
67 rc = seccomp_load(ctx);
68 if (rc < 0)
69 goto out;
70
71 /* ... */
72
73 out:
74 seccomp_release(ctx);
75 return -rc;
76 }
77
79 While the seccomp filter can be generated independent of the kernel,
80 kernel support is required to load and enforce the seccomp filter gen‐
81 erated by libseccomp.
82
83 The libseccomp project site, with more information and the source code
84 repository, can be found at https://github.com/seccomp/libseccomp.
85 This tool, as well as the libseccomp library, is currently under devel‐
86 opment, please report any bugs at the project site or directly to the
87 author.
88
90 Paul Moore <paul@paul-moore.com>
91
93 seccomp_init(3), seccomp_reset(3), seccomp_release(3), sec‐
94 comp_rule_add(3), seccomp_rule_add_exact(3)
95
96
97
98
99
100paul@paul-moore.com 30 May 2020 seccomp_load(3)