From nobody Fri Dec 19 09:19:20 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 4dXhn50y0xz6LBNc for ; Fri, 19 Dec 2025 09:19:21 +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 4dXhn44sCXz44xt for ; Fri, 19 Dec 2025 09:19:20 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1766135960; 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=+8LdHDJ5akg5vBtDem7FB1WDjEnUP6jq/s+C/Boi6GE=; b=tWI2IO9HKMb0iMtKfxMkXQexS1oCoN6RCGL9dNEr3mLV1Wyx0ANsTQP0nR4unoPh2C17v7 IeyI/ISd33v5PAuCukFcL09+/+rV/uw+DdT17uwW+9B/svNPZhXN7m0xz/jlYnKgjf24nj I4g7E2AlHZJ3L76aUw1MPYqswjhTZBuOnyAdWixA809nfDxnDlsswvGc2rF7YGRVvOrdv7 aUVuT+5nSitpFEyxMzXoYu/17Bk8zHZ1WlLdJXXWZ73DDP2IAbRsAgrGutQesbxFc5ttJO kDVEo9lbd1iiyzwQmebRqMuo6SGJnj3Y2sy09aGl2/wFOXOW35NS5aWzciNgvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1766135960; 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=+8LdHDJ5akg5vBtDem7FB1WDjEnUP6jq/s+C/Boi6GE=; b=DIA3BHljaU1wgITAvnLeBppw8ova+g+/ujtJo0cwwgx0whkxWf9wCHp2e/WISpOchDEmLQ f56gzlYtlX40qaPxnmqgQ+P0iXPNIKRPIhDuTq82kveM7Xz6x2S2yOv65rw19Yzo5/Fqsx UY4JBM4HnSc1cz6sakO7EhtBmkpYg6JkQUyC/wcEsho3FtJ5em7jgckpUoSbzQRVxUxpZJ a2t/zkywRVqiR1XsuR8iT8GZq9nH2pSJPvylteAnS+Hp2xhNrfZzHNhPEJnCBj9cE4n7br uE9XWU/g7Zx2ht7aIeDJSn90qW+MXBIYpJeowM/aqc3DPS1YQzqKhgHkWjzX8Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1766135960; a=rsa-sha256; cv=none; b=L5zTKeZKp8x+r3a7K6yODhPpXaiavW//ZDAq4Df2T5nbVO15gHNbtkaIznO0/8QXB+JyEh jY1GSdBIK/XmSv0b1Yy2gAMDqBvwH7H/hbeaIzTfy3anYZmMxooq5AGCSDgekN48Y65i/K SH254iW+jDt8kKRNw95B4hzShuiib9MFB19vsDl+CKhKJXrmmelUNoHW9D+IVS7idJZ7Ju yCU0bCndtYDCzSad5KFUZ8866ANm/egnNOsAzyzaZBFqNoM09o8LurNSWsWTMGT2aIysCA fH7yVmGtYJTkIUYOF6J92bky333O0ohfRc99UabEyIcMH6REVHTk9VgJNGz2lg== 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 4dXhn44PlQz1H2S for ; Fri, 19 Dec 2025 09:19:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3d6dc by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 19 Dec 2025 09:19:20 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Olivier Certner Subject: git: 269e6a4bc065 - stable/14 - proc_set_cred(): Allow 'newcred' to have multiple references 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: olce X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 269e6a4bc0656994ea895c88135a2b0d162e8d13 Auto-Submitted: auto-generated Date: Fri, 19 Dec 2025 09:19:20 +0000 Message-Id: <69451898.3d6dc.79fc1cbb@gitrepo.freebsd.org> The branch stable/14 has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=269e6a4bc0656994ea895c88135a2b0d162e8d13 commit 269e6a4bc0656994ea895c88135a2b0d162e8d13 Author: Olivier Certner AuthorDate: 2025-11-06 22:25:57 +0000 Commit: Olivier Certner CommitDate: 2025-12-19 09:16:47 +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 044b8091310f..c7c60d8bb747 100644 --- a/sys/kern/kern_prot.c +++ b/sys/kern/kern_prot.c @@ -2678,10 +2678,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) { /* @@ -2707,8 +2703,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);