Skip to content

Commit 348c766

Browse files
authored
Merge pull request #5172 from kolyshkin/seccomp-wait-kill
Support specs.LinuxSeccompFlagWaitKillableRecv
2 parents 496b68a + 0079bee commit 348c766

File tree

7 files changed

+46
-7
lines changed

7 files changed

+46
-7
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
136136

137137
[debian-armhf]: https://wiki.debian.org/ArmHardFloatPort
138138

139+
### Added ###
140+
- Support for specs.LinuxSeccompFlagWaitKillableRecv. (#5172)
141+
139142
## [1.4.0] - 2025-11-27
140143

141144
> 路漫漫其修远兮,吾将上下而求索!

docs/spec-conformance.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,6 @@
33
This branch of runc implements the [OCI Runtime Spec v1.3.0](https://github.com/opencontainers/runtime-spec/tree/v1.3.0)
44
for the `linux` platform.
55

6-
The following features are not implemented yet:
7-
8-
Spec version | Feature | PR
9-
-------------|------------------------------------------------|----------------------------------------------------------
10-
v1.1.0 | `SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV` | [#3862](https://github.com/opencontainers/runc/pull/3862)
11-
126
## Architectures
137

148
The following architectures are supported:

libcontainer/seccomp/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ var flags = []string{
109109
flagTsync,
110110
string(specs.LinuxSeccompFlagSpecAllow),
111111
string(specs.LinuxSeccompFlagLog),
112+
string(specs.LinuxSeccompFlagWaitKillableRecv),
112113
}
113114

114115
// KnownFlags returns the list of the known filter flags.

libcontainer/seccomp/patchbpf/enosys_linux.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ const uintptr_t C_FILTER_FLAG_SPEC_ALLOW = SECCOMP_FILTER_FLAG_SPEC_ALLOW;
5151
#endif
5252
const uintptr_t C_FILTER_FLAG_NEW_LISTENER = SECCOMP_FILTER_FLAG_NEW_LISTENER;
5353
54+
#ifndef SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV
55+
# define SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV (1UL << 5)
56+
#endif
57+
const uintptr_t C_FILTER_FLAG_WAIT_KILLABLE_RECV = SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV;
58+
5459
#ifndef AUDIT_ARCH_RISCV64
5560
#ifndef EM_RISCV
5661
#define EM_RISCV 243
@@ -667,6 +672,13 @@ func filterFlags(config *configs.Seccomp, filter *libseccomp.ScmpFilter) (flags
667672
flags |= uint(C.C_FILTER_FLAG_SPEC_ALLOW)
668673
}
669674
}
675+
if apiLevel >= 7 {
676+
if waitKill, err := filter.GetWaitKill(); err != nil {
677+
return 0, false, fmt.Errorf("unable to fetch SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV bit: %w", err)
678+
} else if waitKill {
679+
flags |= uint(C.C_FILTER_FLAG_WAIT_KILLABLE_RECV)
680+
}
681+
}
670682
// XXX: add newly supported filter flags above this line.
671683

672684
for _, call := range config.Syscalls {

libcontainer/seccomp/seccomp_linux.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,11 @@ func setFlag(filter *libseccomp.ScmpFilter, flag specs.LinuxSeccompFlag) error {
159159
return fmt.Errorf("error adding SSB flag to seccomp filter: %w", err)
160160
}
161161
return nil
162+
case specs.LinuxSeccompFlagWaitKillableRecv:
163+
if err := filter.SetWaitKill(true); err != nil {
164+
return fmt.Errorf("error adding WaitKill flag to seccomp filter: %w", err)
165+
}
166+
return nil
162167
}
163168
// NOTE when adding more flags above, do not forget to also:
164169
// - add new flags to `flags` slice in config.go;

tests/integration/seccomp-notify.bats

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,27 @@ function scmp_act_notify_template() {
5858
[ "$status" -eq 0 ]
5959
}
6060

61+
@test "runc run [seccomp] (SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV)" {
62+
scmp_act_notify_template "mkdir /dev/shm/foo && stat /dev/shm/foo-bar" false '"mkdir"'
63+
update_config '.linux.seccomp.flags = [ "SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV" ]'
64+
65+
runc --debug run test_busybox
66+
if [ "$status" -ne 0 ]; then
67+
# Older libseccomp or kernel?
68+
if [[ "$output" == *"error adding WaitKill flag to seccomp filter: SetWaitKill requires "* ]]; then
69+
skip "$(sed -e 's/^.*SetWaitKill //' -e 's/" func=.*$//' <<<"$output")"
70+
fi
71+
# Otherwise, fail.
72+
[ "$status" -eq 0 ]
73+
fi
74+
# Check the numeric flags value, as printed in the debug log, is as expected.
75+
# 32: SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV
76+
# 8: SECCOMP_FILTER_FLAG_NEW_LISTENER
77+
exp='"seccomp filter flags: 40"'
78+
echo "expecting $exp"
79+
[[ "$output" == *"$exp"* ]]
80+
}
81+
6182
# Test actions not-handled by the agent work fine. noNewPrivileges FALSE.
6283
@test "runc exec [seccomp] (SCMP_ACT_NOTIFY noNewPrivileges false)" {
6384
requires root

tests/integration/seccomp.bats

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,11 @@ function flags_value() {
102102

103103
# Get the list of flags supported by runc/seccomp/kernel,
104104
# or "null" if no flags are supported or runc is too old.
105+
#
106+
# Filter out WAIT_KILLABLE_RECV as it requires a listener,
107+
# and thus tested separately in seccomp-notify.bats.
105108
mapfile -t flags < <(__runc features | jq -c '.linux.seccomp.supportedFlags' |
106-
tr -d '[]\n' | tr ',' '\n')
109+
tr -d '[]\n' | tr ',' '\n' | grep -v 'WAIT_KILLABLE_RECV')
107110

108111
# This is a set of all possible flag combinations to test.
109112
declare -A TEST_CASES=(

0 commit comments

Comments
 (0)