diff options
author | gVisor bot <gvisor-bot@google.com> | 2020-06-03 18:08:11 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-06-03 18:08:11 +0000 |
commit | d76e880c453dee0cf0605f891cb334d70258e050 (patch) | |
tree | 72eca5f507589a9513808a6d29d65f2cec29de9f /pkg/sentry | |
parent | 5451d0b376f9e6f5f4ddb00bb1e4c1502af68126 (diff) | |
parent | c8e79683891db9e780449112f78ee4004a2de833 (diff) |
Merge release-20200522.0-67-gc8e79683 (automated)
Diffstat (limited to 'pkg/sentry')
-rw-r--r-- | pkg/sentry/vfs/mount.go | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/pkg/sentry/vfs/mount.go b/pkg/sentry/vfs/mount.go index e4ac6524b..3adb7c97d 100644 --- a/pkg/sentry/vfs/mount.go +++ b/pkg/sentry/vfs/mount.go @@ -265,8 +265,8 @@ func (vfs *VirtualFilesystem) MountAt(ctx context.Context, creds *auth.Credentia if err != nil { return err } + defer mnt.DecRef() if err := vfs.ConnectMountAt(ctx, creds, mnt, target); err != nil { - mnt.DecRef() return err } return nil @@ -394,8 +394,15 @@ func (vfs *VirtualFilesystem) umountRecursiveLocked(mnt *Mount, opts *umountRecu // references held by vd. // // Preconditions: vfs.mountMu must be locked. vfs.mounts.seq must be in a -// writer critical section. d.mu must be locked. mnt.parent() == nil. +// writer critical section. d.mu must be locked. mnt.parent() == nil, i.e. mnt +// must not already be connected. func (vfs *VirtualFilesystem) connectLocked(mnt *Mount, vd VirtualDentry, mntns *MountNamespace) { + if checkInvariants { + if mnt.parent() != nil { + panic("VFS.connectLocked called on connected mount") + } + } + mnt.IncRef() // dropped by callers of umountRecursiveLocked mnt.storeKey(vd) if vd.mount.children == nil { vd.mount.children = make(map[*Mount]struct{}) @@ -420,6 +427,11 @@ func (vfs *VirtualFilesystem) connectLocked(mnt *Mount, vd VirtualDentry, mntns // writer critical section. mnt.parent() != nil. func (vfs *VirtualFilesystem) disconnectLocked(mnt *Mount) VirtualDentry { vd := mnt.loadKey() + if checkInvariants { + if vd.mount != nil { + panic("VFS.disconnectLocked called on disconnected mount") + } + } mnt.storeKey(VirtualDentry{}) delete(vd.mount.children, mnt) atomic.AddUint32(&vd.dentry.mounts, math.MaxUint32) // -1 |