From nobody Fri Jan 17 12:26:52 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 4YZJrX3Qmdz5kvFc; Fri, 17 Jan 2025 12:26:52 +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 4YZJrX2k6bz3TJ5; Fri, 17 Jan 2025 12:26:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1737116812; 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=eVTZsqF/itWNyYr1y+CjRfYcAgVKRe5GzZkoSYn0FD4=; b=ZlSGYjmYTUzAtASaS1nCUyIBbqfDh7N1EBjSJgs2zdgH+ix4vcy2/JE0fN5d7f57naQUW1 3GFxaehLd4OyA4RN0ln7shFZnjdVQVoPjnA1X4AcIlumotWWGCyL/c72xHWQZxUj2B+ZdN AnidQArH2Kurli2JubFesKp4VPXkwHJAutUBW8TEsSTDGxJ/044u4BvFYcW3BBdJY49gvJ MZYEC6bHf6JWhqZFuQD3moM8uhM2wBrdOjzjH+fi2Ikw9P5qE8DbYC+D6wPOSNapR/bGaX v1lCdsG8bVnNGhq+YfwlV/WWe+ecHgMq5Exq4OdDFU+l1a7tbiIhIO1zRHz6kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1737116812; 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=eVTZsqF/itWNyYr1y+CjRfYcAgVKRe5GzZkoSYn0FD4=; b=Lz+QkelMTV+sXbvTNdf0I96SPl1/5pan6zmwmEVRj4D4P6h7pBxl+qhrRODl+Eujm9qGhA oPCOrIluMLJP3qxd2KYkFV+YZ9pV58qT/SC6onrrG6VchGc8bX7zSEkP2PkHNOL4rtDPJn vCa7u05Qsv8W60YKzZE33Xdls7GNhlQ+zZUuCnnVpffsHPMg5kSpqZ/8pHJR8orK2s4a6z y8+fvjhkS7/IdqF68rMAVeEbdeWVhCsh4SSxU/2VSfOWubEI4K6oX4uNxtQUCuj0cH8aO1 ZN3U3DbzXxeAAb+2jTyz/WwTJKZ+nbR721LXFQOEwTB72+bn1L3bX0DD8g0inQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1737116812; a=rsa-sha256; cv=none; b=rcLDMbJgtAsPQS8pyGX2ceF6/4i2I+B+h7iSS8BOO5Cc4vw4S7U/CM28SLIhyRCHwBI752 aWI5oIcEPDBsM28q8d5Aw84NWyLbBaXBHR0Fvt3m40Zppp+atT2DSr9MOJo+spPqwlpvOl OReVkjt49qyohahootR71e0wtRUiCfVwO0pIxAsdmTaO/VwGjjeQBXB8rHr03JgTqdF44n vqeOIdrbwTw0PmfKZDiPiGYX5LT4ydhnTNtVhfz/4KgLBeZPIJOjbrfqZHAgiQsO6Yw1TT n6UFYCmVhMhnUNQkqqxf/yOoix36heq51hfm6ZiAHINdZv4NJSfUC7uF3WjimA== 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 4YZJrX21f6z2p3; Fri, 17 Jan 2025 12:26:52 +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 50HCQqni051470; Fri, 17 Jan 2025 12:26:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 50HCQq9C051467; Fri, 17 Jan 2025 12:26:52 GMT (envelope-from git) Date: Fri, 17 Jan 2025 12:26:52 GMT Message-Id: <202501171226.50HCQq9C051467@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: 4078a7051ab1 - stable/13 - 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/13 X-Git-Reftype: branch X-Git-Commit: 4078a7051ab146d146e88720fac85ca164af2d4a Auto-Submitted: auto-generated The branch stable/13 has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=4078a7051ab146d146e88720fac85ca164af2d4a commit 4078a7051ab146d146e88720fac85ca164af2d4a Author: Olivier Certner AuthorDate: 2023-09-25 08:48:49 +0000 Commit: Olivier Certner CommitDate: 2025-01-17 12:24:43 +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 66db882ba4f3..f827000d9200 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -558,7 +558,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 114eeeb2a943..413453f9bf8f 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -1049,7 +1049,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 482472025fdd..2dc5ecd00175 100644 --- a/sys/kern/kern_prot.c +++ b/sys/kern/kern_prot.c @@ -2275,17 +2275,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 876919f56fb1..f5e2757f7417 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);