SECCOMP_SYSCALL_PRIORITY(3)
π seccomp_syscall_priority β a libseccomp(3) moment
okay bestie so this page is from the libseccomp Documentation and it's called seccomp_syscall_priority(3), and honestly? it's giving "make your syscalls line up in the right order." let's get into it π
β¨ NAME β¨
seccomp_syscall_priority β Prioritize syscalls in the seccomp filter
πΈ SYNOPSIS πΈ
#include <seccomp.h>
typedef void * scmp_filter_ctx;
int SCMP_SYS(syscall_name);
int seccomp_syscall_priority(scmp_filter_ctx ctx,
int syscall, uint8_t priority);
Link with -lseccomp.
π DESCRIPTION π
so the seccomp_syscall_priority() function hands a lil priority hint to the seccomp filter generator inside libseccomp. the way it works is: higher priority syscalls get placed earlier in the seccomp filter code, so they incur less overhead β and the price of that is that lower priority syscalls get pushed back. tradeoff, bestie, it's always a tradeoff π
and here's the cute part: you can set a syscall's priority regardless of whether any rules currently exist for that syscall. the library literally just remembers the priority, and it'll be assigned to that syscall if and when a rule for that syscall gets created. main character foresight, honestly β¨
now, you could specify the syscall value directly using the standard __NR_syscall values, but for proper operation across multiple architectures it is highly recommended to use the SCMP_SYS() macro instead. no cap. check the EXAMPLES section below π
the priority parameter takes an 8-bit value ranging from 0 - 255; a higher value = a higher priority. that's it, that's the range π«Ά
and the filter context ctx? that's the value returned by the call to seccomp_init().
π₯ RETURN VALUE π₯
the SCMP_SYS() macro returns a value suitable for use as the syscall value in seccomp_syscall_priority().
the seccomp_syscall_priority() function returns zero on success or one of the following error codes on failure:
-EDOMβ Architecture specific failure.-EFAULTβ Internal libseccomp failure.-EINVALβ Invalid input, either the context or architecture token is invalid.-ENOMEMβ The library was unable to allocate enough memory.
π EXAMPLES π
#include <seccomp.h>
int main(int argc, char *argv[])
{
int rc = -1;
scmp_filter_ctx ctx;
ctx = seccomp_init(SCMP_ACT_KILL);
if (ctx == NULL)
goto out;
/* ... */
rc = seccomp_syscall_priority(ctx, SCMP_SYS(read), 200);
if (rc < 0)
goto out;
/* ... */
out:
seccomp_release(ctx);
return -rc;
}
π¦ NOTES π¦
okay so even though the seccomp filter can be generated independently of the kernel, kernel support is required to load and enforce the seccomp filter that libseccomp generates. like, the filter exists, sure, but it needs the kernel to actually do anything. vibe check: passed conditionally π
the libseccomp project site, with more information and the source code repository, can be found at https://github.com/seccomp/libseccomp. this tool, as well as the libseccomp library, is currently under development, so please report any bugs at the project site or directly to the author. be a good citizen bestie π
π AUTHOR π
Paul Moore <paul@paul-moore.com>
β SEE ALSO β
and that's the whole page, periodt. this lil doc was written by paul@paul-moore.com, dated 30 May 2020, and it lives under seccomp_syscall_priority(3) in the libseccomp docs. go forth and prioritize your syscalls, you absolute icon ππ
π¦ where this page comes from
- alpine 3.22: libseccomp-doc 2.6.1-r0 Β· LGPL-2.1-or-later
- alpine 3.23: libseccomp-doc 2.6.1-r0 Β· LGPL-2.1-or-later
- alpine 3.24: libseccomp-doc 2.6.1-r0 Β· LGPL-2.1-or-later
- arch rolling: libseccomp 2.6.0-1 Β· LGPL-2.1-only
- centos-stream 10: libseccomp-devel 2.5.6-1.el10 Β· LGPL-2.1-only
- centos-stream 9: libseccomp-devel 2.5.6-1.el9 Β· LGPLv2
- centos-stream 9: libseccomp-devel 2.5.6-1.el9 Β· LGPLv2
- debian bookworm: libseccomp-dev 2.5.4-1+deb12u1 Β· LGPL-2.1-only
- debian trixie: libseccomp-dev 2.6.0-2 Β· LGPL-2.1-only
- fedora 43: libseccomp-devel 2.6.0-2.fc43 Β· LGPL-2.1-only
- fedora 43: libseccomp-devel 2.6.0-2.fc43 Β· LGPL-2.1-only
- fedora 43: libseccomp-devel 2.6.1-2.fc43 Β· LGPL-2.1-only
- fedora 43: libseccomp-devel 2.6.1-2.fc43 Β· LGPL-2.1-only
- fedora 44: libseccomp-devel 2.6.0-3.fc44 Β· LGPL-2.1-only
- fedora 44: libseccomp-devel 2.6.0-3.fc44 Β· LGPL-2.1-only
- fedora 44: libseccomp-devel 2.6.1-2.fc44 Β· LGPL-2.1-only
- fedora 44: libseccomp-devel 2.6.1-2.fc44 Β· LGPL-2.1-only
- nixpkgs unstable: libseccomp 2.6.1
- opensuse-leap 16.0: libseccomp-devel 2.6.0-160000.2.2 Β· LGPL-2.1-only
- opensuse-leap 16.0: libseccomp-devel 2.6.0-160000.2.2 Β· LGPL-2.1-only
- opensuse-leap 16.0: libseccomp-devel 2.6.0-160000.2.2 Β· LGPL-2.1-only
- opensuse-leap 16.0: libseccomp-devel 2.6.0-160000.2.2 Β· LGPL-2.1-only
- ubuntu jammy: libseccomp-dev 2.5.3-2ubuntu2 Β· LGPL-2.1-only
- ubuntu jammy: libseccomp-dev 2.5.3-2ubuntu3~22.04.1 Β· LGPL-2.1-only
- ubuntu noble: libseccomp-dev 2.5.5-1ubuntu3 Β· LGPL-2.1-only
- ubuntu noble: libseccomp-dev 2.5.5-1ubuntu3.1 Β· LGPL-2.1-only
- ubuntu questing: libseccomp-dev 2.6.0-2ubuntu2
- ubuntu resolute: libseccomp-dev 2.6.0-2ubuntu5 Β· LGPL-2.1-only
- ubuntu stonking: libseccomp-dev 2.6.1-1ubuntu1 Β· LGPL-2.1-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms