linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Al Viro <viro@zeniv.linux.org.uk>
To: zhengbin <zhengbin13@huawei.com>
Cc: jack@suse.cz, akpm@linux-foundation.org,
	linux-fsdevel@vger.kernel.org, yi.zhang@huawei.com,
	houtao1@huawei.com, renxudong1@huawei.com
Subject: Re: [PATCH] fs: need to ensure that dentry is initialized before it is added to parent dentry
Date: Tue, 10 Sep 2019 22:56:44 +0100	[thread overview]
Message-ID: <20190910215644.GI1131@ZenIV.linux.org.uk> (raw)
In-Reply-To: <1568135137-106264-1-git-send-email-zhengbin13@huawei.com>

On Wed, Sep 11, 2019 at 01:05:37AM +0800, zhengbin wrote:
> diff --git a/fs/dcache.c b/fs/dcache.c
> index e88cf05..0a07671 100644
> --- a/fs/dcache.c
> +++ b/fs/dcache.c
> @@ -1767,6 +1767,16 @@ struct dentry *d_alloc(struct dentry * parent, const struct qstr *name)
>  	struct dentry *dentry = __d_alloc(parent->d_sb, name);
>  	if (!dentry)
>  		return NULL;
> +
> +	/*
> +	 * need to ensure that dentry->d_child.next is initialized
> +	 * (__d_alloc->INIT_LIST_HEAD) before dentry is added to
> +	 * parent->d_subdirs, Otherwise in next_positive(do not have
> +	 * spin_lock), we may visit uninitialized value because of cpu
> +	 * run optimization(first add dentry to parent->d_subdirs).
> +	 */
> +	smp_wmb();
> +
>  	spin_lock(&parent->d_lock);
>  	/*
>  	 * don't need child lock because it is not subject
> --
> 2.7.4

Unfortunately, that's not all - see the reply upthread ;-/

      reply	other threads:[~2019-09-10 21:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-10 17:05 [PATCH] fs: need to ensure that dentry is initialized before it is added to parent dentry zhengbin
2019-09-10 21:56 ` Al Viro [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190910215644.GI1131@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=akpm@linux-foundation.org \
    --cc=houtao1@huawei.com \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=renxudong1@huawei.com \
    --cc=yi.zhang@huawei.com \
    --cc=zhengbin13@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).