Linux NFS development
 help / color / mirror / Atom feed
From: Trond Myklebust <trondmy@kernel.org>
To: rtm@csail.mit.edu, Anna Schumaker <anna@kernel.org>
Cc: linux-nfs@vger.kernel.org
Subject: Re: _nfs4_open_and_get_state() should check d_splice_alias() return for error
Date: Sun, 07 Sep 2025 17:08:45 -0400	[thread overview]
Message-ID: <8fcebbadae40f048802c3725a231667b8ac25550.camel@kernel.org> (raw)
In-Reply-To: <23296.1757267766@localhost>

On Sun, 2025-09-07 at 13:56 -0400, rtm@csail.mit.edu wrote:
> [You don't often get email from rtm@csail.mit.edu. Learn why this is
> important at https://aka.ms/LearnAboutSenderIdentification ]
> 
> In this code in fs/nfs/nfs4proc.c _nfs_open_and_get_state():
> 
>         dentry = opendata->dentry;
>         if (d_really_is_negative(dentry)) {
>                 struct dentry *alias;
>                 d_drop(dentry);
>                 alias = d_splice_alias(igrab(state->inode), dentry);
>                 /* d_splice_alias() can't fail here - it's a non-
> directory */
>                 if (alias) {
>                         dput(ctx->dentry);
>                         ctx->dentry = dentry = alias;
>                 }
> 
> d_splice_alias() can fail, returning ERR_PTR(-ELOOP). Then this call
> later on causes a crash:

No. It can't return ELOOP.

The reason why it can't is that OP_OPEN is not allowed to return
NFS4_OK for anything other than a regular file. Hence the server cannot
return a directory, or anything which could otherwise be an ancestor to
'dentry'. Hence the comment above...


IOW: Your implementation of OP_OPEN is broken because it only returns
either NFS4ERR_NOENT or NFS4_OK, whereas in this case it should clearly
have return NFS4ERR_ISDIR.

-- 
Trond Myklebust
Linux NFS client maintainer, Hammerspace
trondmy@kernel.org, trond.myklebust@hammerspace.com

      reply	other threads:[~2025-09-07 21:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-07 17:56 _nfs4_open_and_get_state() should check d_splice_alias() return for error rtm
2025-09-07 21:08 ` Trond Myklebust [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=8fcebbadae40f048802c3725a231667b8ac25550.camel@kernel.org \
    --to=trondmy@kernel.org \
    --cc=anna@kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=rtm@csail.mit.edu \
    /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