From nobody Wed May 20 19:39:28 2026 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 4gLMLS6pTGz6fJbF for ; Wed, 20 May 2026 19:39:28 +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 "R13" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gLMLS4Fw7z3XwF for ; Wed, 20 May 2026 19:39:28 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1779305968; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=rjhEXGm6QZU/6Z4zgcrNSRfoEXZTiJiHU1UFdctDzeo=; b=xmUO18YZE/YmaJ1QfS/R04sXMnC6oWIDCk6/Q0joxlwPWhQs3sVTNcHinhGkIXtdu1LmRI xu+FovLsr7EK77+F43E/gss8Nk5JZKJEOphsIoDDd9qPxOiodDjGAIcPhYNl+W8yRRDap9 r3YKJn/yWeVCOH3nKR29upe4JF5mohfeLehRgygcQruC1n2M36jlHQzQ9oETGS9AjQT8lw Pu813Wik7Yo+sTLVOy8m8vwkQVrWGmtolgF5yTFZWaMEnr0iB+GDFNts4VVBq5ruTMKvcp cRLQjTivaAs0v+jokP5YxCoxx2wMQr7Irjw+5AT4WIAIOYCScE4/fxMjaexJMg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1779305968; a=rsa-sha256; cv=none; b=DJQ18KEu+f+dqRPP+yOmzubpk9RIPd0iaShsLvB1j+wq96LZK/j9udqFR3w1hiMKFhVvyJ YUFOFo7EI4s0CRic+JisALFhoz4/qVhSVSWmu7nKJTP25J4RWOPDu8o/sT87fBm0bA28sj A+LL2m8iLQ/8m8JvS7dEP8OYkyuDG7JNp/RnIW4YW8hfiGf2cUyPefkAbQlqp29ATdxuoJ SuVAX4x8vQZgRyqAQ4YrHeKOqs7v1bIpZPj91LXdzT41E/B6rLD81bgnZDX4wWpARXSTHM t/uO5iUXil3P+dbRZUb4fZ1t1OcXbVv1Wzp8bKAXzNRyHFB2H42v8zmoklbQ1w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1779305968; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=rjhEXGm6QZU/6Z4zgcrNSRfoEXZTiJiHU1UFdctDzeo=; b=HgDRYMhokceRXVgCrWuh0mh4p8Qv0GK2lYNt2gi3+2i13/hlzwnNcUHuRSFdQXLKoirAi7 tGee9RKv6mnjrv5aktIMAehC30/lahgtblDdKukY2qcx61c4fjixoq8di/pe4vkgg7nuwx ukJQOvDFipV6lELN2CQVSnwxTh/GhDB6En/fHdCdShaqsl5u2uaji30b0zpgD7fUBpf/eD KOt8mn4HM5QZc9z9A4PClXhC0SSjA02L13xPLFucYpHc4v2TzWI1x7HdG9Uqhvo6SpQSgP wl+MqU8xcluoDctaN5ylVjGhCJ2RKNmcs/izfdEO7PmWkSsrzMzo3zasUAff+Q== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gLMLS3q1Pz1Dss for ; Wed, 20 May 2026 19:39:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 368e7 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 20 May 2026 19:39:28 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Cc: Dag-Erling=?utf-8?Q? Sm=C3=B8rg?=rav From: Mark Johnston Subject: git: d98c0a494a42 - releng/15.0 - setcred: Fix buffer overflow 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/releng/15.0 X-Git-Reftype: branch X-Git-Commit: d98c0a494a421b40f727356bd892d25041c5f90d Auto-Submitted: auto-generated Date: Wed, 20 May 2026 19:39:28 +0000 Message-Id: <6a0e0df0.368e7.1865b2c@gitrepo.freebsd.org> The branch releng/15.0 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=d98c0a494a421b40f727356bd892d25041c5f90d commit d98c0a494a421b40f727356bd892d25041c5f90d Author: Dag-Erling Smørgrav AuthorDate: 2026-05-07 08:06:35 +0000 Commit: Mark Johnston CommitDate: 2026-05-19 23:51:24 +0000 setcred: Fix buffer overflow Since groups is a pointer to a pointer to an array of gid_t, we should use sizeof(**groups) or sizeof(gid_t) when calculating how much to allocate and copy in. We were using sizeof(*groups) instead, which meant that on 64-bit platforms, we would allocate and copy in twice as much as we should. Unfortunately, in the smallgroups case, we copy into a preallocated buffer which has the correct size, which means that if sc_supp_groups_nb >= CRED_SMALLGROUPS_NB / 2, we overflow smallgroups. This is a direct commit to releng/15.0. Approved by: so Security: FreeBSD-SA-26:18.setcred Reported by: Ryan of Calif.io Fixes: ddb3eb4efe55 ("New setcred() system call and associated MAC hooks") --- sys/kern/kern_prot.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/kern/kern_prot.c b/sys/kern/kern_prot.c index 0b7dc2169335..02f83360885e 100644 --- a/sys/kern/kern_prot.c +++ b/sys/kern/kern_prot.c @@ -554,10 +554,10 @@ kern_setcred_copyin_supp_groups(struct setcred *const wcred, */ *groups = wcred->sc_supp_groups_nb <= CRED_SMALLGROUPS_NB ? smallgroups : malloc(wcred->sc_supp_groups_nb * - sizeof(*groups), M_TEMP, M_WAITOK); + sizeof(gid_t), M_TEMP, M_WAITOK); error = copyin(wcred->sc_supp_groups, *groups, - wcred->sc_supp_groups_nb * sizeof(*groups)); + wcred->sc_supp_groups_nb * sizeof(gid_t)); if (error != 0) return (error); wcred->sc_supp_groups = *groups;