seccomp_api_get(3)
π seccomp_api_get β bestie edition π
okay so real talk, this is seccomp_api_get and seccomp_api_set from the libseccomp docs, and they're literally just here to manage the libseccomp API level. that's the whole vibe. let's get into it π«Ά
β¨ NAME β¨
seccomp_api_get, seccomp_api_set β manage the libseccomp API level π
πΈ SYNOPSIS πΈ
#include <seccomp.h>
const unsigned int seccomp_api_get(void);
int seccomp_api_set(unsigned int level);
and bestie, don't forget to link with -lseccomp or it's giving β¨ nothing β¨
π¦ DESCRIPTION π¦
so seccomp_api_get() returns an integer that represents the functionality β aka the "API level" β that your current running kernel is serving up. π
and here's the thing you HAVE to know: even though you can call seccomp_api_get() as many times as your little heart desires, the kernel only gets probed the first time to see what functionality is supported. every call after that? it just returns a cached value. so it's giving fast, but it's also giving "we already checked, chill" π
now seccomp_api_set() lets callers force the API level to whatever value they hand over. but β and I cannot stress this enough β this is almost always a bad idea and use of this function is strongly discouraged. like, bestie, why would you do that. don't. π«
the different API level values are described below, and yes we're doing all of them:
0β Reserved value, not currently used. it's just sitting there, unbothered, unused π1β Base level support.2β theSCMP_FLTATR_CTL_TSYNCfilter attribute is supported, and libseccomp uses theseccomp(2)syscall to load the seccomp filter into the kernel. slay.3β theSCMP_FLTATR_CTL_LOGfilter attribute and theSCMP_ACT_LOGaction are supported.4β theSCMP_FLTATR_CTL_SSBfilter attribute is supported.5β theSCMP_ACT_NOTIFYaction and the notify APIs are supported.6β the simultaneous use ofSCMP_FLTATR_CTL_TSYNCand the notify APIs are supported. teamwork makes the dream work fr fr π€7β theSCMP_FLTATR_CTL_WAITKILLfilter attribute is supported.
π RETURN VALUE π
seccomp_api_get() returns an integer representing the supported API level. seccomp_api_set() returns zero on success, and negative values on failure. simple as that, no cap. β¨
π§ EXAMPLES π§
here's the whole thing, character for character, because we do NOT paraphrase code in this house:
#include <seccomp.h>
int main(int argc, char *argv[])
{
unsigned int api;
api = seccomp_api_get();
switch (api) {
case 2:
/* ... */
default:
/* ... */
}
return 0;
err:
return 1;
}
β NOTES β
so while the seccomp filter can be generated independently of the kernel, kernel support is required to load and enforce the seccomp filter that libseccomp generates. you can build it anywhere, but you can't run it everywhere β vibe check passed only on supported kernels π
the libseccomp project site, with more info and the source code repository, lives 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>
and that's the whole page, periodt π this was written by paul@paul-moore.com, dated 22 September 2022, and it lives in section 3 of the manual as seccomp_api_get(3) β courtesy of the libseccomp Documentation crew. mwah, go forth and check your API level ππβ¨
π¦ 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