From: Chuck Lever III <chuck.lever@oracle.com>
To: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: Dave Chinner <david@fromorbit.com>,
Jeff Layton <jlayton@kernel.org>,
Linux NFS Mailing List <linux-nfs@vger.kernel.org>,
linux-fsdevel <linux-fsdevel@vger.kernel.org>,
Frank van der Linden <fvdl@google.com>
Subject: Re: [PATCH] nfsd: don't use GFP_KERNEL from nfsd_getxattr()/nfsd_listxattr()
Date: Thu, 20 Apr 2023 14:41:08 +0000 [thread overview]
Message-ID: <DB84BC71-AF42-4682-9D55-AFD907FF0874@oracle.com> (raw)
In-Reply-To: <b6256ab2-35f8-e5e5-59f5-10ba95a396fb@I-love.SAKURA.ne.jp>
> On Apr 20, 2023, at 10:05 AM, Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> wrote:
>
> On 2023/04/20 22:41, Chuck Lever III wrote:
>>> That said, nfsd_listxattr() does:
>>>
>>> dentry = fhp->fh_dentry;
>>> inode = d_inode(dentry);
>>> *lenp = 0;
>>>
>>> inode_lock_shared(inode);
>>>
>>> len = vfs_listxattr(dentry, NULL, 0);
>>>
>>> Given that a dentry pointing to an inode *must* hold an active
>>> reference to that inode, I don't see how it is possible this code
>>> path could be using an unreferenced inode.
>>>
>>> nfsd_getxattr() has a similar code fragment to obtain the inode as
>>> well, so same goes for that...
>>
>> Dave, thanks for handling the due diligence! I was not 100% sure
>> about code that handles xattrs rather than the primary byte stream
>> of a file.
>>
>> Tetsuo, you can send a v2, or just let me know and I will make
>> a patch to correct the GFP flags.
>
> So, this inode_lock_shared() was there with an intention to make sure that
> xattr of inode inside the exported filesystem does not change between
> vfs_listxattr(dentry, NULL, 0) and vfs_listxattr(dentry, buf, len),
> wasn't it?
>
> Then, we can remove this inode_lock_shared() by adding a "goto retry;"
> when vfs_listxattr(dentry, buf, len) failed with out of buffer size
> due to a race condition, can't we?
>
> I leave replacing inode lock with retry path and removing GFP_NOFS to you.
Jeff similarly mentioned to me the tactic of simply retrying if the
retrieved listxattr contents exceed the size of the buffer. I think
I'd like to leave that for another time, as it seems to be safe to
use GFP_KERNEL with the inode lock held in this case.
--
Chuck Lever
next prev parent reply other threads:[~2023-04-20 14:41 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <72bf692e-bb6b-c1f2-d1ba-3205ab649b43@I-love.SAKURA.ne.jp>
[not found] ` <4BC7955B-40E4-4A43-B2D1-2E9302E84337@oracle.com>
[not found] ` <b014047a-4a70-b38f-c5bb-01bc3c53d6f2@I-love.SAKURA.ne.jp>
[not found] ` <aee35d52ab19e7e95f69742be8329764db72cbf8.camel@kernel.org>
[not found] ` <c310695e-4279-b1a7-5c2a-2771cc19aa66@I-love.SAKURA.ne.jp>
2023-04-16 11:51 ` [PATCH] nfsd: don't use GFP_KERNEL from nfsd_getxattr()/nfsd_listxattr() Jeff Layton
2023-04-16 16:20 ` Chuck Lever III
2023-04-16 23:37 ` Dave Chinner
2023-04-17 22:25 ` Frank van der Linden
2023-04-17 23:07 ` Frank van der Linden
2023-04-19 13:51 ` Chuck Lever III
2023-04-19 23:32 ` Dave Chinner
2023-04-20 13:41 ` Chuck Lever III
2023-04-20 14:05 ` Tetsuo Handa
2023-04-20 14:41 ` Chuck Lever III [this message]
2023-04-20 15:20 ` Jeff Layton
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=DB84BC71-AF42-4682-9D55-AFD907FF0874@oracle.com \
--to=chuck.lever@oracle.com \
--cc=david@fromorbit.com \
--cc=fvdl@google.com \
--cc=jlayton@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=penguin-kernel@I-love.SAKURA.ne.jp \
/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