Skip to content

Commit df582d4

Browse files
aulanovgregkh
authored andcommitted
namespace: update event counter when umounting a deleted dentry
commit e06b933e6ded42384164d28a2060b7f89243b895 upstream. - m_start() in fs/namespace.c expects that ns->event is incremented each time a mount added or removed from ns->list. - umount_tree() removes items from the list but does not increment event counter, expecting that it's done before the function is called. - There are some codepaths that call umount_tree() without updating "event" counter. e.g. from __detach_mounts(). - When this happens m_start may reuse a cached mount structure that no longer belongs to ns->list (i.e. use after free which usually leads to infinite loop). This change fixes the above problem by incrementing global event counter before invoking umount_tree(). Change-Id: I622c8e84dcb9fb63542372c5dbf0178ee86bb589 Signed-off-by: Andrey Ulanov <andreyu@google.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 7d9f345 commit df582d4

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

fs/namespace.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1562,6 +1562,7 @@ void __detach_mounts(struct dentry *dentry)
15621562
goto out_unlock;
15631563

15641564
lock_mount_hash();
1565+
event++;
15651566
while (!hlist_empty(&mp->m_list)) {
15661567
mnt = hlist_entry(mp->m_list.first, struct mount, mnt_mp_list);
15671568
if (mnt->mnt.mnt_flags & MNT_UMOUNT) {

0 commit comments

Comments
 (0)