seccomp_version(3)

✨ seccomp_version(3) β€” the libseccomp girlies' version check ✨

okay so bestie, this is a page from the libseccomp Documentation and it's literally the cutest lil function ever. it's giving "am I linked to the right library or not" energy and honestly? iconic. let's get into it πŸ’…


🌸 NAME 🌸

seccomp_version β€” query the libseccomp version information πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <seccomp.h>

struct scmp_version {
     unsigned int major;
     unsigned int minor;
     unsigned int micro;
}

const struct scmp_version *seccomp_version(void);

Link with -lseccomp.


πŸ’– DESCRIPTION πŸ’–

so the seccomp_version() and seccomp_reset() functions return a pointer to a scmp_version struct, and that struct is holding the version info of the currently loaded libseccomp library. like, the one that's actually loaded right now, not some hypothetical one. periodt. πŸ”₯

this is the function you call when your app needs to verify that it's linked to a specific libseccomp version at runtime. runtime checks, bestie. we love a runtime check. ✨

🫢 important: the caller should not attempt to free the returned scmp_version struct when finished. hands off, it's not yours to free.

🌈 RETURN VALUE 🌈

the seccomp_version() function returns a pointer to a scmp_version structure on success, and NULL on failure. πŸ’€

and again, because it bears repeating: the caller should not attempt to free the returned structure. no. don't. put it down. 🚫


πŸ“ EXAMPLES πŸ“

okay here's the vibe, copy-paste ready:

#include <seccomp.h>

int main(int argc, char *argv[])
{
     const struct scmp_version *ver;

     ver = seccomp_version();
     if (ver == NULL)
          goto err;

     /* ... */

     return 0;

err:
     return 1;
}

🧚 NOTES 🧚

so while the seccomp filter can be generated independent of the kernel (yes, you can build the whole thing with no kernel input at all), kernel support is required to actually load and enforce the seccomp filter that libseccomp generated. so like, the filter exists, but the kernel has to be the one to run it. no kernel, no enforcement. that's just how it is. πŸ’œ

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 (yes, still, bestie, it's a whole thing), so please report any bugs at the project site or directly to the author. πŸ›


πŸ‘‘ AUTHOR πŸ‘‘

Paul Moore <paul@paul-moore.com>


and that's the whole page, bestie!! every flag, every struct field, every "don't free it" warning β€” all present and accounted for. slay. πŸ’…βœ¨

this little treasure was brought to you by paul@paul-moore.com and dated 18 February 2016, and it's page seccomp_version(3) in case you need to cite it in your group chat. mwah 🫢

πŸ“¦ where this page comes from