Author: rmacklem
Date: Fri Aug 25 22:44:55 2017
New Revision: 322908
URL: https://svnweb.freebsd.org/changeset/base/322908

Log:
  MFC: r321675
  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.

Modified:
  stable/11/sys/fs/nfsclient/nfs_clrpcops.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/fs/nfsclient/nfs_clrpcops.c
==============================================================================
--- stable/11/sys/fs/nfsclient/nfs_clrpcops.c   Fri Aug 25 22:39:49 2017        
(r322907)
+++ stable/11/sys/fs/nfsclient/nfs_clrpcops.c   Fri Aug 25 22:44:55 2017        
(r322908)
@@ -6633,9 +6633,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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to