nfsd: fix crash on LOCKT on reexported NFSv3
authorJ. Bruce Fields <bfields@redhat.com>
Wed, 25 Aug 2021 02:36:03 +0000 (22:36 -0400)
committerChuck Lever <chuck.lever@oracle.com>
Thu, 26 Aug 2021 19:32:29 +0000 (15:32 -0400)
Unlike other filesystems, NFSv3 tries to use fl_file in the GETLK case.

Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfsd/nfs4state.c

index 1b6a7f48982ed411e7921ee2c1f0acebdce904fa..4b6d60b46b0ace468a6621bfcdbf68faeffc0dbe 100644 (file)
@@ -7043,8 +7043,7 @@ out:
 /*
  * The NFSv4 spec allows a client to do a LOCKT without holding an OPEN,
  * so we do a temporary open here just to get an open file to pass to
- * vfs_test_lock.  (Arguably perhaps test_lock should be done with an
- * inode operation.)
+ * vfs_test_lock.
  */
 static __be32 nfsd_test_lock(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file_lock *lock)
 {
@@ -7059,7 +7058,9 @@ static __be32 nfsd_test_lock(struct svc_rqst *rqstp, struct svc_fh *fhp, struct
                                                        NFSD_MAY_READ));
        if (err)
                goto out;
+       lock->fl_file = nf->nf_file;
        err = nfserrno(vfs_test_lock(nf->nf_file, lock));
+       lock->fl_file = NULL;
 out:
        fh_unlock(fhp);
        nfsd_file_put(nf);