Commit e0c9c0af authored by Eric W. Biederman's avatar Eric W. Biederman

mnt: Update detach_mounts to leave mounts connected

Now that it is possible to lazily unmount an entire mount tree and
leave the individual mounts connected to each other add a new flag
UMOUNT_CONNECTED to umount_tree to force this behavior and use
this flag in detach_mounts.

This closes a bug where the deletion of a file or directory could
trigger an unmount and reveal data under a mount point.

Cc: stable@vger.kernel.org
Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
parent f53e5797
...@@ -1348,6 +1348,7 @@ static inline void namespace_lock(void) ...@@ -1348,6 +1348,7 @@ static inline void namespace_lock(void)
enum umount_tree_flags { enum umount_tree_flags {
UMOUNT_SYNC = 1, UMOUNT_SYNC = 1,
UMOUNT_PROPAGATE = 2, UMOUNT_PROPAGATE = 2,
UMOUNT_CONNECTED = 4,
}; };
/* /*
* mount_lock must be held * mount_lock must be held
...@@ -1386,7 +1387,10 @@ static void umount_tree(struct mount *mnt, enum umount_tree_flags how) ...@@ -1386,7 +1387,10 @@ static void umount_tree(struct mount *mnt, enum umount_tree_flags how)
if (how & UMOUNT_SYNC) if (how & UMOUNT_SYNC)
p->mnt.mnt_flags |= MNT_SYNC_UMOUNT; p->mnt.mnt_flags |= MNT_SYNC_UMOUNT;
disconnect = !IS_MNT_LOCKED_AND_LAZY(p); disconnect = !(((how & UMOUNT_CONNECTED) &&
mnt_has_parent(p) &&
(p->mnt_parent->mnt.mnt_flags & MNT_UMOUNT)) ||
IS_MNT_LOCKED_AND_LAZY(p));
pin_insert_group(&p->mnt_umount, &p->mnt_parent->mnt, pin_insert_group(&p->mnt_umount, &p->mnt_parent->mnt,
disconnect ? &unmounted : NULL); disconnect ? &unmounted : NULL);
...@@ -1529,7 +1533,7 @@ void __detach_mounts(struct dentry *dentry) ...@@ -1529,7 +1533,7 @@ void __detach_mounts(struct dentry *dentry)
umount_mnt(p); umount_mnt(p);
} }
} }
else umount_tree(mnt, 0); else umount_tree(mnt, UMOUNT_CONNECTED);
} }
unlock_mount_hash(); unlock_mount_hash();
put_mountpoint(mp); put_mountpoint(mp);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment