Skip to content

Commit 9230888

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]> (cherry picked from commit 55923da) Signed-off-by: Akihiro Suda <[email protected]>
1 parent 78a5a2c commit 9230888

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
@@ -49,6 +49,7 @@ func arches() []specs.Arch {
4949

5050
// DefaultProfile defines the allowed syscalls for the default seccomp profile.
5151
func DefaultProfile(sp *specs.Spec) *specs.LinuxSeccomp {
52+
nosys := uint(unix.ENOSYS)
5253
syscalls := []specs.LinuxSyscall{
5354
{
5455
Names: []string{
@@ -526,6 +527,7 @@ func DefaultProfile(sp *specs.Spec) *specs.LinuxSeccomp {
526527
Names: []string{
527528
"bpf",
528529
"clone",
530+
"clone3",
529531
"fanotify_init",
530532
"fsconfig",
531533
"fsmount",
@@ -657,6 +659,15 @@ func DefaultProfile(sp *specs.Spec) *specs.LinuxSeccomp {
657659
},
658660
})
659661
}
662+
// clone3 is explicitly requested to give ENOSYS instead of the default EPERM, when CAP_SYS_ADMIN is unset
663+
// https://github.com/moby/moby/pull/42681
664+
s.Syscalls = append(s.Syscalls, specs.LinuxSyscall{
665+
Names: []string{
666+
"clone3",
667+
},
668+
Action: specs.ActErrno,
669+
ErrnoRet: &nosys,
670+
})
660671
}
661672

662673
return s

0 commit comments

Comments
 (0)