[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200124051601.GB832@sol.localdomain>
Date: Thu, 23 Jan 2020 21:16:01 -0800
From: Eric Biggers <ebiggers@...nel.org>
To: Gao Xiang <hsiangkao@....com>
Cc: linux-ext4@...r.kernel.org, linux-fsdevel@...r.kernel.org,
linux-f2fs-devel@...ts.sourceforge.net,
Alexander Viro <viro@...iv.linux.org.uk>,
Daniel Rosenberg <drosen@...gle.com>,
Gabriel Krisman Bertazi <krisman@...labora.com>
Subject: Re: [PATCH] ext4: fix race conditions in ->d_compare() and ->d_hash()
On Fri, Jan 24, 2020 at 01:04:25PM +0800, Gao Xiang wrote:
> > diff --git a/fs/ext4/dir.c b/fs/ext4/dir.c
> > index 8964778aabefb..0129d14629881 100644
> > --- a/fs/ext4/dir.c
> > +++ b/fs/ext4/dir.c
> > @@ -671,9 +671,11 @@ static int ext4_d_compare(const struct dentry *dentry, unsigned int len,
> > const char *str, const struct qstr *name)
> > {
> > struct qstr qstr = {.name = str, .len = len };
> > - struct inode *inode = dentry->d_parent->d_inode;
> > + const struct dentry *parent = READ_ONCE(dentry->d_parent);
>
> I'm not sure if we really need READ_ONCE d_parent here (p.s. d_parent
> won't be NULL anyway), and d_seq will guard all its validity. If I'm
> wrong, correct me kindly...
>
> Otherwise, it looks good to me...
> Reviewed-by: Gao Xiang <gaoxiang25@...wei.com>
>
While d_parent can't be set to NULL, it can still be changed concurrently.
So we need READ_ONCE() to ensure that a consistent value is used.
- Eric
Powered by blists - more mailing lists