diff --git a/pkg/sentry/fsimpl/gofer/filesystem.go b/pkg/sentry/fsimpl/gofer/filesystem.go index 97cbdde45..fc9dec077 100644 --- a/pkg/sentry/fsimpl/gofer/filesystem.go +++ b/pkg/sentry/fsimpl/gofer/filesystem.go @@ -1736,11 +1736,10 @@ func (fs *filesystem) MountOptions() string { case InteropModeWritethrough: optsKV = append(optsKV, mopt{moptCache, cacheFSCacheWritethrough}) case InteropModeShared: - if fs.opts.regularFilesUseSpecialFileFD { - optsKV = append(optsKV, mopt{moptCache, cacheNone}) - } else { - optsKV = append(optsKV, mopt{moptCache, cacheRemoteRevalidating}) - } + optsKV = append(optsKV, mopt{moptCache, cacheRemoteRevalidating}) + } + if fs.opts.regularFilesUseSpecialFileFD { + optsKV = append(optsKV, mopt{moptDisableFileHandleSharing, nil}) } if fs.opts.forcePageCache { optsKV = append(optsKV, mopt{moptForcePageCache, nil}) diff --git a/pkg/sentry/fsimpl/gofer/gofer.go b/pkg/sentry/fsimpl/gofer/gofer.go index 73825ddbb..ea807e86c 100644 --- a/pkg/sentry/fsimpl/gofer/gofer.go +++ b/pkg/sentry/fsimpl/gofer/gofer.go @@ -73,16 +73,17 @@ const Name = "9p" // Mount option names for goferfs. const ( - moptTransport = "trans" - moptReadFD = "rfdno" - moptWriteFD = "wfdno" - moptAname = "aname" - moptDfltUID = "dfltuid" - moptDfltGID = "dfltgid" - moptCache = "cache" - moptForcePageCache = "force_page_cache" - moptLimitHostFDTranslation = "limit_host_fd_translation" - moptOverlayfsStaleRead = "overlayfs_stale_read" + moptTransport = "trans" + moptReadFD = "rfdno" + moptWriteFD = "wfdno" + moptAname = "aname" + moptDfltUID = "dfltuid" + moptDfltGID = "dfltgid" + moptCache = "cache" + moptForcePageCache = "force_page_cache" + moptLimitHostFDTranslation = "limit_host_fd_translation" + moptOverlayfsStaleRead = "overlayfs_stale_read" + moptDisableFileHandleSharing = "disable_file_handle_sharing" // Directfs options. moptDirectfs = "directfs" @@ -90,7 +91,6 @@ const ( // Valid values for the "cache" mount option. const ( - cacheNone = "none" cacheFSCache = "fscache" cacheFSCacheWritethrough = "fscache_writethrough" cacheRemoteRevalidating = "remote_revalidating" @@ -422,9 +422,6 @@ func (fstype FilesystemType) GetFilesystem(ctx context.Context, vfsObj *vfs.Virt fsopts.interop = InteropModeExclusive case cacheFSCacheWritethrough: fsopts.interop = InteropModeWritethrough - case cacheNone: - fsopts.regularFilesUseSpecialFileFD = true - fallthrough case cacheRemoteRevalidating: fsopts.interop = InteropModeShared default: @@ -459,6 +456,10 @@ func (fstype FilesystemType) GetFilesystem(ctx context.Context, vfsObj *vfs.Virt } // Handle simple flags. + if _, ok := mopts[moptDisableFileHandleSharing]; ok { + delete(mopts, moptDisableFileHandleSharing) + fsopts.regularFilesUseSpecialFileFD = true + } if _, ok := mopts[moptForcePageCache]; ok { delete(mopts, moptForcePageCache) fsopts.forcePageCache = true