lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <48d1f20b2fc1418080c96a1736f6249b@AcuMS.aculab.com>
Date:   Tue, 23 May 2023 13:50:01 +0000
From:   David Laight <David.Laight@...LAB.COM>
To:     'Jan Kara' <jack@...e.cz>, Ted Tso <tytso@....edu>
CC:     "linux-ext4@...r.kernel.org" <linux-ext4@...r.kernel.org>,
        "Darrick J. Wong" <djwong@...nel.org>,
        "stable@...r.kernel.org" <stable@...r.kernel.org>
Subject: RE: [PATCH] ext4: Fix possible corruption when moving a directory
 with RENAME_EXCHANGE

From: Jan Kara
> Sent: 23 May 2023 14:14
> 
> Commit 0813299c586b ("ext4: Fix possible corruption when moving a
> directory") forgot that handling of RENAME_EXCHANGE renames needs the
> protection of inode lock when changing directory parents for moved
> directories. Add proper locking for that case as well.
> 
> CC: stable@...r.kernel.org
> Fixes: 0813299c586b ("ext4: Fix possible corruption when moving a directory")
> Reported-by: "Darrick J. Wong" <djwong@...nel.org>
> Signed-off-by: Jan Kara <jack@...e.cz>
> ---
>  fs/ext4/namei.c | 23 +++++++++++++++++++++--
>  1 file changed, 21 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
> index 45b579805c95..b91abea1c781 100644
> --- a/fs/ext4/namei.c
> +++ b/fs/ext4/namei.c
> @@ -4083,10 +4083,25 @@ static int ext4_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
>  	if (retval)
>  		return retval;
> 
> +	/*
> +	 * We need to protect against old.inode and new.inode directory getting
> +	 * converted from inline directory format into a normal one. The lock
> +	 * ordering does not matter here as old and new are guaranteed to be
> +	 * incomparable in the directory hierarchy.
> +	 */
> +	if (S_ISDIR(old.inode->i_mode))
> +		inode_lock(old.inode);
> +	if (S_ISDIR(new.inode->i_mode))
> +		inode_lock_nested(new.inode, I_MUTEX_NONDIR2);
> +

What happens if there is another concurrent rename from new.inode
to old.inode?
That will try to acquire the locks in the other order.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ