Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 81c379f5 authored by Andrey Ulanov's avatar Andrey Ulanov Committed by Sasha Levin
Browse files

namespace: update event counter when umounting a deleted dentry



[ Upstream commit e06b933e6ded42384164d28a2060b7f89243b895 ]

- 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
Cc: stable@vger.kernel.org
Signed-off-by: default avatarAndrey Ulanov <andreyu@google.com>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: default avatarSasha Levin <sasha.levin@oracle.com>
parent 35bec119
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1494,6 +1494,7 @@ void __detach_mounts(struct dentry *dentry)
		goto out_unlock;

	lock_mount_hash();
	event++;
	while (!hlist_empty(&mp->m_list)) {
		mnt = hlist_entry(mp->m_list.first, struct mount, mnt_mp_list);
		umount_tree(mnt, 0);