| 1 |
.TH "seccomp_syscall_priority" 3 "30 May 2020" "[email protected]" "libseccomp Documentation" |
| 2 |
.\" ////////////////////////////////////////////////////////////////////////// |
| 3 |
.SH NAME |
| 4 |
.\" ////////////////////////////////////////////////////////////////////////// |
| 5 |
seccomp_syscall_priority \- Prioritize syscalls in the seccomp filter |
| 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 SCMP_SYS(" syscall_name ");" |
| 15 |
.sp |
| 16 |
.BI "int seccomp_syscall_priority(scmp_filter_ctx " ctx "," |
| 17 |
.BI " int " syscall ", uint8_t " priority ");" |
| 18 |
.sp |
| 19 |
Link with \fI\-lseccomp\fP. |
| 20 |
.fi |
| 21 |
.\" ////////////////////////////////////////////////////////////////////////// |
| 22 |
.SH DESCRIPTION |
| 23 |
.\" ////////////////////////////////////////////////////////////////////////// |
| 24 |
.P |
| 25 |
The |
| 26 |
.BR seccomp_syscall_priority () |
| 27 |
function provides a priority hint to the seccomp filter generator in libseccomp |
| 28 |
such that higher priority syscalls are placed earlier in the seccomp filter code |
| 29 |
so that they incur less overhead at the expense of lower priority syscalls. A |
| 30 |
syscall's priority can be set regardless of if any rules currently exist for |
| 31 |
that syscall; the library will remember the priority and it will be assigned to |
| 32 |
the syscall if and when a rule for that syscall is created. |
| 33 |
.P |
| 34 |
While it is possible to specify the |
| 35 |
.I syscall |
| 36 |
value directly using the standard |
| 37 |
.B __NR_syscall |
| 38 |
values, in order to ensure proper operation across multiple architectures it |
| 39 |
is highly recommended to use the |
| 40 |
.BR SCMP_SYS () |
| 41 |
macro instead. See the EXAMPLES section below. |
| 42 |
.P |
| 43 |
The |
| 44 |
.I priority |
| 45 |
parameter takes an 8-bit value ranging from 0 \- 255; a higher value represents |
| 46 |
a higher priority. |
| 47 |
.P |
| 48 |
The filter context |
| 49 |
.I ctx |
| 50 |
is the value returned by the call to |
| 51 |
.BR seccomp_init (). |
| 52 |
.\" ////////////////////////////////////////////////////////////////////////// |
| 53 |
.SH RETURN VALUE |
| 54 |
.\" ////////////////////////////////////////////////////////////////////////// |
| 55 |
The |
| 56 |
.BR SCMP_SYS () |
| 57 |
macro returns a value suitable for use as the |
| 58 |
.I syscall |
| 59 |
value in |
| 60 |
.BR seccomp_syscall_priority (). |
| 61 |
.P |
| 62 |
The |
| 63 |
.BR seccomp_syscall_priority () |
| 64 |
function returns zero on success or one of the following error codes on |
| 65 |
failure: |
| 66 |
.TP |
| 67 |
.B -EDOM |
| 68 |
Architecture specific failure. |
| 69 |
.TP |
| 70 |
.B -EFAULT |
| 71 |
Internal libseccomp failure. |
| 72 |
.TP |
| 73 |
.B -EINVAL |
| 74 |
Invalid input, either the context or architecture token is invalid. |
| 75 |
.TP |
| 76 |
.B -ENOMEM |
| 77 |
The library was unable to allocate enough memory. |
| 78 |
.\" ////////////////////////////////////////////////////////////////////////// |
| 79 |
.SH EXAMPLES |
| 80 |
.\" ////////////////////////////////////////////////////////////////////////// |
| 81 |
.nf |
| 82 |
#include <seccomp.h> |
| 83 |
|
| 84 |
int main(int argc, char *argv[]) |
| 85 |
{ |
| 86 |
int rc = \-1; |
| 87 |
scmp_filter_ctx ctx; |
| 88 |
|
| 89 |
ctx = seccomp_init(SCMP_ACT_KILL); |
| 90 |
if (ctx == NULL) |
| 91 |
goto out; |
| 92 |
|
| 93 |
/* ... */ |
| 94 |
|
| 95 |
rc = seccomp_syscall_priority(ctx, SCMP_SYS(read), 200); |
| 96 |
if (rc < 0) |
| 97 |
goto out; |
| 98 |
|
| 99 |
/* ... */ |
| 100 |
|
| 101 |
out: |
| 102 |
seccomp_release(ctx); |
| 103 |
return \-rc; |
| 104 |
} |
| 105 |
.fi |
| 106 |
.\" ////////////////////////////////////////////////////////////////////////// |
| 107 |
.SH NOTES |
| 108 |
.\" ////////////////////////////////////////////////////////////////////////// |
| 109 |
.P |
| 110 |
While the seccomp filter can be generated independent of the kernel, kernel |
| 111 |
support is required to load and enforce the seccomp filter generated by |
| 112 |
libseccomp. |
| 113 |
.P |
| 114 |
The libseccomp project site, with more information and the source code |
| 115 |
repository, can be found at https://github.com/seccomp/libseccomp. This tool, |
| 116 |
as well as the libseccomp library, is currently under development, please |
| 117 |
report any bugs at the project site or directly to the author. |
| 118 |
.\" ////////////////////////////////////////////////////////////////////////// |
| 119 |
.SH AUTHOR |
| 120 |
.\" ////////////////////////////////////////////////////////////////////////// |
| 121 |
Paul Moore <[email protected]> |
| 122 |
.\" ////////////////////////////////////////////////////////////////////////// |
| 123 |
.SH SEE ALSO |
| 124 |
.\" ////////////////////////////////////////////////////////////////////////// |
| 125 |
.BR seccomp_rule_add (3), |
| 126 |
.BR seccomp_rule_add_exact (3) |