-
Notifications
You must be signed in to change notification settings - Fork 202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
seccomp: switch default to ENOSYS #573
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,8 +44,54 @@ func arches() []Architecture { | |
// DefaultProfile defines the allowlist for the default seccomp profile. | ||
func DefaultProfile() *Seccomp { | ||
einval := uint(unix.EINVAL) | ||
enosys := uint(unix.ENOSYS) | ||
eperm := uint(unix.EPERM) | ||
|
||
syscalls := []*Syscall{ | ||
{ | ||
Names: []string{ | ||
"bdflush", | ||
"clone3", | ||
"io_pgetevents", | ||
"io_uring_enter", | ||
"io_uring_register", | ||
"io_uring_setup", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
"kexec_file_load", | ||
"kexec_load", | ||
"membarrier", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
"migrate_pages", | ||
"move_pages", | ||
"nfsservctl", | ||
"nice", | ||
"oldfstat", | ||
"oldlstat", | ||
"oldolduname", | ||
"oldstat", | ||
"olduname", | ||
"pciconfig_iobase", | ||
"pciconfig_read", | ||
"pciconfig_write", | ||
"pkey_alloc", | ||
"pkey_free", | ||
"pkey_mprotect", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
"rseq", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not see any harm in permitting |
||
"sgetmask", | ||
"ssetmask", | ||
"swapcontext", | ||
"swapoff", | ||
"swapon", | ||
"sysfs", | ||
"uselib", | ||
"userfaultfd", | ||
"ustat", | ||
"vm86", | ||
"vm86old", | ||
"vmsplice", | ||
}, | ||
Action: ActErrno, | ||
ErrnoRet: &eperm, | ||
Args: []*Arg{}, | ||
}, | ||
{ | ||
Names: []string{ | ||
"_llseek", | ||
|
@@ -255,6 +301,7 @@ func DefaultProfile() *Seccomp { | |
"pwritev2", | ||
"read", | ||
"readahead", | ||
"readdir", | ||
"readlink", | ||
"readlinkat", | ||
"readv", | ||
|
@@ -522,6 +569,17 @@ func DefaultProfile() *Seccomp { | |
Caps: []string{"CAP_DAC_READ_SEARCH"}, | ||
}, | ||
}, | ||
{ | ||
Names: []string{ | ||
"open_by_handle_at", | ||
}, | ||
Action: ActErrno, | ||
ErrnoRet: &eperm, | ||
Args: []*Arg{}, | ||
Excludes: Filter{ | ||
Caps: []string{"CAP_DAC_READ_SEARCH"}, | ||
}, | ||
}, | ||
{ | ||
Names: []string{ | ||
"bpf", | ||
|
@@ -539,6 +597,24 @@ func DefaultProfile() *Seccomp { | |
Caps: []string{"CAP_SYS_ADMIN"}, | ||
}, | ||
}, | ||
{ | ||
Names: []string{ | ||
"bpf", | ||
"fanotify_init", | ||
"lookup_dcookie", | ||
"perf_event_open", | ||
"quotactl", | ||
"setdomainname", | ||
"sethostname", | ||
"setns", | ||
}, | ||
Action: ActErrno, | ||
ErrnoRet: &eperm, | ||
Args: []*Arg{}, | ||
Excludes: Filter{ | ||
Caps: []string{"CAP_SYS_ADMIN"}, | ||
}, | ||
}, | ||
{ | ||
Names: []string{ | ||
"chroot", | ||
|
@@ -549,6 +625,17 @@ func DefaultProfile() *Seccomp { | |
Caps: []string{"CAP_SYS_CHROOT"}, | ||
}, | ||
}, | ||
{ | ||
Names: []string{ | ||
"chroot", | ||
}, | ||
Action: ActErrno, | ||
ErrnoRet: &eperm, | ||
Args: []*Arg{}, | ||
Excludes: Filter{ | ||
Caps: []string{"CAP_SYS_CHROOT"}, | ||
}, | ||
}, | ||
{ | ||
Names: []string{ | ||
"delete_module", | ||
|
@@ -562,6 +649,20 @@ func DefaultProfile() *Seccomp { | |
Caps: []string{"CAP_SYS_MODULE"}, | ||
}, | ||
}, | ||
{ | ||
Names: []string{ | ||
"delete_module", | ||
"init_module", | ||
"finit_module", | ||
"query_module", | ||
}, | ||
Action: ActErrno, | ||
ErrnoRet: &eperm, | ||
Args: []*Arg{}, | ||
Excludes: Filter{ | ||
Caps: []string{"CAP_SYS_MODULE"}, | ||
}, | ||
}, | ||
{ | ||
Names: []string{ | ||
"get_mempolicy", | ||
|
@@ -574,6 +675,19 @@ func DefaultProfile() *Seccomp { | |
Caps: []string{"CAP_SYS_NICE"}, | ||
}, | ||
}, | ||
{ | ||
Names: []string{ | ||
"get_mempolicy", | ||
"mbind", | ||
"set_mempolicy", | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure why those are separate from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these fails with EPERM only when the container is not granted CAP_SYS_NICE. Otherwise seccomp won't block them There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do you suggest enabling them in any case? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As far as I know, they are similar to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks. Added a patch to always allow them |
||
Action: ActErrno, | ||
ErrnoRet: &eperm, | ||
Args: []*Arg{}, | ||
Excludes: Filter{ | ||
Caps: []string{"CAP_SYS_NICE"}, | ||
}, | ||
}, | ||
{ | ||
Names: []string{ | ||
"acct", | ||
|
@@ -584,6 +698,17 @@ func DefaultProfile() *Seccomp { | |
Caps: []string{"CAP_SYS_PACCT"}, | ||
}, | ||
}, | ||
{ | ||
Names: []string{ | ||
"acct", | ||
}, | ||
Action: ActErrno, | ||
ErrnoRet: &eperm, | ||
Args: []*Arg{}, | ||
Excludes: Filter{ | ||
Caps: []string{"CAP_SYS_PACCT"}, | ||
}, | ||
}, | ||
{ | ||
Names: []string{ | ||
"kcmp", | ||
|
@@ -598,6 +723,21 @@ func DefaultProfile() *Seccomp { | |
Caps: []string{"CAP_SYS_PTRACE"}, | ||
}, | ||
}, | ||
{ | ||
Names: []string{ | ||
"kcmp", | ||
"process_madvise", | ||
"process_vm_readv", | ||
"process_vm_writev", | ||
"ptrace", | ||
}, | ||
Action: ActErrno, | ||
ErrnoRet: &eperm, | ||
Args: []*Arg{}, | ||
Excludes: Filter{ | ||
Caps: []string{"CAP_SYS_PTRACE"}, | ||
}, | ||
}, | ||
{ | ||
Names: []string{ | ||
"iopl", | ||
|
@@ -609,6 +749,18 @@ func DefaultProfile() *Seccomp { | |
Caps: []string{"CAP_SYS_RAWIO"}, | ||
}, | ||
}, | ||
{ | ||
Names: []string{ | ||
"iopl", | ||
"ioperm", | ||
}, | ||
Action: ActErrno, | ||
ErrnoRet: &eperm, | ||
Args: []*Arg{}, | ||
Excludes: Filter{ | ||
Caps: []string{"CAP_SYS_RAWIO"}, | ||
}, | ||
}, | ||
{ | ||
Names: []string{ | ||
"settimeofday", | ||
|
@@ -622,6 +774,20 @@ func DefaultProfile() *Seccomp { | |
Caps: []string{"CAP_SYS_TIME"}, | ||
}, | ||
}, | ||
{ | ||
Names: []string{ | ||
"settimeofday", | ||
"stime", | ||
"clock_settime", | ||
"clock_settime64", | ||
}, | ||
Action: ActErrno, | ||
ErrnoRet: &eperm, | ||
Args: []*Arg{}, | ||
Excludes: Filter{ | ||
Caps: []string{"CAP_SYS_TIME"}, | ||
}, | ||
}, | ||
{ | ||
Names: []string{ | ||
"vhangup", | ||
|
@@ -632,6 +798,17 @@ func DefaultProfile() *Seccomp { | |
Caps: []string{"CAP_SYS_TTY_CONFIG"}, | ||
}, | ||
}, | ||
{ | ||
Names: []string{ | ||
"vhangup", | ||
}, | ||
Action: ActErrno, | ||
ErrnoRet: &eperm, | ||
Args: []*Arg{}, | ||
Excludes: Filter{ | ||
Caps: []string{"CAP_SYS_TTY_CONFIG"}, | ||
}, | ||
}, | ||
{ | ||
Names: []string{ | ||
"socket", | ||
|
@@ -714,8 +891,9 @@ func DefaultProfile() *Seccomp { | |
} | ||
|
||
return &Seccomp{ | ||
DefaultAction: ActErrno, | ||
ArchMap: arches(), | ||
Syscalls: syscalls, | ||
DefaultAction: ActErrno, | ||
DefaultErrnoRet: &enosys, | ||
ArchMap: arches(), | ||
Syscalls: syscalls, | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this has to be treated the same way as
clone
. Ideally, we would allow this system call because it is required for supporting certain forms of security hardening. But we definitely will needENOSYS
forclone3
.