mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
Support specs.LinuxSeccompFlagWaitKillableRecv
This adds support for WaitKillableRecv seccomp flag (also known as SCMP_FLTATR_CTL_WAITKILL in libseccomp and as SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV in the kernel). This requires: - libseccomp >= 2.6.0 - libseccomp-golang >= 0.11.0 - linux kernel >= 5.19 Note that this flag does not make sense without NEW_LISTENER, and the kernel returns EINVAL when SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV is set but SECCOMP_FILTER_FLAG_NEW_LISTENER is not set. For runc this means that .linux.seccomp.listenerPath should also be set, and some of the seccomp rules should have SCMP_ACT_NOTIFY action. This is why the flag is tested separately in seccomp-notify.bats. At the moment the only adequate CI environment for this functionality is Fedora 43. On all other platforms (including CentOS 10 and Ubuntu 24.04) it is skipped similar to this: > ok 251 runc run [seccomp] (SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV) # skip requires libseccomp >= 2.6.0 and API level >= 7 (current version: 2.5.6, API level: 6) Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
@@ -109,6 +109,7 @@ var flags = []string{
|
||||
flagTsync,
|
||||
string(specs.LinuxSeccompFlagSpecAllow),
|
||||
string(specs.LinuxSeccompFlagLog),
|
||||
string(specs.LinuxSeccompFlagWaitKillableRecv),
|
||||
}
|
||||
|
||||
// KnownFlags returns the list of the known filter flags.
|
||||
|
||||
@@ -51,6 +51,11 @@ const uintptr_t C_FILTER_FLAG_SPEC_ALLOW = SECCOMP_FILTER_FLAG_SPEC_ALLOW;
|
||||
#endif
|
||||
const uintptr_t C_FILTER_FLAG_NEW_LISTENER = SECCOMP_FILTER_FLAG_NEW_LISTENER;
|
||||
|
||||
#ifndef SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV
|
||||
# define SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV (1UL << 5)
|
||||
#endif
|
||||
const uintptr_t C_FILTER_FLAG_WAIT_KILLABLE_RECV = SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV;
|
||||
|
||||
#ifndef AUDIT_ARCH_RISCV64
|
||||
#ifndef EM_RISCV
|
||||
#define EM_RISCV 243
|
||||
@@ -667,6 +672,13 @@ func filterFlags(config *configs.Seccomp, filter *libseccomp.ScmpFilter) (flags
|
||||
flags |= uint(C.C_FILTER_FLAG_SPEC_ALLOW)
|
||||
}
|
||||
}
|
||||
if apiLevel >= 7 {
|
||||
if waitKill, err := filter.GetWaitKill(); err != nil {
|
||||
return 0, false, fmt.Errorf("unable to fetch SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV bit: %w", err)
|
||||
} else if waitKill {
|
||||
flags |= uint(C.C_FILTER_FLAG_WAIT_KILLABLE_RECV)
|
||||
}
|
||||
}
|
||||
// XXX: add newly supported filter flags above this line.
|
||||
|
||||
for _, call := range config.Syscalls {
|
||||
|
||||
@@ -159,6 +159,11 @@ func setFlag(filter *libseccomp.ScmpFilter, flag specs.LinuxSeccompFlag) error {
|
||||
return fmt.Errorf("error adding SSB flag to seccomp filter: %w", err)
|
||||
}
|
||||
return nil
|
||||
case specs.LinuxSeccompFlagWaitKillableRecv:
|
||||
if err := filter.SetWaitKill(true); err != nil {
|
||||
return fmt.Errorf("error adding WaitKill flag to seccomp filter: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
// NOTE when adding more flags above, do not forget to also:
|
||||
// - add new flags to `flags` slice in config.go;
|
||||
|
||||
Reference in New Issue
Block a user