From 2ef09d3bddc7b738a555f6f98029ec32a402a9b8 Mon Sep 17 00:00:00 2001 From: Nicolas Lacasse Date: Mon, 5 Aug 2024 10:45:59 -0700 Subject: [PATCH] FUSE: Avoid panic when opening unknown file type. Reported-by: syzbot+7958d33bd06200d30e90@syzkaller.appspotmail.com PiperOrigin-RevId: 659604628 --- pkg/sentry/fsimpl/fuse/inode.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/sentry/fsimpl/fuse/inode.go b/pkg/sentry/fsimpl/fuse/inode.go index 23b2c491a..101e97b2a 100644 --- a/pkg/sentry/fsimpl/fuse/inode.go +++ b/pkg/sentry/fsimpl/fuse/inode.go @@ -19,11 +19,11 @@ import ( gotime "time" "gvisor.dev/gvisor/pkg/abi/linux" - "gvisor.dev/gvisor/pkg/atomicbitops" "gvisor.dev/gvisor/pkg/context" "gvisor.dev/gvisor/pkg/errors/linuxerr" "gvisor.dev/gvisor/pkg/hostarch" + "gvisor.dev/gvisor/pkg/log" "gvisor.dev/gvisor/pkg/marshal" "gvisor.dev/gvisor/pkg/marshal/primitive" "gvisor.dev/gvisor/pkg/sentry/fsimpl/kernfs" @@ -280,7 +280,7 @@ func (i *inode) Open(ctx context.Context, rp *vfs.ResolvingPath, d *kernfs.Dentr fdImpl vfs.FileDescriptionImpl opcode linux.FUSEOpcode ) - switch i.filemode().FileType() { + switch ft := i.filemode().FileType(); ft { case linux.S_IFREG: regularFD := ®ularFileFD{} fd = &(regularFD.fileDescription) @@ -302,6 +302,9 @@ func (i *inode) Open(ctx context.Context, rp *vfs.ResolvingPath, d *kernfs.Dentr opcode = linux.FUSE_OPENDIR case linux.S_IFLNK: return nil, linuxerr.ELOOP + default: + log.Warningf("Open on unknown file type: %v", ft) + return nil, linuxerr.EINVAL } fd.LockFD.Init(&i.locks)