linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Chuck Lever <chuck.lever@oracle.com>
To: yangerkun <yangerkun@huaweicloud.com>
Cc: cel@kernel.org, Hugh Dickens <hughd@google.com>,
	Christian Brauner <brauner@kernel.org>,
	Al Viro <viro@zeniv.linux.org.uk>,
	linux-fsdevel@vger.kernel.org, linux-mm@kvack.org,
	yukuai3@huawei.com
Subject: Re: [RFC PATCH v2 2/5] libfs: Check dentry before locking in simple_offset_empty()
Date: Sat, 30 Nov 2024 12:03:02 -0500	[thread overview]
Message-ID: <Z0tFRkq9kxREW6vg@tissot.1015granger.net> (raw)
In-Reply-To: <234243c3-7368-4824-6c1a-ff9eee4e10ba@huaweicloud.com>

On Fri, Nov 29, 2024 at 04:17:56PM +0800, yangerkun wrote:
> 
> 
> 在 2024/11/27 22:36, Chuck Lever 写道:
> > On Wed, Nov 27, 2024 at 11:09:11AM +0800, yangerkun wrote:
> > > Thank you very much for your efforts on this issue!
> > > 
> > > 在 2024/11/26 23:54, cel@kernel.org 写道:
> > > > From: Chuck Lever <chuck.lever@oracle.com>
> > > > 
> > > > Defensive change: Don't try to lock a dentry unless it is positive.
> > > > Trying to lock a negative entry will generate a refcount underflow.
> > > 
> > > Which member trigger this underflow?
> > 
> > dput() encounters a dentry refcount underflow because a negative
> > dentry's refcount is already zero.
> 
> OK, so you mean dentry->d_lockref here.
> 
> But I cannot see why we can trigger this, if it is, it's actually a bug...
> 
> Can you give a more detail why can trigger this?

I think it is possible for the mtree lookup in simple_offset_empty()
to return a pointer to a negative dentry, perhaps due to a race.
There is nothing explicit that prevents a dentry from going negative
while it is still stored in the mtree, although that condition would
be quite brief. So, best to harden the "is dentry positive" check
there so that it acts like other dentry locking code in fs/libfs.c.

Perhaps labeling this patch as a "clean up" would be more clear. I
will remove the "Fixes:" tag -- it does not fix a bug in the current
code.


-- 
Chuck Lever


  reply	other threads:[~2024-11-30 17:08 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-26 15:54 [RFC PATCH v2 0/5] Improve simple directory offset wrap behavior cel
2024-11-26 15:54 ` [RFC PATCH v2 1/5] libfs: Return ENOSPC when the directory offset range is exhausted cel
2024-11-27  3:11   ` yangerkun
2024-11-26 15:54 ` [RFC PATCH v2 2/5] libfs: Check dentry before locking in simple_offset_empty() cel
2024-11-27  3:09   ` yangerkun
2024-11-27 14:36     ` Chuck Lever
2024-11-29  8:17       ` yangerkun
2024-11-30 17:03         ` Chuck Lever [this message]
2024-11-26 15:54 ` [RFC PATCH v2 3/5] Revert "libfs: fix infinite directory reads for offset dir" cel
2024-11-26 15:54 ` [RFC PATCH v2 4/5] libfs: Refactor end-of-directory detection for simple_offset directories cel
2024-11-26 15:54 ` [RFC PATCH v2 5/5] libfs: Refactor offset_iterate_dir() cel
2024-11-26 16:24 ` [RFC PATCH v2 0/5] Improve simple directory offset wrap behavior Christoph Hellwig
2024-11-26 16:59   ` Chuck Lever III

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=Z0tFRkq9kxREW6vg@tissot.1015granger.net \
    --to=chuck.lever@oracle.com \
    --cc=brauner@kernel.org \
    --cc=cel@kernel.org \
    --cc=hughd@google.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=yangerkun@huaweicloud.com \
    --cc=yukuai3@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