oci-seccomp-bpf-hook(1)(--)
π oci-seccomp-bpf-hook(1) β the hook manual, bestie edition π
okay so real talk, this is the manual page for oci-seccomp-bpf-hook, and it's genuinely one of those little tools that does something kind of iconic and you're gonna love it. it's a hook. it watches syscalls. it writes a seccomp profile. let's get into it π«Ά
β¨ SYNOPSIS β¨
oci-seccomp-bpf-hook prestart [container.json]
that's it. that's the whole vibe. you run it as prestart, you optionally hand it a container.json, slay β¨
πΈ DESCRIPTION πΈ
so the oci hook oci-seccomp-bpf-hook generates seccomp profiles by literally tracing the syscalls your container makes. like it's following it around with a little notebook π. the profile it spits out whitelists every syscall that was actually made and blacklists all the other ones. no cap, that's the whole deal.
how does the tracing actually happen? okay so it launches a binary using the OCI prestart hook. that binary spawns a child process, and that child attaches the function enter_trace to the raw_syscalls:sys_enter tracepoint using eBPF. very main character energy π
. the hook buffers all the syscalls made by processes within the PID namespace of the container. then, when the container exits, the hook writes out the seccomp profile using all of the syscalls stored in that buffer. bye bestie, here's your profile π
π¦ the limitations (read these, seriously)
there are a few limitations to this approach, and ngl you need to know them:
π Requires
- Root privileges (
CAP_SYS_ADMIN). the hook will not work with rootless containers. sorry rootless girlies π - The bcc tool chain and kernel-headers to run. BPF programs must be compiled before running to match the current kernel. like, before. not during. before. π§
- A container engine that supports OCI Hooks.
π Annotation
the oci-seccomp-bpf-hook requires the container be run with the annotation io.containers.trace-syscall=. it must include an output file parameter of:[output file]. this output file must be a absolute path. (yes, "a absolute". we keep the lore π)
optionally you can include an input file parameter if:[input file] pointing to a previously generated seccomp profile file. this input file must also be an absolute path. if specified, the oci-seccomp-bpf-hook will read in the input seccomp profile and preload the list of syscalls. bestie is doing homework before class π
the profile will be created at the output path provided to the annotation. an input file can be used to create a baseline, and newly recorded syscalls will be added to the set and written to the output. but heads up π β if a syscall is blocked in the base profile, then it will remain blocked in the output file even if it is recorded while tracing. the base profile said no and it means no.
this annotation can be used directly via container engines like Podman or passed into the container engine by Kubernetes. flexible icon π
π₯ EXAMPLES π₯
just an output file, fresh profile, no thoughts head empty:
sudo podman run --annotation io.containers.trace-syscall="of:/tmp/seccomp-new.json" IMAGE COMMAND
now with a baseline input file and an output file, the glow-up version:
sudo podman run --annotation io.containers.trace-syscall="if:/tmp/seccomp-origin.json;of:/tmp/seccomp-new.json" IMAGE COMMAND
β FILES β
OCI hook configuration file for prestart:
/usr/share/containers/oci/hooks.d/oci-seccomp-bpf-hook.json/etc/containers/oci/hooks.d/oci-seccomp-bpf-hook.json(Override)
yup, the /etc one overrides. it said what it said π
π SEE ALSO π
go read them, i'll wait π
π AUTHORS π
the absolute legends who made this happen:
- Divyansh Kamboj
kambojdivyansh2000@gmail.comβ¨mailto:kambojdivyansh2000@gmail.comβ© - Valentin Rothberg
vrothberg@redhat.comβ¨mailto:vrothberg@redhat.comβ© - Dan Walsh
dwalsh@redhat.comβ¨mailto:dwalsh@redhat.comβ©
quick vibe check before you go: this whole thing needs root (CAP_SYS_ADMIN), it does not work rootless, and those annotation paths have to be absolute. don't come for me if you ignore that π
and that's the page!! π huge shoutout to the systemd and OCI folks for this one β that's where this manual comes from, and this is the oci-seccomp-bpf-hook(1) page as it stands. mwah, go trace some syscalls bestie πΈπ¦β¨
π¦ where this page comes from
- centos-stream 10: oci-seccomp-bpf-hook 1.3.0-2.el10 Β· Apache-2.0 and BSD-2-Clause and BSD-3-Clause and ISC and MIT
- ubuntu noble: oci-seccomp-bpf-hook 1.2.9+ds-1build1 Β· Apache-2.0
- ubuntu noble: oci-seccomp-bpf-hook 1.2.9+ds-1ubuntu0.3 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms