]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
__legitimize_mnt(): check for MNT_SYNC_UMOUNT should be under mount_lock
authorAl Viro <viro@zeniv.linux.org.uk>
Sun, 27 Apr 2025 19:41:51 +0000 (15:41 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 4 Jun 2025 12:38:05 +0000 (14:38 +0200)
commitf6d45fd92f62845cbd1eb5128fd8f0ed7d0c5a42
treeabb17a65fb83d7917f687aa9f616aa58861e8fe6
parent769dd92ef97e454778eb58524ad081e4e46bc339
__legitimize_mnt(): check for MNT_SYNC_UMOUNT should be under mount_lock

[ Upstream commit 250cf3693060a5f803c5f1ddc082bb06b16112a9 ]

... or we risk stealing final mntput from sync umount - raising mnt_count
after umount(2) has verified that victim is not busy, but before it
has set MNT_SYNC_UMOUNT; in that case __legitimize_mnt() doesn't see
that it's safe to quietly undo mnt_count increment and leaves dropping
the reference to caller, where it'll be a full-blown mntput().

Check under mount_lock is needed; leaving the current one done before
taking that makes no sense - it's nowhere near common enough to bother
with.

Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/namespace.c