Skip to content

Commit 55923da

Browse files
committed
seccomp: support "clone3" (return ENOSYS unless SYS_ADMIN is granted)
clone3 is explicitly requested to give ENOSYS instead of the default EPERM, when CAP_SYS_ADMIN is unset. See moby/moby PR 42681 (thanks to berrange). Without this commit, rawhide image does not work: ```console $ sudo ctr run --rm --net-host --seccomp registry.fedoraproject.org/fedora:rawhide foo /usr/bin/curl google.com curl: (6) getaddrinfo() thread failed to start ``` Signed-off-by: Akihiro Suda <[email protected]>
1 parent 493220b commit 55923da

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

contrib/seccomp/seccomp_default.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ func arches() []specs.Arch {
5050

5151
// DefaultProfile defines the allowed syscalls for the default seccomp profile.
5252
func DefaultProfile(sp *specs.Spec) *specs.LinuxSeccomp {
53+
nosys := uint(unix.ENOSYS)
5354
syscalls := []specs.LinuxSyscall{
5455
{
5556
Names: []string{
@@ -527,6 +528,7 @@ func DefaultProfile(sp *specs.Spec) *specs.LinuxSeccomp {
527528
Names: []string{
528529
"bpf",
529530
"clone",
531+
"clone3",
530532
"fanotify_init",
531533
"fsconfig",
532534
"fsmount",
@@ -658,6 +660,15 @@ func DefaultProfile(sp *specs.Spec) *specs.LinuxSeccomp {
658660
},
659661
})
660662
}
663+
// clone3 is explicitly requested to give ENOSYS instead of the default EPERM, when CAP_SYS_ADMIN is unset
664+
// https://github.com/moby/moby/pull/42681
665+
s.Syscalls = append(s.Syscalls, specs.LinuxSyscall{
666+
Names: []string{
667+
"clone3",
668+
},
669+
Action: specs.ActErrno,
670+
ErrnoRet: &nosys,
671+
})
661672
}
662673

663674
return s

0 commit comments

Comments
 (0)