1seccomp_load(3)            libseccomp Documentation            seccomp_load(3)
2
3
4

NAME

6       seccomp_load - Load the current seccomp filter into the kernel
7

SYNOPSIS

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

DESCRIPTION

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
24       remember  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
26       applied.   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

RETURN VALUE

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
41              invalid.
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
50       error codes are the negative  errno  values  returned  by  the  system.
51       Unfortunately libseccomp can make no guarantees about these return val‐
52       ues.
53

EXAMPLES

55       #include <seccomp.h>
56
57       int main(int argc, char *argv[])
58       {
59            int rc = -1;
60            scmp_filter_ctx ctx;
61
62            ctx = seccomp_init(SCMP_ACT_KILL);
63            if (ctx == NULL)
64                 goto out;
65
66            /* ... */
67
68            rc = seccomp_load(ctx);
69            if (rc < 0)
70                 goto out;
71
72            /* ... */
73
74       out:
75            seccomp_release(ctx);
76            return -rc;
77       }
78

NOTES

80       While the seccomp filter can be generated independent  of  the  kernel,
81       kernel  support is required to load and enforce the seccomp filter gen‐
82       erated by libseccomp.
83
84       The libseccomp project site, with more information and the source  code
85       repository,  can  be  found  at  https://github.com/seccomp/libseccomp.
86       This tool, as well as the libseccomp library, is currently under devel‐
87       opment,  please  report any bugs at the project site or directly to the
88       author.
89

AUTHOR

91       Paul Moore <paul@paul-moore.com>
92

SEE ALSO

94       seccomp_init(3),     seccomp_reset(3),     seccomp_release(3),     sec‐
95       comp_rule_add(3), seccomp_rule_add_exact(3)
96
97
98
99
100
101paul@paul-moore.com               30 May 2020                  seccomp_load(3)
Impressum