Skip to content

Commit

Permalink
systrap: don't fail if seccomp_unotify isn't supported
Browse files Browse the repository at this point in the history
Fixes #10633

PiperOrigin-RevId: 651552693
  • Loading branch information
avagin authored and gvisor-bot committed Jul 11, 2024
1 parent ab513ff commit 03e1b70
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pkg/sentry/platform/systrap/syscall_thread.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,11 @@ func (t *syscallThread) init(seccompNotify bool) error {
}

if seccompNotify {
t.seccompNotify = t.installSeccompNotify()
var err error
t.seccompNotify, err = t.installSeccompNotify()
if err != nil {
t.thread.Warningf("failed to install seccomp notify rules: %s", err)
}
}

// Map the stack into the sentry.
Expand Down Expand Up @@ -142,19 +146,19 @@ func (t *syscallThread) destroy() {
t.subproc.sysmsgStackPool.Put(t.thread.sysmsgStackID)
}

func (t *syscallThread) installSeccompNotify() *os.File {
func (t *syscallThread) installSeccompNotify() (*os.File, error) {
fd, err := t.thread.syscallIgnoreInterrupt(&t.thread.initRegs, seccomp.SYS_SECCOMP,
arch.SyscallArgument{Value: uintptr(linux.SECCOMP_SET_MODE_FILTER)},
arch.SyscallArgument{Value: uintptr(linux.SECCOMP_FILTER_FLAG_NEW_LISTENER)},
arch.SyscallArgument{Value: stubSyscallRules})
if err != nil {
panic(fmt.Sprintf("seccomp failed: %v", err))
return nil, err
}
_, _, errno := unix.RawSyscall(unix.SYS_IOCTL, fd, linux.SECCOMP_IOCTL_NOTIF_SET_FLAGS, linux.SECCOMP_USER_NOTIF_FD_SYNC_WAKE_UP)
if errno != 0 {
t.thread.Debugf("failed to set SECCOMP_USER_NOTIF_FD_SYNC_WAKE_UP")
}
return os.NewFile(fd, "seccomp_notify")
return os.NewFile(fd, "seccomp_notify"), nil
}

// mapMessageIntoStub maps the syscall message into the stub process address space.
Expand Down

0 comments on commit 03e1b70

Please sign in to comment.