Lock around accessing the mount namespace in pivot_root.

Reported-by: syzbot+14315403420bef186ad8@syzkaller.appspotmail.com
PiperOrigin-RevId: 513401809
This commit is contained in:
Lucas Manning
2023-03-01 18:55:25 -08:00
committed by gVisor bot
parent a625ba1d0a
commit 807fd0fd27
+2 -1
View File
@@ -954,11 +954,12 @@ retry:
// The current root and the new root must be in the context's mount namespace.
ns := MountNamespaceFromContext(ctx)
defer ns.DecRef(ctx)
vfs.mountMu.Lock()
if rootVd.mount.ns != ns || newRootVd.mount.ns != ns {
vfs.mountMu.Unlock()
return linuxerr.EINVAL
}
vfs.mountMu.Lock()
// Either the mount point at new_root, or the parent mount of that mount
// point, has propagation type MS_SHARED.
if newRootParent := newRootVd.mount.parent(); newRootVd.mount.propType == Shared || newRootParent.propType == Shared {