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: <20201012093304.aevqpvq5sotzamrq@work>
Date:   Mon, 12 Oct 2020 11:33:04 +0200
From:   Lukas Czerner <lczerner@...hat.com>
To:     xiakaixu1987@...il.com
Cc:     linux-ext4@...r.kernel.org, tytso@....edu,
        adilger.kernel@...ger.ca, Kaixu Xia <kaixuxia@...cent.com>
Subject: Re: [RFC PATCH] ext4: use the normal helper to get the actual inode

On Sat, Oct 10, 2020 at 04:10:16PM +0800, xiakaixu1987@...il.com wrote:
> From: Kaixu Xia <kaixuxia@...cent.com>
> 
> Here we use the READ_ONCE to fix race conditions in ->d_compare() and
> ->d_hash() when they are called in RCU-walk mode, seems we can use
> the normal helper d_inode_rcu() to get the actual inode.

Looks good to me.
Thanks!

Reviewed-by: Lukas Czerner <lczerner@...hat.com>

> 
> Signed-off-by: Kaixu Xia <kaixuxia@...cent.com>
> ---
>  fs/ext4/dir.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/ext4/dir.c b/fs/ext4/dir.c
> index 1d82336b1cd4..3bf6cb8e55f6 100644
> --- a/fs/ext4/dir.c
> +++ b/fs/ext4/dir.c
> @@ -674,7 +674,7 @@ static int ext4_d_compare(const struct dentry *dentry, unsigned int len,
>  {
>  	struct qstr qstr = {.name = str, .len = len };
>  	const struct dentry *parent = READ_ONCE(dentry->d_parent);
> -	const struct inode *inode = READ_ONCE(parent->d_inode);
> +	const struct inode *inode = d_inode_rcu(parent);
>  	char strbuf[DNAME_INLINE_LEN];
>  
>  	if (!inode || !IS_CASEFOLDED(inode) ||
> @@ -706,7 +706,7 @@ static int ext4_d_hash(const struct dentry *dentry, struct qstr *str)
>  {
>  	const struct ext4_sb_info *sbi = EXT4_SB(dentry->d_sb);
>  	const struct unicode_map *um = sbi->s_encoding;
> -	const struct inode *inode = READ_ONCE(dentry->d_inode);
> +	const struct inode *inode = d_inode_rcu(dentry);
>  	unsigned char *norm;
>  	int len, ret = 0;
>  
> -- 
> 2.20.0
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ