Re: _nfs4_open_and_get_state() should check d_splice_alias() return for error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 2025-09-07 at 13:56 -0400, rtm@xxxxxxxxxxxxx wrote:
> [You don't often get email from rtm@xxxxxxxxxxxxx. 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@xxxxxxxxxx, trond.myklebust@xxxxxxxxxxxxxxx




[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux