From dfd9045221c782f4618ebf3fe88f4bc49dce1653 Mon Sep 17 00:00:00 2001 From: Ayush Ranjan Date: Mon, 11 Jul 2022 17:13:59 -0700 Subject: [PATCH] Remove host fchmod(2) calls from the sentry. fchmod(2) is not part of sentry's seccomp filters. So the sentry should not be trying to make this syscall. Instead we will error out gracefully. Violating seccomp filters will kill the entire sandbox. There was only one instance in host filesystem (both in VFS1 and VFS2). I am only fixing VFS2, because VFS1 is already deprecated. I manually checked that all other host syscalls made by fsimpl/host are allowed by sentry seccomp filters. PiperOrigin-RevId: 460335687 --- pkg/sentry/fsimpl/host/host.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkg/sentry/fsimpl/host/host.go b/pkg/sentry/fsimpl/host/host.go index fd9a751a9..f33433c91 100644 --- a/pkg/sentry/fsimpl/host/host.go +++ b/pkg/sentry/fsimpl/host/host.go @@ -523,9 +523,8 @@ func (i *inode) SetStat(ctx context.Context, fs *vfs.Filesystem, creds *auth.Cre // We hold i.virtualOwner.mu. i.virtualOwner.mode = atomicbitops.FromUint32(uint32(opts.Stat.Mode)) } else { - if err := unix.Fchmod(i.hostFD, uint32(s.Mode)); err != nil { - return err - } + log.Warningf("sentry seccomp filters don't allow making fchmod(2) syscall") + return unix.EPERM } } if m&linux.STATX_SIZE != 0 {