From nobody Wed Dec 01 21:58:45 2021 X-Original-To: dev-commits-src-all@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 C1ED018B9A99; Wed, 1 Dec 2021 21:58:45 +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 4J4Cdx3hVvz3kgP; Wed, 1 Dec 2021 21:58:45 +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 50AB911868; Wed, 1 Dec 2021 21:58:45 +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 1B1LwjLJ000928; Wed, 1 Dec 2021 21:58:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1B1LwjFV000927; Wed, 1 Dec 2021 21:58:45 GMT (envelope-from git) Date: Wed, 1 Dec 2021 21:58:45 GMT Message-Id: <202112012158.1B1LwjFV000927@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Rick Macklem Subject: git: fd020f197d6a - main - nfsd: Sanity check the ACL attribute List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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/main X-Git-Reftype: branch X-Git-Commit: fd020f197d6ac481d36171ea69fe555eb911d673 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1638395925; 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=MEBm+Fl9ByQzKqVnGOZpkVjQy+3y5mjSsaJYcZ+rdq8=; b=OVakt5rIp3+bd4zCEhJApX7wNwkiwe1clfd2wnF+YeK02odCot2fUMqjSdRPDdE0nbCjYJ 0L2eee/OXDtfUs3PFgj9EhHKvWYGmgmbzaL70y+FUXjSBLPaBe4HwNPcLX9MfdnwgkKpB/ /ufB8oA+E+FfHZ/Nf9skAjegogVipLBqV+aeSTFgMeg7fWeKU/ZydhT3YhsoxHGCgwnRrR 1G0ptl1GsX2pFN346suSbmjVzimBoYSfLpuLeOViXZUW2f2aPO4zeJDFTY3vnYJIg4YKpw 1cMtCpj+D4e4nQwr2h+1+bpk+aobi4WMSHIH4MO7aVOW+JmKCuil0rsywLvj2Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1638395925; a=rsa-sha256; cv=none; b=lCNNX1UVSHo2dOr8i5ltHSnEp86sMh1zDNlUXj+wQy6eWFOJhvWiK/ITVIrbeJ5dCvgCha DLZ4CG0Y9lNiJZ3CEYe/YZjz7vckczSmL9El2qLC8K3BmTcWZ8LD1qsTO/hn6of13ECC39 s/vYLlCoTy5rnt2pe+Oght9hsIbm8okB7rvPVKl1sUE04B+OIQbAtfvx88SdgRKG9Tpz5v LWFXfbCzq91y/lgYcY0bAVXuBCv4QgIz77Lne3xZGx+wkLqYYOUVrzRVMXTxq6AdJHnifY ljGoHTb64QvQsZgWUSm8a9zC55W0Rz2wLFP6Ck94hMEaKdvOtuxoIg338yqxfg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=fd020f197d6ac481d36171ea69fe555eb911d673 commit fd020f197d6ac481d36171ea69fe555eb911d673 Author: Rick Macklem AuthorDate: 2021-12-01 21:55:17 +0000 Commit: Rick Macklem CommitDate: 2021-12-01 21:55:17 +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. Reported by: rtm@lcs.mit.edu Tested by: rtm@lcs.mit.edu PR: 260111 MFC after: 2 weeks --- 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 910f10eb1b4a..d882d248ef7f 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; } }