From nobody Wed May 04 20:59:42 2022 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 8297F1ABE9BE; Wed, 4 May 2022 20:59:42 +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 4Ktq2k3F8Cz4S0f; Wed, 4 May 2022 20:59:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651697982; 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=WnuuSAtIsFFhORfASfe8+XwE2aDDZL9NMNZc29NZlZw=; b=i8Ds4xKlNTvCp8hdlDYLqu51EOotpcaS/DPKWoeHavwKvb3NwwBW24UgxWM/CWp3r2jWXO yrS11GkF+4u+um/mjC0GXytA3IVURAgYCC1LEu0BlCvVNlR0/IQcO3OuRcfWWqgsofBSeN Gip6wBa5LTed/jolLIUgR+Suy8iVwfnEd9f2lIVBo0exDbB+0yNoGkNM/GyJjiMJ9E9p93 4Vcb2tMISK+tWo8+L/G0xACt+zPVFDmx8TOCzhnQ6Asg4IVl6Rrz7i2ZxdIzH29uyfHwIK 1+YMVvzc/R990WHL587BSkG3GSfeW1kZHX2n930K5+fJJfO7P7LMLWCmpRITRQ== 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 4B4811A4A3; Wed, 4 May 2022 20:59:42 +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 244KxgZM080515; Wed, 4 May 2022 20:59:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 244KxgBU080514; Wed, 4 May 2022 20:59:42 GMT (envelope-from git) Date: Wed, 4 May 2022 20:59:42 GMT Message-Id: <202205042059.244KxgBU080514@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: ef4edb70c909 - main - nfsd: Add a sanity check for Owner/OwnerGroup string length 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: ef4edb70c909fc2b1de867601c2230597d07daa0 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651697982; 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=WnuuSAtIsFFhORfASfe8+XwE2aDDZL9NMNZc29NZlZw=; b=JQuNkXluekWlGgKiBTIAVH7mncKV4jTQ6e/9q4ZwV7446p+/LpIcFwZbQD+56s8Xn2XuB/ 8OSsif9isckO6YCLkNkqVGtBTlUNDscd1is4k5zVNySAXsJV3VYOnXl80i2h5RmhKUsoFz LGHMTuODxFUqqLSx/t8Lo+H0Mlo/h1cbOlQC3iHpaGWN8i3ZdsyrwwKwPtCAa6HdUjSN0a +M9yEBAggXHJzlWwrqtm4iz4IvvDn7asMuKG4SECiRuS6REwml/9blYGzy18N0Xeq1lU1t 9AkaiC+yMCooyse3THu4BPZ0/7lXkmMNHmqukcwMLGdzvjoTMWB+RY4JfDoEyg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1651697982; a=rsa-sha256; cv=none; b=WGsJuz0UbfRGgvFbw54C9TO4wR4t2T70aEuP4ODABUYC4Qm9CUQHc9FG4iMnoUjA1381P9 dN/C2+2EZHK0JiwljKkQajpurMreNOY3B96Gt/Cxt7ESr71IIXksbgfp7iZoW5qCf1Xkf1 6JjtBMIGHEZkOFhiJ7QZKEfI0ADOd6cRNgu2GYMwFxrJS6Cl0ldkqkGQNWjH16YuNXL+iR BKx0S5RmRkomfIi+8h8idfbUo5R/QwwIwizQKKCJw4Hus83OCKcKz1n905aybk4VFMuQtG Jn+IWmBZrInUF565g3P1A42dZhH1IcCrz7y7haH/emqQycLZbPL5h7tayaxOPA== 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=ef4edb70c909fc2b1de867601c2230597d07daa0 commit ef4edb70c909fc2b1de867601c2230597d07daa0 Author: Rick Macklem AuthorDate: 2022-05-04 20:58:22 +0000 Commit: Rick Macklem CommitDate: 2022-05-04 20:58: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. Reported by: rtm@lcs.mit.edu PR: 260546 MFC after: 2 weeks --- 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 1a29a7e1d6ec..ffd612331c1f 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 0a601553fa40..e11dba4d2d5e 100644 --- a/sys/fs/nfs/nfs_commonsubs.c +++ b/sys/fs/nfs/nfs_commonsubs.c @@ -1843,7 +1843,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; } @@ -1876,7 +1876,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; }