knfsd: LOOKUP can return an illegal error value
authorTrond Myklebust <trond.myklebust@hammerspace.com>
Mon, 6 May 2024 16:30:04 +0000 (12:30 -0400)
committerChuck Lever <chuck.lever@oracle.com>
Mon, 6 May 2024 16:47:24 +0000 (12:47 -0400)
The 'NFS error' NFSERR_OPNOTSUPP is not described by any of the official
NFS related RFCs, but appears to have snuck into some older .x files for
NFSv2.
Either way, it is not in RFC1094, RFC1813 or any of the NFSv4 RFCs, so
should not be returned by the knfsd server, and particularly not by the
"LOOKUP" operation.

Instead, let's return NFSERR_STALE, which is more appropriate if the
filesystem encodes the filehandle as FILEID_INVALID.

Cc: stable@vger.kernel.org
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfsd/nfsfh.c

index 40fecf7b224f2fab00747c1b385a37f1bbd8923b..0b75305fb5f53d513434397dd5d02eb496f3c470 100644 (file)
@@ -573,7 +573,7 @@ fh_compose(struct svc_fh *fhp, struct svc_export *exp, struct dentry *dentry,
                _fh_update(fhp, exp, dentry);
        if (fhp->fh_handle.fh_fileid_type == FILEID_INVALID) {
                fh_put(fhp);
-               return nfserr_opnotsupp;
+               return nfserr_stale;
        }
 
        return 0;
@@ -599,7 +599,7 @@ fh_update(struct svc_fh *fhp)
 
        _fh_update(fhp, fhp->fh_export, dentry);
        if (fhp->fh_handle.fh_fileid_type == FILEID_INVALID)
-               return nfserr_opnotsupp;
+               return nfserr_stale;
        return 0;
 out_bad:
        printk(KERN_ERR "fh_update: fh not verified!\n");