seccomp_precompute(3)
β¨ seccomp_precompute β¨
okay so bestie, welcome to seccomp_precompute(3), one of the lil gems from the libseccomp Documentation collection π. it's a function. it precomputes stuff. it slays. let's get into it π«Ά
πΈ NAME πΈ
seccomp_precompute β precompute the current seccomp filter π
π SYNOPSIS π
#include <seccomp.h>
typedef void * scmp_filter_ctx;
int seccomp_precompute(scmp_filter_ctx ctx);
and like, don't forget to link with -lseccomp or nothing's gonna happen, no cap π₯
π¦ DESCRIPTION π¦
so what this does is it precomputes the seccomp filter for later use by seccomp_load() and its similar little friends. and the way that this is a whole double win?? because not only does it improve the performance of seccomp_load(), it also ensures that the seccomp filter can be loaded in an async-signal-safe manner β if no changes have been made to the filter since it was precomputed. periodt. π§
π RETURN VALUE π
returns zero on success π or, if it's not giving success, one of these error codes:
-ECANCELEDβ there was a system failure beyond the control of the library π (not our fault bestie)-EFAULTβ internal libseccomp failure π-EINVALβ invalid input, either the context or architecture token is invalid π-ENOMEMβ the library was unable to allocate enough memory π΅
and okay here's the tea π: if the SCMP_FLTATR_API_SYSRAWRC filter attribute is non-zero, then additional error codes may be returned to the caller. those additional error codes are the negative errno values returned by the system. unfortunately libseccomp can make no guarantees about these return values. so like, good luck with those ig π
β¨ 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_precompute(ctx);
if (rc < 0)
goto out;
/* ... */
rc = seccomp_load(ctx);
if (rc < 0)
goto out;
/* ... */
out:
seccomp_release(ctx);
return -rc;
}
look at that flow. precompute, then load. main character energy fr fr π
π NOTES π
while the seccomp filter can be generated independent of the kernel, kernel support is required to load and enforce the seccomp filter generated by libseccomp. so like, no kernel, no enforcement. that's just how it is π«
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 β please report any bugs at the project site or directly to the author ππ
not me reminding you that "under development" means things can still shift, so keep an eye on the project site bestie
π AUTHOR π
Paul Moore <paul@paul-moore.com> β iconic, we stan π
β¨
β SEE ALSO β
and that's the whole page bestie!! π¦πΈ this lil masterpiece was written by <paul@paul-moore.com> and dated 19 September 2022, and yeah it lives in the seccomp_precompute(3) section of the libseccomp docs. go precompute something, you got this ππβ¨
π¦ 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
- 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 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