From nobody Wed Dec 15 01:42:09 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 C322018E1F12; Wed, 15 Dec 2021 01:42:09 +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 4JDHzj3sjPz3vp3; Wed, 15 Dec 2021 01:42:09 +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 5B3571388B; Wed, 15 Dec 2021 01:42:09 +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 1BF1g99c015899; Wed, 15 Dec 2021 01:42:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BF1g9mU015898; Wed, 15 Dec 2021 01:42:09 GMT (envelope-from git) Date: Wed, 15 Dec 2021 01:42:09 GMT Message-Id: <202112150142.1BF1g9mU015898@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: b5c577931db1 - stable/12 - 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/12 X-Git-Reftype: branch X-Git-Commit: b5c577931db12c68f5a20fa11c9502049c3cdb40 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1639532529; 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=fBBqpesHxxUrYAruwD4iVq2YNv+DnJDAoIIhOcoM/kc=; b=RrMrug7mZHZXdE4cZAfhZ1c5ZUS0+tEmRCfNnDluIx6jogTDFp1Oop/7Mj8tsIl7FO0A9c ytYJnzpLARujihjPy4VgHnG5gVOpHmxssGChOOjC36A356+A669XegakgNidz/C0c1dnpB RSv/NRBATa3zksBuHztbsUmzEJ25LmU/8nYxgjeK59oXUVOjp8jiAeDHsehz5ovRVoVtP3 ZwlRC1qp/+XSnJjQOgWJoT48kRsZMRh1NwfhBLJPmEYl583xJcS3qywEkC71xKsLWz5qL7 sH6Krsc3w34XwDm0Wef3cRnJja/PfWkDEphFcKUuZlc9E1RsnYxntKaPg48mwg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1639532529; a=rsa-sha256; cv=none; b=xeQEmo0D6efkzFynheWM1s/5p4dgv+Xc0Wzf7ZZ3b//fLz/r4We4Ph8lBsNC5i7W5D009d pp7qZlqAA2w5SFz7tlx/nFj8q2s59iT1mO1yLScdCLr4A+ESvJ+s/2bF0L7HE7MlNRCfdV q6d4P80bb8P+HuRkNdkpm6RWO+KLj1LMVNtNSlPYUv6Igt3nl+RuylYL6LFozuTHLGWwST jcSkim+li2l8Ov3nyaykwybivvIWHebnDFpU8iTkJWh2OI7Wzr1FpyYs/eprODCNe49Uwi hMdG5PHMMnnopJ9iOYosged89U/d/OxGoJCrKg3ImGesNjxUV54ORRgW+gDUwg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=b5c577931db12c68f5a20fa11c9502049c3cdb40 commit b5c577931db12c68f5a20fa11c9502049c3cdb40 Author: Rick Macklem AuthorDate: 2021-12-01 21:55:17 +0000 Commit: Rick Macklem CommitDate: 2021-12-15 01:38:56 +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 7fb744417d6a..6254a6b6568c 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 e4120d4d9e78..dcdf2e96c7e8 100644 --- a/sys/fs/nfs/nfs_commonsubs.c +++ b/sys/fs/nfs/nfs_commonsubs.c @@ -1085,6 +1085,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) @@ -1468,6 +1476,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; } }