diff options
author | Alice Frosi <afrosi@redhat.com> | 2023-07-18 11:15:53 +0200 |
---|---|---|
committer | Alice Frosi <afrosi@redhat.com> | 2023-08-24 15:33:17 +0200 |
commit | 240eb94b44f9dc613a85911d4190df129372e9cc (patch) | |
tree | 2535780888d293b71aa5aadc70f2047f2a7f787b /cooker/emit.c | |
parent | 3f2585770384586977483ec4c4b38fe4c3e5fc45 (diff) | |
download | seitan-240eb94b44f9dc613a85911d4190df129372e9cc.tar seitan-240eb94b44f9dc613a85911d4190df129372e9cc.tar.gz seitan-240eb94b44f9dc613a85911d4190df129372e9cc.tar.bz2 seitan-240eb94b44f9dc613a85911d4190df129372e9cc.tar.lz seitan-240eb94b44f9dc613a85911d4190df129372e9cc.tar.xz seitan-240eb94b44f9dc613a85911d4190df129372e9cc.tar.zst seitan-240eb94b44f9dc613a85911d4190df129372e9cc.zip |
cooker: generate OCI seccomp profile
Generate the OCI seccomp profile instead of directly the BPF filter. The
seccomp profile will be used consquently by the container runtime as
input in order to generate the BPF filter.
Example with mknod:
$ seitan-cooker -g /tmp/gluten -p /tmp/scmp_prof.json -s seccomp.json -i demo/mknod.hjson
$ seitan -s /tmp/seitan.sock -i /tmp/gluten
$ podman run --cap-drop ALL
--security-opt=seccomp=/tmp/scmp_prof.json \
--annotation run.oci.seccomp.receiver=/tmp/seitan.sock \
-ti fedora \
sh -c 'mknod /dev/lol c 1 7 && ls /dev/lol'
/dev/lol
Signed-off-by: Alice Frosi <afrosi@redhat.com>
Diffstat (limited to 'cooker/emit.c')
-rw-r--r-- | cooker/emit.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/cooker/emit.c b/cooker/emit.c index 28afd29..ce325f1 100644 --- a/cooker/emit.c +++ b/cooker/emit.c @@ -14,6 +14,7 @@ #include "filter.h" #include "util.h" #include "emit.h" +#include "seccomp_profile.h" static const char *type_str[] = { "UNDEF", "NONE", @@ -549,8 +550,8 @@ static void gluten_link(struct gluten_ctx *g, enum jump_type type, } } -void emit_bpf_arg(int index, enum type type, union value v, union value mask, - enum op_cmp_type cmp) +static void emit_bpf_filter_arg(int index, enum type type, union value v, + union value mask, enum op_cmp_type cmp) { struct bpf_field bpf; @@ -575,6 +576,15 @@ void emit_bpf_arg(int index, enum type type, union value v, union value mask, filter_add_check(&bpf); } +void emit_bpf_arg(int index, enum type type, union value v, union value mask, + enum op_cmp_type cmp, enum scmp_mode mode) +{ + if (mode == SCMP_FILTER) + emit_bpf_filter_arg(index, type, v, mask, cmp); + else + scmp_profile_add_check(index, v, mask, cmp); +} + void link_block(struct gluten_ctx *g) { debug(" Linking block..."); |