From nobody Fri May 20 00:43:45 2022 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 E9CE51B47658; Fri, 20 May 2022 00:43: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 4L47JK5zdyz3syj; Fri, 20 May 2022 00:43:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1653007425; 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=OAjiPIeF/4gNRHc4oC//xhWHI3GtkkcNRD7eQ94nWfc=; b=YMICufyHn7/b/zSgl5tJPwWWCa3CtRxskvR7jDbfLS4yUI58QZZEbP8Mmp0GUOnK8AdsvE 2D6iZPIu+LxNxHCLXCN7auAp9vBFr3TP8qOB3Z4W81lOM3qIaua1W2KxGhF62wbtgpGntV VLW7wMnBSHOrLJSREGT0bpx2TAtJ1XwoDns8pme05kGoA326HU4y7ShnT9moHMw5Jv5vWb wS0oNO7AaMeHsYXxW4Xb+Euwzq8HTM3ntEUtRtBGAWncRUj1g56sHRcG2CWEYj1PXXGmq0 cBxsPhbJ68wvyYhKrzD+QAw2m2/TDpXL22+uOE0ZflgN5CVOTkHziD6bhmWIhg== 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 AE74A2F9; Fri, 20 May 2022 00:43: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 24K0hjXL004439; Fri, 20 May 2022 00:43:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 24K0hjgX004438; Fri, 20 May 2022 00:43:45 GMT (envelope-from git) Date: Fri, 20 May 2022 00:43:45 GMT Message-Id: <202205200043.24K0hjgX004438@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: c0ea059da22f - stable/12 - nfsd: Add a sanity check for Owner/OwnerGroup string length 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: c0ea059da22f0f1f20ee43db536a74032f140429 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1653007425; 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=OAjiPIeF/4gNRHc4oC//xhWHI3GtkkcNRD7eQ94nWfc=; b=KZiNorzm0tXM90on+R2nGVkJoK8281CMR+7FuaeAOnVnNr4Tbnk+ahmxZmQnBNFeDqKYIG PZqFla0D5/0fwBKqSwnpOLQunkqJZqpttKI9Us4NuAFUmPiA/WdKueJfMZc7kzMVi/0mfN ublDjYgx7ohw3oG8Xj1B/qMa+O9kZ0TALXrP6E67tYG0LRCWTMvphhmRRMtuEHLK/H8sOO 0bQnk59r1UxGSkqS1mcR5je/Khq3oGopKuyE/d5tJnBzVyr5LHJoEsdYDASCYOqM9JtMVE H8ycNOXudeURBNMI6G1vqqWzo0USY8TZHDN5XHplTOBlIfecL5gTFIdkTXH3fg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1653007425; a=rsa-sha256; cv=none; b=CugLv+ZbOe5iWy0652ecx+ymBXNvUP2v+Dp47fsfXh9EUKH10szSLzMq+wDQyEtxvOrlb9 qCk+yLaAuMe3MYiMhH2NO8Nu9p0sy6NbfwVvVp6eHi3y1+6c0hAlkZmJOO1dLgabGqNJ4/ 9TET9P3QgTUTfrhvW8NrX/jGBvA8Qa38WCoHfL+ZoEIuyEcEFAJb529D7YIrcPTrOfyqbd P8RrxvvlBWcwvRGAN/lIGyxuQmNCpTlFyzM4huxGpB1/h28GztupgIi+cfXXOFKUyJhArC GKzZOUS7xd0tHY2gYAYNSFF/yFQF2O5d5dTWbWNOai99Qg2ec/zi7ACPU7Kqpg== 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=c0ea059da22f0f1f20ee43db536a74032f140429 commit c0ea059da22f0f1f20ee43db536a74032f140429 Author: Rick Macklem AuthorDate: 2022-05-04 20:58:22 +0000 Commit: Rick Macklem CommitDate: 2022-05-20 00:43:22 +0000 nfsd: Add a sanity check for Owner/OwnerGroup string length Robert Morris reported that, if a client sends an absurdly large Owner/OwnerGroup string, the kernel malloc() for the large size string can block forever. This patch adds a sanity limit for Owner/OwnerGroup string length. Since the RFCs do not specify any limit and FreeBSD can handle a group name greater than 1Kbyte, the limit is set at a generous 10Kbytes. PR: 260546 (cherry picked from commit ef4edb70c909fc2b1de867601c2230597d07daa0) --- sys/fs/nfs/nfs.h | 7 +++++++ sys/fs/nfs/nfs_commonsubs.c | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/sys/fs/nfs/nfs.h b/sys/fs/nfs/nfs.h index de35f40f40d0..b6af8902ca98 100644 --- a/sys/fs/nfs/nfs.h +++ b/sys/fs/nfs/nfs.h @@ -143,6 +143,13 @@ #define NFS_READDIRBLKSIZ DIRBLKSIZ /* Minimal nm_readdirsize */ +/* + * The NFSv4 RFCs do not define an upper limit on the length of Owner and + * OwnerGroup strings. Since FreeBSD handles a group name > 1024bytes in + * length, set a generous sanity limit of 10Kbytes. + */ +#define NFSV4_MAXOWNERGROUPLEN (10 * 1024) + /* * Oddballs */ diff --git a/sys/fs/nfs/nfs_commonsubs.c b/sys/fs/nfs/nfs_commonsubs.c index c7271cffe1ab..3ccfb6cce0d2 100644 --- a/sys/fs/nfs/nfs_commonsubs.c +++ b/sys/fs/nfs/nfs_commonsubs.c @@ -1815,7 +1815,7 @@ nfsv4_loadattr(struct nfsrv_descript *nd, vnode_t vp, case NFSATTRBIT_OWNER: NFSM_DISSECT(tl, u_int32_t *, NFSX_UNSIGNED); j = fxdr_unsigned(int, *tl); - if (j < 0) { + if (j < 0 || j > NFSV4_MAXOWNERGROUPLEN) { error = NFSERR_BADXDR; goto nfsmout; } @@ -1848,7 +1848,7 @@ nfsv4_loadattr(struct nfsrv_descript *nd, vnode_t vp, case NFSATTRBIT_OWNERGROUP: NFSM_DISSECT(tl, u_int32_t *, NFSX_UNSIGNED); j = fxdr_unsigned(int, *tl); - if (j < 0) { + if (j < 0 || j > NFSV4_MAXOWNERGROUPLEN) { error = NFSERR_BADXDR; goto nfsmout; }