]> Gentwo Git Trees - linux/.git/commit
do_move_mount(): deal with the checks on old_path early
authorAl Viro <viro@zeniv.linux.org.uk>
Wed, 20 Aug 2025 18:50:09 +0000 (14:50 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Tue, 2 Sep 2025 23:35:58 +0000 (19:35 -0400)
commitc1ab70be88f3135cdb931673aae2afc5d6624b62
tree3b98f801ff1347820f921b5b93f0f8a9dec4f336
parenta666bbcf7e9c5e0524b60677a0a43a4cddedcefd
do_move_mount(): deal with the checks on old_path early

1) checking that location we want to move does point to root of some mount
can be done before anything else; that property is not going to change
and having it already verified simplifies the analysis.

2) checking the type agreement between what we are trying to move and what
we are trying to move it onto also belongs in the very beginning -
do_lock_mount() might end up switching new_path to something that overmounts
the original location, but... the same type agreement applies to overmounts,
so we could just as well check against the original location.

3) since we know that old_path->dentry is the root of old_path->mnt, there's
no point bothering with path_is_overmounted() in can_move_mount_beneath();
it's simply a check for the mount we are trying to move having non-NULL
->overmount.  And with that, we can switch can_move_mount_beneath() to
taking old instead of old_path, leaving no uses of old_path past the original
checks.

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