From nobody Thu Oct 30 14:05:46 2025 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 4cy5Vg07TVz6DGLy; Thu, 30 Oct 2025 14:05:47 +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 "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cy5Vf6RLDz3RQr; Thu, 30 Oct 2025 14:05:46 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1761833146; 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=jI1nZ7ctUkfKv1GbSWz7JatYi0o65b9O0hKdTdLGX2I=; b=Y++Mwj5v9JfYkcXmnSNM9Nr3UT3zOy+/a7+GguJgPmk3yg/CXRhDuezfQIJXUOtc3ziyfW fBHbWfx3O59BuBIl1hY6X1JSzoFJF43KjyTVpBP07n56Sfoxuo1ikQZU1AXoe7oVjjltjv d1lHnZSTBsfn8Gl90rXRFVebeQPh4cxvmNWpy1jkurtIM91biJkmxUdGpifNeuNf5D9uAY gneC/bheTJuilpg0IflbimpLRrzWQlIXCscv05hSyAa1/H6noxnsgdiILxF7UaGMetpM0f tQpdS9ByDHsXxibwklU85YTVRdaiJiI69N1ljhJp6v7UKXPlm9fgJUnZp+7sAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1761833146; 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=jI1nZ7ctUkfKv1GbSWz7JatYi0o65b9O0hKdTdLGX2I=; b=T3RyyFt6uiDbKwWXOBHGAWGxYd/MgsmZAc7SuqHaixIsB9tE/0qYBX85Rrg39VxwtREAOV LFhyDJ+LUHDd0+EYpav/+h+VPHH658+30ctRuGQ4ZlbSPnLp7PkOXc4bpi2zokpLPq81k2 LNvGMxMNAsNRaxuCcOns7TIEODh0cjXR4SafAirT8wcpvx6TJf3EzyOu++TRWKOzETnPWr wJ3kTuBG3uk58yUkLY6G+CNxbnXCzPW3vbPrV7kONen+tB1K6uYG9bvOrHkPMmdGQnF+XY cD1d98vLZLN65Tu44bXlLpyGf7s1o89I0uXjsV0yQMejlZ2tzY9zKSp03kwi6g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1761833146; a=rsa-sha256; cv=none; b=oRQHV2rsgq5pqOd368JIF9eM0vnRGTgpdoSdUk8DAaaojMHkrnlgZjSbLpbm4SI7qHaICS RQ2KLHAtDHaJYcxVmfXU6v5ee7G5mR2bO/GciUn5PWJWwFz+y0it1LDpW58KQwfyalsq7I sQ94caIWEXoDlNqUbz5sYV2iLoeyRfKS02A1O5KVJu2wkuDcDAL9SwUWvFL6RqurOmmW87 l9V9dqK5XC6ntdMGiaIV0gAwMTQJM1I8nwREvug8i4yX4v/pmwQMhHA9iMWzJMWRq+elpo R/RBmQUjnFC4kKBc6bnpTIxwIZOD1Ni6VyIQGkFaO6RflW8DZgL5PT6GDA6L+w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4cy5Vf5p2Gz9G9; Thu, 30 Oct 2025 14:05:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 59UE5k6Q077794; Thu, 30 Oct 2025 14:05:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 59UE5kYp077791; Thu, 30 Oct 2025 14:05:46 GMT (envelope-from git) Date: Thu, 30 Oct 2025 14:05:46 GMT Message-Id: <202510301405.59UE5kYp077791@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: 83a0732a4cfe - stable/15 - nfs_commonsubs.c: Add a sanity check for nid_ngroup 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: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-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/15 X-Git-Reftype: branch X-Git-Commit: 83a0732a4cfe9f2846e144b39ebe517cbe395fac Auto-Submitted: auto-generated The branch stable/15 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=83a0732a4cfe9f2846e144b39ebe517cbe395fac commit 83a0732a4cfe9f2846e144b39ebe517cbe395fac Author: Rick Macklem AuthorDate: 2025-10-28 14:44:14 +0000 Commit: Rick Macklem CommitDate: 2025-10-30 14:02:49 +0000 nfs_commonsubs.c: Add a sanity check for nid_ngroup The nfsuserd(8) daemon passes user credentials (uid + gids) into the kernel for users and groups identified by name (received from a NFSv4 server). This patch add a sanity check for the number of groups (nid_ngroup) passed in. It's only purpose is to protect against a bogus nfsuserd(8) running in a jail. (cherry picked from commit 4672adcea4cf3c0c626d186f1f41c69552d915f1) --- sys/fs/nfs/nfs_commonsubs.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/sys/fs/nfs/nfs_commonsubs.c b/sys/fs/nfs/nfs_commonsubs.c index 7f5b29ca2085..dd3b8b4f1708 100644 --- a/sys/fs/nfs/nfs_commonsubs.c +++ b/sys/fs/nfs/nfs_commonsubs.c @@ -4165,10 +4165,15 @@ nfssvc_idname(struct nfsd_idargs *nidp) nidp->nid_namelen); if (error == 0 && nidp->nid_ngroup > 0 && (nidp->nid_flag & NFSID_ADDUID) != 0) { - grps = malloc(sizeof(gid_t) * nidp->nid_ngroup, M_TEMP, - M_WAITOK); - error = copyin(nidp->nid_grps, grps, - sizeof(gid_t) * nidp->nid_ngroup); + grps = NULL; + if (nidp->nid_ngroup > NGROUPS_MAX) + error = EINVAL; + if (error == 0) { + grps = malloc(sizeof(gid_t) * nidp->nid_ngroup, M_TEMP, + M_WAITOK); + error = copyin(nidp->nid_grps, grps, + sizeof(gid_t) * nidp->nid_ngroup); + } if (error == 0) { /* * Create a credential just like svc_getcred(),