Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 27 Apr 2018 12:50:17 +0000 (UTC)
From:      Rick Macklem <rmacklem@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r333060 - stable/11/sys/fs/nfsserver
Message-ID:  <201804271250.w3RCoHKu080396@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rmacklem
Date: Fri Apr 27 12:50:17 2018
New Revision: 333060
URL: https://svnweb.freebsd.org/changeset/base/333060

Log:
  MFC: r332790
  Fix OpenDowngrade for NFSv4.1 if a client sets the OPEN_SHARE_ACCESS_WANT* bits.
  
  The NFSv4.1 RFC specifies that the OPEN_SHARE_ACCESS_WANT bits can be set
  in the OpenDowngrade share_access argument and are basically ignored.
  I do not know of a extant NFSv4.1 client that does this, but this little
  patch fixes it just in case.
  It also changes the error from NFSERR_BADXDR to NFSERR_INVAL since the NFSv4.1
  RFC specifies this as the error to be returned if bogus bits are set.
  (The NFSv4.0 RFC didn't specify any error for this, so the error reply can
   be changed for NFSv4.0 as well.)
  Found by inspection while looking at a problem with OpenDowngrade reported
  for the ESXi 6.5 NFSv4.1 client.

Modified:
  stable/11/sys/fs/nfsserver/nfs_nfsdserv.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/fs/nfsserver/nfs_nfsdserv.c
==============================================================================
--- stable/11/sys/fs/nfsserver/nfs_nfsdserv.c	Fri Apr 27 12:44:20 2018	(r333059)
+++ stable/11/sys/fs/nfsserver/nfs_nfsdserv.c	Fri Apr 27 12:50:17 2018	(r333060)
@@ -3235,6 +3235,8 @@ nfsrvd_opendowngrade(struct nfsrv_descript *nd, __unus
 	tl += (NFSX_STATEIDOTHER / NFSX_UNSIGNED);
 	stp->ls_seq = fxdr_unsigned(u_int32_t, *tl++);
 	i = fxdr_unsigned(int, *tl++);
+	if ((nd->nd_flag & ND_NFSV41) != 0)
+		i &= ~NFSV4OPEN_WANTDELEGMASK;
 	switch (i) {
 	case NFSV4OPEN_ACCESSREAD:
 		stp->ls_flags = (NFSLCK_READACCESS | NFSLCK_DOWNGRADE);
@@ -3247,7 +3249,7 @@ nfsrvd_opendowngrade(struct nfsrv_descript *nd, __unus
 		    NFSLCK_DOWNGRADE);
 		break;
 	default:
-		nd->nd_repstat = NFSERR_BADXDR;
+		nd->nd_repstat = NFSERR_INVAL;
 	}
 	i = fxdr_unsigned(int, *tl);
 	switch (i) {
@@ -3263,7 +3265,7 @@ nfsrvd_opendowngrade(struct nfsrv_descript *nd, __unus
 		stp->ls_flags |= (NFSLCK_READDENY | NFSLCK_WRITEDENY);
 		break;
 	default:
-		nd->nd_repstat = NFSERR_BADXDR;
+		nd->nd_repstat = NFSERR_INVAL;
 	}
 
 	clientid.lval[0] = stp->ls_stateid.other[0];



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201804271250.w3RCoHKu080396>