Skip to content

Commit 2c49d9f

Browse files
avagingvisor-bot
authored andcommitted
kernel: fix circular locking in FSContext.destroy
Release dentries without holding FSContext mutex. PiperOrigin-RevId: 807933205
1 parent 20452a2 commit 2c49d9f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

pkg/sentry/kernel/fs_context.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,13 @@ func (f *FSContext) destroy(ctx context.Context) {
6767
// Hold f.mu so that we don't race with RootDirectory() and
6868
// WorkingDirectory().
6969
f.mu.Lock()
70-
defer f.mu.Unlock()
71-
f.root.DecRef(ctx)
70+
root := f.root
71+
cwd := f.cwd
7272
f.root = vfs.VirtualDentry{}
73-
f.cwd.DecRef(ctx)
7473
f.cwd = vfs.VirtualDentry{}
74+
f.mu.Unlock()
75+
root.DecRef(ctx)
76+
cwd.DecRef(ctx)
7577
}
7678

7779
// DecRef implements RefCounter.DecRef.

0 commit comments

Comments
 (0)