]> 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:40:18 +0000 (14:40 +0200)
commit9b0915e72b3cf52474dcee0b24a2f99d93e604a3
treebcdf0e5065a1a99c90385f7d7a02fb25a8b497ad
parenta58442f75be49c2be28a6eba387f5dbb1b11395c
__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