From nobody Wed Dec 15 01:35:51 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 48E6B18DF0DA; Wed, 15 Dec 2021 01:35:52 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JDHrR5rqHz3rqt; Wed, 15 Dec 2021 01:35:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A8ECE13268; Wed, 15 Dec 2021 01:35:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1BF1ZpHn004617; Wed, 15 Dec 2021 01:35:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BF1Zpdh004616; Wed, 15 Dec 2021 01:35:51 GMT (envelope-from git) Date: Wed, 15 Dec 2021 01:35:51 GMT Message-Id: <202112150135.1BF1Zpdh004616@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Rick Macklem Subject: git: 081d40b8ea24 - stable/13 - nfsd: Sanity check the ACL attribute List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 081d40b8ea244d0700dd2b6031f9722394e3ce09 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1639532151; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=6dVqM2jS+OgojEBFkSo4xxNQz7iM3SrQAY+pvhAWDBs=; b=WE+pVXWJMcAMbBiJCr+YNo/n9g42BU+qjGt8PT0rSREKTOTAQjdIseiKxjN65ESq/drU9W gdfE8jDYVp57JK2l1NJ8llANrcFNiOo7rlbMAHkwaDlxUp6Pvf99UR/aqD5CkQXdaMSjkc +flkgqpGlkQgUiCOCNuek+Nn3UrcfBKijANXg5GlE4AtE+8A8M9W9atm4bCiYb05zAxEkA rc8rZQv3nVWcQXKt03M80OpLklur6gUM7F4GjaruAmwR/yN50GK8bNNfJad5Lwa0qWUSFg f9Ezn+gljoqVPRxv8AvA7Qg2ACaud/sckNhIKbt89Q5+TmyXZ/DaKXlgZvFQZQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1639532151; a=rsa-sha256; cv=none; b=Xxipzkr8/MpRhZR9/UoerAFRqWAgID0v1lJZz7TWifv88C+b4hxAx0Na/IW7u6ybt6/MV1 yAF22pXt6Dg0b5D7Th9OJxrinCAuNgzakY8Nysziwtuo7DpD1K4Gn81LkDxKFXTdK3fjzl dXm53ZESOHU6C6vodPOvQaWFDNbCPfDU5nJLVg/+5B4QdGDxsUn6AXIuvO42Das5MkiSHK FHYzQ9zHmvZ4tOwppTP+PdWZFMHTTK+g8MjErzgZ+ZE1pulsn7bqY+rBfHbVMt4xCVHoh4 ihjXBIPQPchwsQ3GD8P7a+zUZMfe1R0JnZVWESblQV4T3ryAtjkB3UdBQ69qfQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=081d40b8ea244d0700dd2b6031f9722394e3ce09 commit 081d40b8ea244d0700dd2b6031f9722394e3ce09 Author: Rick Macklem AuthorDate: 2021-12-01 21:55:17 +0000 Commit: Rick Macklem CommitDate: 2021-12-15 01:32:27 +0000 nfsd: Sanity check the ACL attribute When an ACL is presented to the NFSv4 server in Setattr or Verify, parsing of the ACL assumed a sane acecnt and sane sizes for the "who" strings. This patch adds sanity checks for these. The patch also fixes handling of an error return from nfsrv_dissectacl() for one broken case. PR: 260111 (cherry picked from commit fd020f197d6ac481d36171ea69fe555eb911d673) --- sys/fs/nfs/nfs_commonacl.c | 6 +++++- sys/fs/nfs/nfs_commonsubs.c | 10 ++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/sys/fs/nfs/nfs_commonacl.c b/sys/fs/nfs/nfs_commonacl.c index 99a67edc044d..19492675e731 100644 --- a/sys/fs/nfs/nfs_commonacl.c +++ b/sys/fs/nfs/nfs_commonacl.c @@ -58,7 +58,11 @@ nfsrv_dissectace(struct nfsrv_descript *nd, struct acl_entry *acep, flag = fxdr_unsigned(u_int32_t, *tl++); mask = fxdr_unsigned(u_int32_t, *tl++); len = fxdr_unsigned(int, *tl); - if (len < 0) { + /* + * The RFCs do not specify a limit to the length of the "who", but + * NFSV4_OPAQUELIMIT (1024) should be sufficient. + */ + if (len < 0 || len > NFSV4_OPAQUELIMIT) { error = NFSERR_BADXDR; goto nfsmout; } else if (len == 0) { diff --git a/sys/fs/nfs/nfs_commonsubs.c b/sys/fs/nfs/nfs_commonsubs.c index 58d517b0b13d..29e33372e83e 100644 --- a/sys/fs/nfs/nfs_commonsubs.c +++ b/sys/fs/nfs/nfs_commonsubs.c @@ -1107,6 +1107,14 @@ nfsrv_dissectacl(struct nfsrv_descript *nd, NFSACL_T *aclp, int *aclerrp, NFSM_DISSECT(tl, u_int32_t *, NFSX_UNSIGNED); aclsize = NFSX_UNSIGNED; acecnt = fxdr_unsigned(int, *tl); + /* + * The RFCs do not define a fixed limit to the number of ACEs in + * an ACL, but 10240 should be more than sufficient. + */ + if (acecnt < 0 || acecnt > 10240) { + error = NFSERR_BADXDR; + goto nfsmout; + } if (acecnt > ACL_MAX_ENTRIES) aceerr = NFSERR_ATTRNOTSUPP; if (nfsrv_useacl == 0) @@ -1492,6 +1500,8 @@ nfsv4_loadattr(struct nfsrv_descript *nd, vnode_t vp, } else { error = nfsrv_dissectacl(nd, NULL, &aceerr, &cnt, p); + if (error) + goto nfsmout; *retcmpp = NFSERR_ATTRNOTSUPP; } }