Re: [PATCH 18/52] do_move_mount(): trim local variables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Aug 25, 2025 at 05:43:21AM +0100, Al Viro wrote:
> Both 'parent' and 'ns' are used at most once, no point precalculating those...
> 
> Signed-off-by: Al Viro <viro@xxxxxxxxxxxxxxxxxx>
> ---

Reviewed-by: Christian Brauner <brauner@xxxxxxxxxx>

>  fs/namespace.c | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/fs/namespace.c b/fs/namespace.c
> index a8b586e635d8..1a076aac5d73 100644
> --- a/fs/namespace.c
> +++ b/fs/namespace.c
> @@ -3564,10 +3564,8 @@ static inline bool may_use_mount(struct mount *mnt)
>  static int do_move_mount(struct path *old_path,
>  			 struct path *new_path, enum mnt_tree_flags_t flags)
>  {
> -	struct mnt_namespace *ns;
>  	struct mount *p;
>  	struct mount *old;
> -	struct mount *parent;
>  	struct pinned_mountpoint mp;
>  	int err;
>  	bool beneath = flags & MNT_TREE_BENEATH;
> @@ -3578,8 +3576,6 @@ static int do_move_mount(struct path *old_path,
>  
>  	old = real_mount(old_path->mnt);
>  	p = real_mount(new_path->mnt);
> -	parent = old->mnt_parent;
> -	ns = old->mnt_ns;
>  
>  	err = -EINVAL;
>  
> @@ -3588,12 +3584,12 @@ static int do_move_mount(struct path *old_path,
>  		/* ... it should be detachable from parent */
>  		if (!mnt_has_parent(old) || IS_MNT_LOCKED(old))
>  			goto out;
> +		/* ... which should not be shared */
> +		if (IS_MNT_SHARED(old->mnt_parent))
> +			goto out;
>  		/* ... and the target should be in our namespace */
>  		if (!check_mnt(p))
>  			goto out;
> -		/* parent of the source should not be shared */
> -		if (IS_MNT_SHARED(parent))
> -			goto out;
>  	} else {
>  		/*
>  		 * otherwise the source must be the root of some anon namespace.
> @@ -3605,7 +3601,7 @@ static int do_move_mount(struct path *old_path,
>  		 * subsequent checks would've rejected that, but they lose
>  		 * some corner cases if we check it early.
>  		 */
> -		if (ns == p->mnt_ns)
> +		if (old->mnt_ns == p->mnt_ns)
>  			goto out;
>  		/*
>  		 * Target should be either in our namespace or in an acceptable
> -- 
> 2.47.2
> 




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux