Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 19 Apr 2018 20:30:33 +0000 (UTC)
From:      Rick Macklem <rmacklem@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r332790 - head/sys/fs/nfsserver
Message-ID:  <201804192030.w3JKUXGD014807@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rmacklem
Date: Thu Apr 19 20:30:33 2018
New Revision: 332790
URL: https://svnweb.freebsd.org/changeset/base/332790

Log:
  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.
  
  Reported by:	andreas.nagy@frequentis.com
  PR:		227214
  MFC after:	1 week

Modified:
  head/sys/fs/nfsserver/nfs_nfsdserv.c

Modified: head/sys/fs/nfsserver/nfs_nfsdserv.c
==============================================================================
--- head/sys/fs/nfsserver/nfs_nfsdserv.c	Thu Apr 19 20:25:19 2018	(r332789)
+++ head/sys/fs/nfsserver/nfs_nfsdserv.c	Thu Apr 19 20:30:33 2018	(r332790)
@@ -3237,6 +3237,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);
@@ -3249,7 +3251,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) {
@@ -3265,7 +3267,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?201804192030.w3JKUXGD014807>