Skip to content

Commit b9045bc

Browse files
committed
libct/seccomp/config: add missing KillThread, KillProcess
OCI spec added SCMP_ACT_KILL_THREAD and SCMP_ACT_KILL_PROCESS almost two years ago ([1], [2]), but runc support was half-finished [3]. Add these actions, and modify the test case to check them. In addition, "runc features" now lists the new actions. [1] opencontainers/runtime-spec#1044 [2] opencontainers/runtime-spec#1064 [3] https://github.com/opencontainers/runc/pulls/3204 Fixes: 84e6025 Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com> (cherry picked from commit e74fdeb) (cherry picked from commit 8604590d59ca5c6e3608244e49d888e0e92c7585) Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
1 parent a837b58 commit b9045bc

File tree

2 files changed

+27
-10
lines changed

2 files changed

+27
-10
lines changed

libcontainer/seccomp/config.go

+9-7
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,15 @@ func KnownOperators() []string {
2929
}
3030

3131
var actions = map[string]configs.Action{
32-
"SCMP_ACT_KILL": configs.Kill,
33-
"SCMP_ACT_ERRNO": configs.Errno,
34-
"SCMP_ACT_TRAP": configs.Trap,
35-
"SCMP_ACT_ALLOW": configs.Allow,
36-
"SCMP_ACT_TRACE": configs.Trace,
37-
"SCMP_ACT_LOG": configs.Log,
38-
"SCMP_ACT_NOTIFY": configs.Notify,
32+
"SCMP_ACT_KILL": configs.Kill,
33+
"SCMP_ACT_ERRNO": configs.Errno,
34+
"SCMP_ACT_TRAP": configs.Trap,
35+
"SCMP_ACT_ALLOW": configs.Allow,
36+
"SCMP_ACT_TRACE": configs.Trace,
37+
"SCMP_ACT_LOG": configs.Log,
38+
"SCMP_ACT_NOTIFY": configs.Notify,
39+
"SCMP_ACT_KILL_THREAD": configs.KillThread,
40+
"SCMP_ACT_KILL_PROCESS": configs.KillProcess,
3941
}
4042

4143
// KnownActions returns the list of the known actions.

libcontainer/specconv/spec_linux_test.go

+18-3
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,14 @@ func TestSetupSeccomp(t *testing.T) {
234234
Names: []string{"mknod"},
235235
Action: "SCMP_ACT_NOTIFY",
236236
},
237+
{
238+
Names: []string{"rmdir"},
239+
Action: "SCMP_ACT_KILL_THREAD",
240+
},
241+
{
242+
Names: []string{"mkdir"},
243+
Action: "SCMP_ACT_KILL_PROCESS",
244+
},
237245
},
238246
}
239247
seccomp, err := SetupSeccomp(conf)
@@ -263,9 +271,8 @@ func TestSetupSeccomp(t *testing.T) {
263271

264272
calls := seccomp.Syscalls
265273

266-
callsLength := len(calls)
267-
if callsLength != 8 {
268-
t.Errorf("Expected 8 syscalls, got :%d", callsLength)
274+
if len(calls) != len(conf.Syscalls) {
275+
t.Error("Mismatched number of syscalls")
269276
}
270277

271278
for _, call := range calls {
@@ -317,6 +324,14 @@ func TestSetupSeccomp(t *testing.T) {
317324
if call.Action != configs.Notify {
318325
t.Errorf("Wrong conversion for the %s syscall action", call.Name)
319326
}
327+
case "rmdir":
328+
if call.Action != configs.KillThread {
329+
t.Errorf("Wrong conversion for the %s syscall action", call.Name)
330+
}
331+
case "mkdir":
332+
if call.Action != configs.KillProcess {
333+
t.Errorf("Wrong conversion for the %s syscall action", call.Name)
334+
}
320335
default:
321336
t.Errorf("Unexpected syscall %s found", call.Name)
322337
}

0 commit comments

Comments
 (0)