Patch "mnt: Don't propagate unmounts to locked mounts" has been added to the 4.0-stable tree
Subsystems (2)
This is a note to let you know that I've just added the patch titled
mnt: Don't propagate unmounts to locked mounts
to the 4.0-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
mnt-don-t-propagate-unmounts-to-locked-mounts.patch
and it can be found in the queue-4.0 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
0c56fe31420ca599c90240315f7959bf1b4eb6ceMon Sep 17 00:00:00 2001
From: "Eric W. Biederman" <[email protected]>
Date: Mon, 5 Jan 2015 13:38:04 -0600
Subject: mnt: Don't propagate unmounts to locked mounts
From: "Eric W. Biederman" <[email protected]>
commit 0c56fe31420ca599c90240315f7959bf1b4eb6ce upstream.
If the first mount in shared subtree is locked don't unmount the shared subtree.
This is ensured by walking through the mounts parents before children and marking a mount as unmountable if it is not locked or it is locked but it's parent is marked.
This allows recursive mount detach to propagate through a set of mounts when unmounting them would not reveal what is under any locked mount.
--- fs/pnode.c | 32 +++++++++++++++++++++++++++++--- fs/pnode.h | 1 + 2 files changed, 30 insertions(+), 3 deletions(-)
fs/pnode.c +29 -3
@@ -382,6 +382,26 @@ void propagate_mount_unlock(struct mount }/* +* Mark all mounts that the MNT_LOCKED logic will allow to be unmounted. +*/ +static void mark_umount_candidates (struct mount *mnt) +{ +struct mount *parent = mnt->mnt_parent; +struct mount *m; + +BUG_ON (parent == mnt); + +for (m =propagation_next (parent, parent); m; + m =propagation_next (m, parent)) { +struct mount *child =__lookup_mnt_last (&m->mnt, + mnt->mnt_mountpoint); +if (child && (!IS_MNT_LOCKED (child) ||IS_MNT_MARKED (m))) { +SET_MNT_MARK (child); + } + } +} + +/* * NOTE: unmounting 'mnt' naturally propagates to all other mounts its * parent propagates to. */
@@ -398,10 +418,13 @@ static void __propagate_umount(struct mostruct mount *child =__lookup_mnt_last (&m->mnt, mnt->mnt_mountpoint);/* -* umount the child only if the child has no -* other children +* umount the child only if the child has no children +* and the child is marked safe to unmount. */ -if (child &&list_empty (&child->mnt_mounts)) { +if (!child || !IS_MNT_MARKED (child)) +continue ; +CLEAR_MNT_MARK (child); +if (list_empty (&child->mnt_mounts)) {list_del_init (&child->mnt_child); child->mnt.mnt_flags |=MNT_UMOUNT ;list_move_tail (&child->mnt_list, &mnt->mnt_list);
@@ -420,6 +443,9 @@ int propagate_umount(struct list_head *l {struct mount *mnt; +list_for_each_entry_reverse (mnt, list, mnt_list) +mark_umount_candidates (mnt); +list_for_each_entry (mnt, list, mnt_list)__propagate_umount (mnt);return 0 ;
fs/pnode.h +1 -0
@@ -19,6 +19,7 @@#define IS_MNT_MARKED (m) ((m)->mnt.mnt_flags & MNT_MARKED)#define SET_MNT_MARK (m) ((m)->mnt.mnt_flags |= MNT_MARKED)#define CLEAR_MNT_MARK (m) ((m)->mnt.mnt_flags &= ~MNT_MARKED) +#define IS_MNT_LOCKED (m) ((m)->mnt.mnt_flags & MNT_LOCKED)#define CL_EXPIRE 0x01#define CL_SLAVE 0x02
Patches currently in stable-queue which might be from [email protected] are
queue-4.0/mnt-don-t-propagate-umounts-in-__detach_mounts.patch queue-4.0/mnt-add-mnt_umount-flag.patch queue-4.0/mnt-honor-mnt_locked-when-detaching-mounts.patch queue-4.0/mnt-delay-removal-from-the-mount-hash.patch queue-4.0/mnt-on-an-unmount-propagate-clearing-of-mnt_locked.patch queue-4.0/mnt-don-t-propagate-unmounts-to-locked-mounts.patch queue-4.0/mnt-factor-out-unhash_mnt-from-detach_mnt-and-umount_tree.patch queue-4.0/mnt-factor-umount_mnt-from-umount_tree.patch queue-4.0/mnt-fix-the-error-check-in-__detach_mounts.patch queue-4.0/mnt-update-detach_mounts-to-leave-mounts-connected.patch queue-4.0/mnt-improve-the-umount_tree-flags.patch queue-4.0/mnt-in-umount_tree-reuse-mnt_list-instead-of-mnt_hash.patch