Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 30ad2a7

Browse files
committed
seccomp: custom annotation to load raw bpf
Add an annotation `run.oci.seccomp_bpf_data` to ignore the seccomp section in the OCI configuration file and use the specified file as the raw data to the `seccomp(SECCOMP_SET_MODE_FILTER)` syscall. Signed-off-by: Giuseppe Scrivano <[email protected]>
1 parent d883b62 commit 30ad2a7

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

crun.1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,12 @@ are available on the \fB\fCld.so(8)\fR man page.
467467
If the annotation \fB\fCrun.oci.seccomp\_fail\_unknown\_syscall\fR is present, then crun
468468
will fail when an unknown syscall is encountered in the seccomp configuration.
469469

470+
.SH \fB\fCrun.oci.seccomp\_bpf\_data\fR
471+
.PP
472+
If the annotation \fB\fCrun.oci.seccomp\_bpf\_data\fR is present, then crun
473+
ignores the seccomp section in the OCI configuration file and use the specified file
474+
as the raw data to the \fB\fCseccomp(SECCOMP\_SET\_MODE\_FILTER)\fR syscall.
475+
470476
.SH \fB\fCrun.oci.keep\_original\_groups=1\fR
471477
.PP
472478
If the annotation \fB\fCrun.oci.keep\_original\_groups\fR is present, then crun

crun.1.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,12 @@ are available on the `ld.so(8)` man page.
371371
If the annotation `run.oci.seccomp_fail_unknown_syscall` is present, then crun
372372
will fail when an unknown syscall is encountered in the seccomp configuration.
373373

374+
## `run.oci.seccomp_bpf_data`
375+
376+
If the annotation `run.oci.seccomp_bpf_data` is present, then crun
377+
ignores the seccomp section in the OCI configuration file and use the specified file
378+
as the raw data to the `seccomp(SECCOMP_SET_MODE_FILTER)` syscall.
379+
374380
## `run.oci.keep_original_groups=1`
375381

376382
If the annotation `run.oci.keep_original_groups` is present, then crun

src/libcrun/container.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1950,6 +1950,21 @@ libcrun_container_run_internal (libcrun_container_t *container, libcrun_context_
19501950
if (annotation && strcmp (annotation, "0") != 0)
19511951
seccomp_gen_options = LIBCRUN_SECCOMP_FAIL_UNKNOWN_SYSCALL;
19521952

1953+
annotation = find_annotation (container, "run.oci.seccomp_bpf_data");
1954+
if (annotation)
1955+
{
1956+
cleanup_free char *file_content = NULL;
1957+
size_t size;
1958+
1959+
ret = read_all_file (annotation, &file_content, &size, err);
1960+
if (UNLIKELY (ret < 0))
1961+
return ret;
1962+
1963+
ret = safe_write (seccomp_fd, file_content, (ssize_t) size);
1964+
if (UNLIKELY (ret < 0))
1965+
return crun_make_error (err, 0, "write to seccomp fd");
1966+
}
1967+
19531968
ret = libcrun_generate_seccomp (container, seccomp_fd, seccomp_gen_options, err);
19541969
if (UNLIKELY (ret < 0))
19551970
return cleanup_watch (context, pid, sync_socket, terminal_fd, err);

0 commit comments

Comments
 (0)