Re: [PATCH v2] nfs: fix ENXIO on O_CREAT open of existing symlink over NFSv3
Michael Nemanov <michael.nemanov-8Du6NiZp2BlWk0Htik3J/[email protected]>
| Newsgroups | gmane.linux.nfs |
|---|---|
| Message-ID | <[email protected]> |
On 08/08/2026 19:53, Trond Myklebust wrote:
> On Sat, 2026-08-08 at 12:34 -0400, Trond Myklebust wrote:
>> On Thu, 2026-08-06 at 13:13 +0000, Michael Nemanov wrote:
...
>>> diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
>>> index e9ce1883288c5..c3481d9c74334 100644
>>> --- a/fs/nfs/dir.c
>>> +++ b/fs/nfs/dir.c
>>> @@ -2317,6 +2317,13 @@ int nfs_atomic_open_v23(struct inode *dir,
>>> struct dentry *dentry,
>>> if (open_flags & O_CREAT) {
>>> error = nfs_do_create(dir, dentry, mode,
>>> open_flags);
>>> if (!error) {
>>> + /* With UNCHECKED mode, a server may
>>> return
>>> NFS3_OK for
>>> + * a pre-existing non-regular file (e.g. a
>>> symlink).
>>> + * Let the VFS handle it; calling
>>> finish_open() would
>>> + * hit no_open() and return -ENXIO.
>>> + */
>>> + if (d_inode(dentry) &&
>>> !S_ISREG(d_inode(dentry)->i_mode))
>>
>> Hmm... I'm changing the above to "if (!d_inode(dentry) ||
>> !S_ISREG(....))" so that we don't inadvertently try to open a
>> negative
>> dentry. That can happen with NFSv2 if we hit an existing directory
>> that
>> has been renamed on the server.
>
> Actually, "if (!d_is_reg(dentry))" is even better.
>
Agreed. Would you like a v3 with this fix?