| 1 |
.TH "seccomp_load" 3 "30 May 2020" "[email protected]" "libseccomp Documentation" |
| 2 |
.\" ////////////////////////////////////////////////////////////////////////// |
| 3 |
.SH NAME |
| 4 |
.\" ////////////////////////////////////////////////////////////////////////// |
| 5 |
seccomp_load \- Load the current seccomp filter into the kernel |
| 6 |
.\" ////////////////////////////////////////////////////////////////////////// |
| 7 |
.SH SYNOPSIS |
| 8 |
.\" ////////////////////////////////////////////////////////////////////////// |
| 9 |
.nf |
| 10 |
.B #include <seccomp.h> |
| 11 |
.sp |
| 12 |
.B typedef void * scmp_filter_ctx; |
| 13 |
.sp |
| 14 |
.BI "int seccomp_load(scmp_filter_ctx " ctx ");" |
| 15 |
.sp |
| 16 |
Link with \fI\-lseccomp\fP. |
| 17 |
.fi |
| 18 |
.\" ////////////////////////////////////////////////////////////////////////// |
| 19 |
.SH DESCRIPTION |
| 20 |
.\" ////////////////////////////////////////////////////////////////////////// |
| 21 |
.P |
| 22 |
Loads the seccomp filter provided by |
| 23 |
.I ctx |
| 24 |
into the kernel; if the function |
| 25 |
succeeds the new seccomp filter will be active when the function returns. If |
| 26 |
.BR seccomp_precompute (3) |
| 27 |
was called prior to attempting to load the seccomp filter, and no changes have |
| 28 |
been made to the filter, |
| 29 |
.BR seccomp_load () |
| 30 |
can be considered to be async-signal-safe. |
| 31 |
.P |
| 32 |
As it is possible to have multiple stacked seccomp filters for a given task |
| 33 |
(defined as either a process or a thread), it is important to remember that |
| 34 |
each of the filters loaded for a given task are executed when a syscall is |
| 35 |
made and the "strictest" rule is the rule that is applied. In the case of |
| 36 |
seccomp, "strictest" is defined as the action with the lowest value (e.g. |
| 37 |
.I SCMP_ACT_KILL |
| 38 |
is "stricter" than |
| 39 |
.IR SCMP_ACT_ALLOW ). |
| 40 |
.\" ////////////////////////////////////////////////////////////////////////// |
| 41 |
.SH RETURN VALUE |
| 42 |
.\" ////////////////////////////////////////////////////////////////////////// |
| 43 |
Returns zero on success or one of the following error codes on failure: |
| 44 |
.TP |
| 45 |
.B -ECANCELED |
| 46 |
There was a system failure beyond the control of the library. |
| 47 |
.TP |
| 48 |
.B -EFAULT |
| 49 |
Internal libseccomp failure. |
| 50 |
.TP |
| 51 |
.B -EINVAL |
| 52 |
Invalid input, either the context or architecture token is invalid. |
| 53 |
.TP |
| 54 |
.B -ENOMEM |
| 55 |
The library was unable to allocate enough memory. |
| 56 |
.TP |
| 57 |
.B -ESRCH |
| 58 |
Unable to load the filter due to thread issues. |
| 59 |
.P |
| 60 |
If the \fISCMP_FLTATR_API_SYSRAWRC\fP filter attribute is non-zero then |
| 61 |
additional error codes may be returned to the caller; these additional error |
| 62 |
codes are the negative \fIerrno\fP values returned by the system. Unfortunately |
| 63 |
libseccomp can make no guarantees about these return values. |
| 64 |
.\" ////////////////////////////////////////////////////////////////////////// |
| 65 |
.SH EXAMPLES |
| 66 |
.\" ////////////////////////////////////////////////////////////////////////// |
| 67 |
.nf |
| 68 |
#include <seccomp.h> |
| 69 |
|
| 70 |
int main(int argc, char *argv[]) |
| 71 |
{ |
| 72 |
int rc = \-1; |
| 73 |
scmp_filter_ctx ctx; |
| 74 |
|
| 75 |
ctx = seccomp_init(SCMP_ACT_KILL); |
| 76 |
if (ctx == NULL) |
| 77 |
goto out; |
| 78 |
|
| 79 |
/* ... */ |
| 80 |
|
| 81 |
rc = seccomp_load(ctx); |
| 82 |
if (rc < 0) |
| 83 |
goto out; |
| 84 |
|
| 85 |
/* ... */ |
| 86 |
|
| 87 |
out: |
| 88 |
seccomp_release(ctx); |
| 89 |
return \-rc; |
| 90 |
} |
| 91 |
.fi |
| 92 |
.\" ////////////////////////////////////////////////////////////////////////// |
| 93 |
.SH NOTES |
| 94 |
.\" ////////////////////////////////////////////////////////////////////////// |
| 95 |
.P |
| 96 |
While the seccomp filter can be generated independent of the kernel, kernel |
| 97 |
support is required to load and enforce the seccomp filter generated by |
| 98 |
libseccomp. |
| 99 |
.P |
| 100 |
The libseccomp project site, with more information and the source code |
| 101 |
repository, can be found at https://github.com/seccomp/libseccomp. This tool, |
| 102 |
as well as the libseccomp library, is currently under development, please |
| 103 |
report any bugs at the project site or directly to the author. |
| 104 |
.\" ////////////////////////////////////////////////////////////////////////// |
| 105 |
.SH AUTHOR |
| 106 |
.\" ////////////////////////////////////////////////////////////////////////// |
| 107 |
Paul Moore <[email protected]> |
| 108 |
.\" ////////////////////////////////////////////////////////////////////////// |
| 109 |
.SH SEE ALSO |
| 110 |
.\" ////////////////////////////////////////////////////////////////////////// |
| 111 |
.BR seccomp_init (3), |
| 112 |
.BR seccomp_reset (3), |
| 113 |
.BR seccomp_release (3), |
| 114 |
.BR seccomp_rule_add (3), |
| 115 |
.BR seccomp_rule_add_exact (3) |
| 116 |
.BR seccomp_precompute (3) |
| 117 |
.BR signal-safety (7) |