git: 216460b80674 - stable/14 - linux: setgroups(): Avoid allocation under the process lock

From: Olivier Certner <olce_at_FreeBSD.org>
Date: Fri, 10 Oct 2025 17:16:19 UTC
The branch stable/14 has been updated by olce:

URL: https://cgit.FreeBSD.org/src/commit/?id=216460b806742c8c0a97aec2c9a689a17c564beb

commit 216460b806742c8c0a97aec2c9a689a17c564beb
Author:     Olivier Certner <olce@FreeBSD.org>
AuthorDate: 2025-08-28 15:47:38 +0000
Commit:     Olivier Certner <olce@FreeBSD.org>
CommitDate: 2025-10-10 17:15:56 +0000

    linux: setgroups(): Avoid allocation under the process lock
    
    This was missed in commit 838d9858251e ("Rework the credential code to
    support larger values of NGROUPS (...)").
    
    No functional change (intended).
    
    MFC after:      5 days
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D52278
    
    (cherry picked from commit b7a87d7c0dd19016e82f5d33f2c5ec90479c31fe)
---
 sys/compat/linux/linux_misc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c
index 855c1d885164..2ae10a487813 100644
--- a/sys/compat/linux/linux_misc.c
+++ b/sys/compat/linux/linux_misc.c
@@ -1044,8 +1044,7 @@ linux_setgroups(struct thread *td, struct linux_setgroups_args *args)
 	crextend(newcred, ngrp + 1);
 	p = td->td_proc;
 	PROC_LOCK(p);
-	oldcred = p->p_ucred;
-	crcopy(newcred, oldcred);
+	oldcred = crcopysafe(p, newcred);
 
 	/*
 	 * cr_groups[0] holds egid. Setting the whole set from