Author: rmacklem
Date: Sat Jul 29 02:25:49 2017
New Revision: 321675
URL: https://svnweb.freebsd.org/changeset/base/321675

Log:
  Fix possible crash for the NFSv4.1 pNFS client.
  
  If the nfsrpc_createlayoutrpc() call in nfsrpc_getcreatelayout() fails,
  the code used nfhpp when it might be set NULL. This patch checks for
  the error cases (laystat != 0) and avoids using nfhpp for the failure case.
  This would only affect NFSv4.1 mounts with the "pnfs" option.
  Found while testing the "umount -N" patch not yet in head.
  
  MFC after:    2 weeks

Modified:
  head/sys/fs/nfsclient/nfs_clrpcops.c

Modified: head/sys/fs/nfsclient/nfs_clrpcops.c
==============================================================================
--- head/sys/fs/nfsclient/nfs_clrpcops.c        Fri Jul 28 23:56:07 2017        
(r321674)
+++ head/sys/fs/nfsclient/nfs_clrpcops.c        Sat Jul 29 02:25:49 2017        
(r321675)
@@ -6643,9 +6643,14 @@ nfsrpc_getcreatelayout(vnode_t dvp, char *name, int na
        NFSCL_DEBUG(4, "aft nfsrpc_createlayoutrpc laystat=%d err=%d\n",
            laystat, error);
        lyp = NULL;
-       nfhp = *nfhpp;
-       laystat = nfsrpc_layoutgetres(nmp, dvp, nfhp->nfh_fh, nfhp->nfh_len,
-           &stateid, retonclose, NULL, &lyp, &flh, laystat, NULL, cred, p);
+       if (laystat == 0) {
+               nfhp = *nfhpp;
+               laystat = nfsrpc_layoutgetres(nmp, dvp, nfhp->nfh_fh,
+                   nfhp->nfh_len, &stateid, retonclose, NULL, &lyp, &flh,
+                   laystat, NULL, cred, p);
+       } else
+               laystat = nfsrpc_layoutgetres(nmp, dvp, NULL, 0, &stateid,
+                   retonclose, NULL, &lyp, &flh, laystat, NULL, cred, p);
        if (laystat == 0)
                nfscl_rellayout(lyp, 0);
        return (error);
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to