jail: add support for cgroup devices as in OCI run-time spec
authorDaniel Golle <daniel@makrotopia.org>
Fri, 28 May 2021 16:17:35 +0000 (18:17 +0200)
committerDaniel Golle <daniel@makrotopia.org>
Sat, 10 Jul 2021 02:26:04 +0000 (03:26 +0100)
commit2dcefbd6094681dcbd2d7ff608590e74425a9220
treeca34ec61d5ba71f84c58e511f0018f4d3c92f5a4
parent021ece84de430fca988acd6934f6046ea59d8c37
jail: add support for cgroup devices as in OCI run-time spec

Implement eBPF generator to emulate cgroup-v1 devices.{allow,deny}
as we got only cgroup-v2 available while the spec was written having
cgroups-v1 in mind.
Instead of literally emulating the legacy behavior, do like other
runtimes do as well when running on cgroup-v2: simply translate each
device rule into a bunch of eBPF instructions and then execute them
in reverse order, prepended by some default rules covering /dev/null,
/dev/random, /dev/tty, ...

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
CMakeLists.txt
jail/cgroups-bpf.c [new file with mode: 0644]
jail/cgroups-bpf.h [new file with mode: 0644]
jail/cgroups.c
jail/jail.c