From nobody Tue Jan 6 13:34:24 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 4dlsb447k2z6Ndwd for ; Tue, 06 Jan 2026 13:34:24 +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" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4dlsb422Kcz3Sr9 for ; Tue, 06 Jan 2026 13:34:24 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1767706464; 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=sEECbDIFqb6hRKQY8ewHTFXqAKIew2LM+Attor6W4Nk=; b=h0srzq3p0S3o7fl/h4WeJEDtvk6Saq1qYE2vfJFMp/zAr7hrAyDxbOeDkgd1YivdygdvZX MEjje2EPgTPxKoKvEJ7ZYtEfAKe9G8PIwMR2JluQ9RwI9jqsQryElh2M2bYRzyurxJd50Z WzZQbypenag/LGPIOluFBMvMMdmNXIgJlP82Q0kDNlHnjK4+sFk7ik9E4MbroGrf3/qEgR 3ZJnWyaVExuNnLr2mqRUoeR1JcT3HifptjPh88vqtnI0a6ln2GaMgCZ4lbiIBuWJ7mP2Wp EikajhnWf9f2S5iJj2EYOLC1DzTjQ4myIBOAfOWuaYoNv/Zmfh8RhG3RI1Kfyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1767706464; 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=sEECbDIFqb6hRKQY8ewHTFXqAKIew2LM+Attor6W4Nk=; b=JatzsTPuOA4O6WLM7PE07mDzWE4Xk5uLn8rdfdjB9x1lBt5vnop8MVcfloJN5aVZin+RJA wtxMhhBF5/lldSh6olyyq4A17+TLI79nG0zn2TRg6sBPZB+MQe5Sr7p/JD0rSKQRLlkvhW b++GaHkEZrNyS/s78/oRkdVngRl5m8VqtNx2XP4OhDU3rV0Is0tbg7yQw1CRKyNvzM8cV6 2qPrjegGTUCuHXxiP3MElxz689M1iSolpCgOlPx+EeRiAtlJamrV1CCkKmjCrR3/5ASB1+ AJEw4zdzbUaPqHjGUTZRV6Du8tJGDyX/5V/+28D2dUt1glDsEfo+SrxZv95sSQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1767706464; a=rsa-sha256; cv=none; b=hyEUicHaPG2i/lj8yQEIzNrn16r2hC+2z9BrHCjrAw9/Qm6OyAQ8WnZ/Xtplg3lIa/6bc9 k/FMI/Ti17ZlDwnOj1lji3Tf15+NNBoK7abAbIAxkY31qmbdqIdT7qjb+v5Md1/egHks3a Hkr2HmjCcYyBpHvD4MkgHIRCbqP6n4ui2m07++zEALJEpnMFXuN3R1yCpHdtGFj45dYjpI jCJRcdp5zVkyMgWoz2aJfdJos4v5MJE1m4QxczT3n7Lgk1VQWFb6rYyBnFB2Ay0bacHJIZ tcSwa6ZYQbAm10n2kne/si+iflLppJrdsnPqPTkGTI4yfRMhqNvRAdgCyqo4IA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4dlsb40sYnz17lN for ; Tue, 06 Jan 2026 13:34:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3fdc1 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 06 Jan 2026 13:34:24 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Olivier Certner Subject: git: 7db725b25ed9 - stable/15 - proc_set_cred(): Allow 'newcred' to have multiple references 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 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: olce X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 7db725b25ed933b5e126386652e801c8fed34a84 Auto-Submitted: auto-generated Date: Tue, 06 Jan 2026 13:34:24 +0000 Message-Id: <695d0f60.3fdc1.48844a3c@gitrepo.freebsd.org> The branch stable/15 has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=7db725b25ed933b5e126386652e801c8fed34a84 commit 7db725b25ed933b5e126386652e801c8fed34a84 Author: Olivier Certner AuthorDate: 2025-11-06 22:25:57 +0000 Commit: Olivier Certner CommitDate: 2026-01-06 13:33:24 +0000 proc_set_cred(): Allow 'newcred' to have multiple references This is an extension needed by next commit, where some additional reference is kept on the credentials to be set on a process in order to keep these credentials alive even after the process lock is released (an intervening reset of process credentials could release the reference that the process holds). Only 'cr_users' is incremented, as the reference (counted in 'cr_ref') comes from the caller, who passes it to the process. Reviewed by: kib, markj MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D53636 (cherry picked from commit 5d46d11772c3280fd1c8ae09f20ce6c57f631c30) --- sys/kern/kern_prot.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/sys/kern/kern_prot.c b/sys/kern/kern_prot.c index 0b7dc2169335..30cc617ceaf1 100644 --- a/sys/kern/kern_prot.c +++ b/sys/kern/kern_prot.c @@ -2792,10 +2792,6 @@ _proc_set_cred(struct proc *p, struct ucred *newcred, bool enforce_proc_lim) MPASS(oldcred != NULL); PROC_LOCK_ASSERT(p, MA_OWNED); - KASSERT(newcred->cr_users == 0, ("%s: users %d not 0 on cred %p", - __func__, newcred->cr_users, newcred)); - KASSERT(newcred->cr_ref == 1, ("%s: ref %ld not 1 on cred %p", - __func__, newcred->cr_ref, newcred)); if (newcred->cr_ruidinfo != oldcred->cr_ruidinfo) { /* @@ -2821,8 +2817,10 @@ _proc_set_cred(struct proc *p, struct ucred *newcred, bool enforce_proc_lim) __func__, oldcred->cr_users, oldcred)); oldcred->cr_users--; mtx_unlock(&oldcred->cr_mtx); + mtx_lock(&newcred->cr_mtx); + newcred->cr_users++; + mtx_unlock(&newcred->cr_mtx); p->p_ucred = newcred; - newcred->cr_users = 1; PROC_UPDATE_COW(p); if (newcred->cr_ruidinfo != oldcred->cr_ruidinfo) (void)chgproccnt(oldcred->cr_ruidinfo, -1, 0);