From owner-svn-src-all@freebsd.org Tue Sep 3 14:07:59 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5E00EDD4FB; Tue, 3 Sep 2019 14:07:07 +0000 (UTC) (envelope-from yuripv@freebsd.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2610:1c1:1:6074::16:84]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "freefall.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46N80B6jh4z4QFY; Tue, 3 Sep 2019 14:07:06 +0000 (UTC) (envelope-from yuripv@freebsd.org) Received: by freefall.freebsd.org (Postfix, from userid 1452) id 52B711B0CB; Tue, 3 Sep 2019 14:06:28 +0000 (UTC) X-Original-To: yuripv@localmail.freebsd.org Delivered-To: yuripv@localmail.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client CN "mx1.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by freefall.freebsd.org (Postfix) with ESMTPS id 75DAD11916; Fri, 19 Apr 2019 03:36:27 +0000 (UTC) (envelope-from owner-src-committers@freebsd.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2610:1c1:1:6074::16:84]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "freefall.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 2466E8B92A; Fri, 19 Apr 2019 03:36:27 +0000 (UTC) (envelope-from owner-src-committers@freebsd.org) Received: by freefall.freebsd.org (Postfix, from userid 538) id 116CD11914; Fri, 19 Apr 2019 03:36:27 +0000 (UTC) Delivered-To: src-committers@localmail.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client CN "mx1.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by freefall.freebsd.org (Postfix) with ESMTPS id 177E211912 for ; Fri, 19 Apr 2019 03:36:24 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C10B88B928; Fri, 19 Apr 2019 03:36:23 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8F6C228AB0; Fri, 19 Apr 2019 03:36:23 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x3J3aNLt087781; Fri, 19 Apr 2019 03:36:23 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x3J3aMUg087776; Fri, 19 Apr 2019 03:36:22 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201904190336.x3J3aMUg087776@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r346365 - in head/sys/fs: nfs nfsserver X-SVN-Group: head X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: in head/sys/fs: nfs nfsserver X-SVN-Commit-Revision: 346365 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk X-Loop: FreeBSD.org Sender: owner-src-committers@freebsd.org X-Rspamd-Queue-Id: 2466E8B92A X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[freebsd.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.96)[-0.965,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] Status: O X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Date: Tue, 03 Sep 2019 14:07:59 -0000 X-Original-Date: Fri, 19 Apr 2019 03:36:22 +0000 (UTC) X-List-Received-Date: Tue, 03 Sep 2019 14:07:59 -0000 Author: rmacklem Date: Fri Apr 19 03:36:22 2019 New Revision: 346365 URL: https://svnweb.freebsd.org/changeset/base/346365 Log: Fix the NFSv4.0 server so that it does not support NFSv4.1 attributes. During inspection of a packet trace, I noticed that an NFSv4.0 mount reported that it supported attributes that are only defined for NFSv4.1. In practice, this bug appears to be benign, since NFSv4.0 clients will not use attributes that were added for NFSv4.1. However, this was not correct and this patch fixes the NFSv4.0 server so that it only supports attributes defined for NFSv4.0. It also adds a definition for NFSv4.1 attributes that can only be set, although it is only defined as 0 for now. This is anticipation of the addition of support for the NFSv4.1 mode+mask attribute soon. MFC after: 2 weeks Modified: head/sys/fs/nfs/nfs.h head/sys/fs/nfs/nfs_commonsubs.c head/sys/fs/nfs/nfsproto.h head/sys/fs/nfsserver/nfs_nfsdport.c Modified: head/sys/fs/nfs/nfs.h ============================================================================== --- head/sys/fs/nfs/nfs.h Fri Apr 19 02:54:13 2019 (r346364) +++ head/sys/fs/nfs/nfs.h Fri Apr 19 03:36:22 2019 (r346365) @@ -423,10 +423,14 @@ typedef struct { (t)->bits[2] = (f)->bits[2]; \ } while (0) -#define NFSSETSUPP_ATTRBIT(b) do { \ +#define NFSSETSUPP_ATTRBIT(b, n) do { \ (b)->bits[0] = NFSATTRBIT_SUPP0; \ - (b)->bits[1] = (NFSATTRBIT_SUPP1 | NFSATTRBIT_SUPPSETONLY); \ - (b)->bits[2] = NFSATTRBIT_SUPP2; \ + (b)->bits[1] = (NFSATTRBIT_SUPP1 | NFSATTRBIT_SUPPSETONLY1); \ + (b)->bits[2] = (NFSATTRBIT_SUPP2 | NFSATTRBIT_SUPPSETONLY2); \ + if (((n)->nd_flag & ND_NFSV41) == 0) { \ + (b)->bits[1] &= ~NFSATTRBIT_NFSV41_1; \ + (b)->bits[2] &= ~NFSATTRBIT_NFSV41_2; \ + } \ } while (0) #define NFSISSET_ATTRBIT(b, p) ((b)->bits[(p) / 32] & (1 << ((p) % 32))) @@ -445,16 +449,22 @@ typedef struct { (b)->bits[2] &= ((a)->bits[2]); \ } while (0) -#define NFSCLRNOTFILLABLE_ATTRBIT(b) do { \ +#define NFSCLRNOTFILLABLE_ATTRBIT(b, n) do { \ (b)->bits[0] &= NFSATTRBIT_SUPP0; \ (b)->bits[1] &= NFSATTRBIT_SUPP1; \ (b)->bits[2] &= NFSATTRBIT_SUPP2; \ + if (((n)->nd_flag & ND_NFSV41) == 0) { \ + (b)->bits[1] &= ~NFSATTRBIT_NFSV41_1; \ + (b)->bits[2] &= ~NFSATTRBIT_NFSV41_2; \ + } \ } while (0) -#define NFSCLRNOTSETABLE_ATTRBIT(b) do { \ +#define NFSCLRNOTSETABLE_ATTRBIT(b, n) do { \ (b)->bits[0] &= NFSATTRBIT_SETABLE0; \ (b)->bits[1] &= NFSATTRBIT_SETABLE1; \ (b)->bits[2] &= NFSATTRBIT_SETABLE2; \ + if (((n)->nd_flag & ND_NFSV41) == 0) \ + (b)->bits[2] &= ~NFSATTRBIT_NFSV41_2; \ } while (0) #define NFSNONZERO_ATTRBIT(b) ((b)->bits[0] || (b)->bits[1] || (b)->bits[2]) Modified: head/sys/fs/nfs/nfs_commonsubs.c ============================================================================== --- head/sys/fs/nfs/nfs_commonsubs.c Fri Apr 19 02:54:13 2019 (r346364) +++ head/sys/fs/nfs/nfs_commonsubs.c Fri Apr 19 03:36:22 2019 (r346365) @@ -1293,7 +1293,7 @@ nfsv4_loadattr(struct nfsrv_descript *nd, vnode_t vp, if (error) goto nfsmout; if (compare && !(*retcmpp)) { - NFSSETSUPP_ATTRBIT(&checkattrbits); + NFSSETSUPP_ATTRBIT(&checkattrbits, nd); /* Some filesystem do not support NFSv4ACL */ if (nfsrv_useacl == 0 || nfs_supportsnfsv4acls(vp) == 0) { @@ -2129,8 +2129,8 @@ nfsv4_loadattr(struct nfsrv_descript *nd, vnode_t vp, if (error) goto nfsmout; if (compare && !(*retcmpp)) { - NFSSETSUPP_ATTRBIT(&checkattrbits); - NFSCLRNOTSETABLE_ATTRBIT(&checkattrbits); + NFSSETSUPP_ATTRBIT(&checkattrbits, nd); + NFSCLRNOTSETABLE_ATTRBIT(&checkattrbits, nd); NFSCLRBIT_ATTRBIT(&checkattrbits, NFSATTRBIT_TIMEACCESSSET); if (!NFSEQUAL_ATTRBIT(&retattrbits, &checkattrbits) @@ -2460,10 +2460,10 @@ nfsv4_fillattr(struct nfsrv_descript *nd, struct mount * reply call. */ if (p == NULL && cred == NULL) { - NFSCLRNOTSETABLE_ATTRBIT(retbitp); + NFSCLRNOTSETABLE_ATTRBIT(retbitp, nd); aclp = saclp; } else { - NFSCLRNOTFILLABLE_ATTRBIT(retbitp); + NFSCLRNOTFILLABLE_ATTRBIT(retbitp, nd); naclp = acl_alloc(M_WAITOK); aclp = naclp; } @@ -2533,7 +2533,7 @@ nfsv4_fillattr(struct nfsrv_descript *nd, struct mount if (NFSISSET_ATTRBIT(retbitp, bitpos)) { switch (bitpos) { case NFSATTRBIT_SUPPORTEDATTRS: - NFSSETSUPP_ATTRBIT(&attrbits); + NFSSETSUPP_ATTRBIT(&attrbits, nd); if (nfsrv_useacl == 0 || ((cred != NULL || p != NULL) && supports_nfsv4acls == 0)) { NFSCLRBIT_ATTRBIT(&attrbits,NFSATTRBIT_ACLSUPPORT); @@ -2935,8 +2935,8 @@ nfsv4_fillattr(struct nfsrv_descript *nd, struct mount retnum += NFSX_HYPER; break; case NFSATTRBIT_SUPPATTREXCLCREAT: - NFSSETSUPP_ATTRBIT(&attrbits); - NFSCLRNOTSETABLE_ATTRBIT(&attrbits); + NFSSETSUPP_ATTRBIT(&attrbits, nd); + NFSCLRNOTSETABLE_ATTRBIT(&attrbits, nd); NFSCLRBIT_ATTRBIT(&attrbits, NFSATTRBIT_TIMEACCESSSET); retnum += nfsrv_putattrbit(nd, &attrbits); break; Modified: head/sys/fs/nfs/nfsproto.h ============================================================================== --- head/sys/fs/nfs/nfsproto.h Fri Apr 19 02:54:13 2019 (r346364) +++ head/sys/fs/nfs/nfsproto.h Fri Apr 19 03:36:22 2019 (r346365) @@ -1086,11 +1086,11 @@ struct nfsv3_sattr { NFSATTRBM_SUPPATTREXCLCREAT) /* - * NFSATTRBIT_SUPPSETONLY is the OR of NFSATTRBIT_TIMEACCESSSET and - * NFSATTRBIT_TIMEMODIFYSET. + * These are the set only attributes. */ -#define NFSATTRBIT_SUPPSETONLY (NFSATTRBM_TIMEACCESSSET | \ +#define NFSATTRBIT_SUPPSETONLY1 (NFSATTRBM_TIMEACCESSSET | \ NFSATTRBM_TIMEMODIFYSET) +#define NFSATTRBIT_SUPPSETONLY2 0 /* * NFSATTRBIT_SETABLE - SETABLE0 - bits 0<->31 @@ -1107,6 +1107,18 @@ struct nfsv3_sattr { NFSATTRBM_TIMEACCESSSET | \ NFSATTRBM_TIMEMODIFYSET) #define NFSATTRBIT_SETABLE2 0 + +/* + * NFSATTRBIT_NFSV41 - Attributes only supported by NFSv4.1. + */ +#define NFSATTRBIT_NFSV41_1 \ + (NFSATTRBM_FSLAYOUTTYPE) +#define NFSATTRBIT_NFSV41_2 \ + (NFSATTRBM_LAYOUTTYPE | \ + NFSATTRBM_LAYOUTBLKSIZE | \ + NFSATTRBM_LAYOUTALIGNMENT | \ + NFSATTRBM_MODESETMASKED | \ + NFSATTRBM_SUPPATTREXCLCREAT) /* * Set of attributes that the getattr vnode op needs. Modified: head/sys/fs/nfsserver/nfs_nfsdport.c ============================================================================== --- head/sys/fs/nfsserver/nfs_nfsdport.c Fri Apr 19 02:54:13 2019 (r346364) +++ head/sys/fs/nfsserver/nfs_nfsdport.c Fri Apr 19 03:36:22 2019 (r346365) @@ -2126,7 +2126,7 @@ nfsrvd_readdirplus(struct nfsrv_descript *nd, int isdg if (error) goto nfsmout; NFSSET_ATTRBIT(&savbits, &attrbits); - NFSCLRNOTFILLABLE_ATTRBIT(&attrbits); + NFSCLRNOTFILLABLE_ATTRBIT(&attrbits, nd); NFSZERO_ATTRBIT(&rderrbits); NFSSETBIT_ATTRBIT(&rderrbits, NFSATTRBIT_RDATTRERROR); } else {