mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Move rootfs check to inside mountMu.
Reported-by: syzbot+811d3f0d101cfe1b1737@syzkaller.appspotmail.com PiperOrigin-RevId: 578631715
This commit is contained in:
committed by
gVisor bot
parent
9c0d595c8f
commit
429f7c4396
@@ -1040,10 +1040,7 @@ retry:
|
||||
if oldRoot.mount.root != oldRoot.dentry {
|
||||
return newRoot, oldRoot, linuxerr.EINVAL
|
||||
}
|
||||
// The current root and the new root cannot be on the rootfs mount.
|
||||
if oldRoot.mount.parent() == nil || newRoot.mount.parent() == nil {
|
||||
return newRoot, oldRoot, linuxerr.EINVAL
|
||||
}
|
||||
|
||||
// The current root and the new root must be in the context's mount namespace.
|
||||
ns := MountNamespaceFromContext(ctx)
|
||||
defer ns.DecRef(ctx)
|
||||
@@ -1053,6 +1050,12 @@ retry:
|
||||
return newRoot, oldRoot, linuxerr.EINVAL
|
||||
}
|
||||
|
||||
// The current root and the new root cannot be on the rootfs mount.
|
||||
if oldRoot.mount.parent() == nil || newRoot.mount.parent() == nil {
|
||||
vfs.unlockMounts(ctx)
|
||||
return newRoot, oldRoot, linuxerr.EINVAL
|
||||
}
|
||||
|
||||
// Either the mount point at new_root, or the parent mount of that mount
|
||||
// point, has propagation type MS_SHARED.
|
||||
if newRootParent := newRoot.mount.parent(); newRoot.mount.isShared || newRootParent.isShared {
|
||||
|
||||
Reference in New Issue
Block a user