diff options
author | Jinmou Li <jinmli@google.com> | 2020-09-16 17:44:06 +0000 |
---|---|---|
committer | Andrei Vagin <avagin@gmail.com> | 2020-09-16 12:22:17 -0700 |
commit | c4c302a27e5811ce04bb904686e657c9ed830a44 (patch) | |
tree | 1a3ac68b92e7482395136195ba927b4f91b08048 /pkg/sentry | |
parent | 70cf503b4c3653df8253438a8873a5d3ebb688e3 (diff) |
fuse: fix data race in fusefs Release()
fix #3956
Diffstat (limited to 'pkg/sentry')
-rw-r--r-- | pkg/sentry/fsimpl/fuse/connection_control.go | 5 | ||||
-rw-r--r-- | pkg/sentry/fsimpl/fuse/fusefs.go | 5 |
2 files changed, 5 insertions, 5 deletions
diff --git a/pkg/sentry/fsimpl/fuse/connection_control.go b/pkg/sentry/fsimpl/fuse/connection_control.go index 50cf4a761..bfde78559 100644 --- a/pkg/sentry/fsimpl/fuse/connection_control.go +++ b/pkg/sentry/fsimpl/fuse/connection_control.go @@ -189,10 +189,9 @@ func (conn *connection) initProcessReply(out *linux.FUSEInitOut, hasSysAdminCap // Abort this FUSE connection. // It tries to acquire conn.fd.mu, conn.lock, conn.bgLock in order. // All possible requests waiting or blocking will be aborted. +// +// Preconditions: conn.fd.mu is locked. func (conn *connection) Abort(ctx context.Context) { - conn.fd.mu.Lock() - defer conn.fd.mu.Unlock() - conn.mu.Lock() conn.asyncMu.Lock() diff --git a/pkg/sentry/fsimpl/fuse/fusefs.go b/pkg/sentry/fsimpl/fuse/fusefs.go index 86922a96a..f1ffd2343 100644 --- a/pkg/sentry/fsimpl/fuse/fusefs.go +++ b/pkg/sentry/fsimpl/fuse/fusefs.go @@ -225,12 +225,13 @@ func newFUSEFilesystem(ctx context.Context, devMinor uint32, opts *filesystemOpt // Release implements vfs.FilesystemImpl.Release. func (fs *filesystem) Release(ctx context.Context) { + fs.conn.fd.mu.Lock() + fs.umounted = true fs.conn.Abort(ctx) - - fs.conn.fd.mu.Lock() // Notify all the waiters on this fd. fs.conn.fd.waitQueue.Notify(waiter.EventIn) + fs.conn.fd.mu.Unlock() fs.Filesystem.VFSFilesystem().VirtualFilesystem().PutAnonBlockDevMinor(fs.devMinor) |