From nobody Thu Jan 16 18:07:58 2025 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 4YYrSZ30C1z5kktJ; Thu, 16 Jan 2025 18:07:58 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YYrSZ2H1Pz3R9V; Thu, 16 Jan 2025 18:07:58 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1737050878; 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=hUxlhvxX4K6KBFbwK7UmY+pl/7Bas3LHF2FFftMbMW0=; b=TvCH6USAJf1zpB6T8sGXC8lOYz4AbNZBAbFp8OdYLt3FVhKX0dYqMQw5Cc70CPuK68C1WA 26qeDTDpQljcehpL3L+7PnL4QdJhpfrgvr8xlsgPVeutMhgnzedmB3USZBd06kxLTsOFZz TvxOB2oP3sYIpapzzrZSBL8s+tr6vJuncnLZ/hzW8jubTpBHaH2XPqZ9rzULdfz/VKTVUK iC3JzkaCoo0bk+v9Vj77csUYpw9OQ6wRKCUOEkEsX/sqaI2VngQhup01lTBR7NuOOdr755 ZqMtFyAag9VMLvGFB9uFTliXYtiLOu+I4py7s0AxujgVnBwxe7ZglNSSm/2AaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1737050878; 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=hUxlhvxX4K6KBFbwK7UmY+pl/7Bas3LHF2FFftMbMW0=; b=isYpEEKm2bd3H503Nbo86uk0hm6V8IK05ETPnpJn+KiSCgaEwhuFkecqpN8P71C+gD15Er NjXgZyxiM4LSKyaWqaBkDxVbGTq+3BdFfb3EccdcxuJbnN2mbChvqt8Gcf5IVVLtfftDEr ScEfQ+TrEIyYvVXSwgxIDs+qtkeFH6NYBZBfpKmsJIGtEj5IwhjN/KVN5Gjt5fw4dbxPGg zJ3n/+0idSyEQrtf3HJWcyyzUfnaR8m1L2L5nuXwQ191+x0xQgvSf6kEqy31xuVFvnhM0v 0CixvK2zXycTUhWIcLwTKoZg8UfCuBTixxwSK34cpILILp/zd04mRzLtMwbjAQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1737050878; a=rsa-sha256; cv=none; b=KXQb6OrI57ctC4N2IisW7TFulqZQuIlGRq+LLv/uTGUAribfIqwki+clq9o0u3LoFMdmPy E7u2THN12WaYFQ6S2NLcWdlVYcO0YUgcdSB6B6M5c6usRDfUe4nKGi8aCQ8gmwzcbSBc6/ 5VMF6QTT0XlTanD1U5QlS0SeEMTRjl0/kuYsvynzihd+HCoJCmqJl9lgTYZM/jLrQalz4N pOMDFwRPqJDcSm/lDJsA3wNBZgeYG7xSnBc96fh4T2kNgJZrVW6DiNdUNW/vtDR/sUVmD1 JmYiAtS24Fp40l9WDMgCHQKHngdxkXWxb5hGNVQ0D66pCvhNY2LJ5I83kOzenQ== 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 4YYrSZ1lsRzjbv; Thu, 16 Jan 2025 18:07:58 +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 50GI7wFv090957; Thu, 16 Jan 2025 18:07:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 50GI7wkO090954; Thu, 16 Jan 2025 18:07:58 GMT (envelope-from git) Date: Thu, 16 Jan 2025 18:07:58 GMT Message-Id: <202501161807.50GI7wkO090954@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Olivier Certner Subject: git: 1ae0a4f52af6 - stable/14 - Open-code proc_set_cred_init() 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/14 X-Git-Reftype: branch X-Git-Commit: 1ae0a4f52af67d345d9829422b3c7cf9e704da0e Auto-Submitted: auto-generated The branch stable/14 has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=1ae0a4f52af67d345d9829422b3c7cf9e704da0e commit 1ae0a4f52af67d345d9829422b3c7cf9e704da0e Author: Olivier Certner AuthorDate: 2023-09-25 08:48:49 +0000 Commit: Olivier Certner CommitDate: 2025-01-16 18:06:46 +0000 Open-code proc_set_cred_init() This function is to be called only when initializing a new process (so, 'proc0' and at fork), and not in any other circumstances. Setting the process' 'p_ucred' field to the result of crcowget() on the original credentials is the only thing it does, hiding the fact that the process' 'p_ucred' field is crushed by the call. Moreover, most of the code it executes is already encapsulated in crcowget(). To prevent misuse and improve code readability, just remove this function and replace it with a direct assignment to 'p_ucred'. Reviewed by: markj (earlier version), kib MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D42255 (cherry picked from commit 92541c12bc25c59333d7f3b0721b6b16aaff3644) --- sys/kern/init_main.c | 2 +- sys/kern/kern_fork.c | 2 +- sys/kern/kern_prot.c | 11 ----------- sys/sys/ucred.h | 1 - 4 files changed, 2 insertions(+), 14 deletions(-) diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index 23a1eb944b7b..5835db44b853 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -562,7 +562,7 @@ proc0_init(void *dummy __unused) curthread->td_ucred = NULL; newcred->cr_prison = &prison0; newcred->cr_users++; /* avoid assertion failure */ - proc_set_cred_init(p, newcred); + p->p_ucred = crcowget(newcred); newcred->cr_users--; crfree(newcred); #ifdef AUDIT diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index 9bbe7c8a8153..8054f93c2c9d 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -1060,7 +1060,7 @@ fork1(struct thread *td, struct fork_req *fr) * XXX: This is ugly; when we copy resource usage, we need to bump * per-cred resource counters. */ - proc_set_cred_init(newproc, td->td_ucred); + newproc->p_ucred = crcowget(td->td_ucred); /* * Initialize resource accounting for the child process. diff --git a/sys/kern/kern_prot.c b/sys/kern/kern_prot.c index 85c38c474df5..44a1f26767ed 100644 --- a/sys/kern/kern_prot.c +++ b/sys/kern/kern_prot.c @@ -2278,17 +2278,6 @@ cru2xt(struct thread *td, struct xucred *xcr) xcr->cr_pid = td->td_proc->p_pid; } -/* - * Set initial process credentials. - * Callers are responsible for providing the reference for provided credentials. - */ -void -proc_set_cred_init(struct proc *p, struct ucred *newcred) -{ - - p->p_ucred = crcowget(newcred); -} - /* * Change process credentials. * Callers are responsible for providing the reference for passed credentials diff --git a/sys/sys/ucred.h b/sys/sys/ucred.h index e7f8d7328dda..8724cfcdc1e6 100644 --- a/sys/sys/ucred.h +++ b/sys/sys/ucred.h @@ -158,7 +158,6 @@ void crcopy(struct ucred *dest, struct ucred *src); struct ucred *crcopysafe(struct proc *p, struct ucred *cr); struct ucred *crdup(struct ucred *cr); void crextend(struct ucred *cr, int n); -void proc_set_cred_init(struct proc *p, struct ucred *cr); void proc_set_cred(struct proc *p, struct ucred *cr); void proc_unset_cred(struct proc *p); void crfree(struct ucred *cr);