From nobody Sat Nov 2 20:39:29 2024 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 4XgqN15jZfz5chDW; Sat, 02 Nov 2024 20:39:29 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XgqN13YCXz44B0; Sat, 2 Nov 2024 20:39:29 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730579969; 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=0FgxX+rHOYbpMPpxUAcJPxANxi/di3Eh+uNHPR1+csc=; b=bKhIX4+hxKS/MwkHc348bwgSFvwz/4D1RrLEJQZXE/eowbunEWp4/rblIDQJIj20lm3cIY J7w6gsAJDDJa9f+Pw8eMtraPGEi0zQc+6B9oQdRFYuvRWvJsLL9Fj1qY9K7w1Lh/TvSBh6 BiBvjcTwcHppyIQRnGH6X7YIw6snNazNhhNyJiIBGRZMrBw/YfvLUe1cTPKvyhe2zIZy+T SAW4vjrIv2OtRunVdqddziQYLcaL2XFIatHNzyjMzf/M/eY5QW0FXgmKS6H5YaLwJQKBAt saa1SpgQCXna+gA+aPuLivm4lvC3weboGcjUYyxcrDEDQgSL4BWxz9THO8Oq6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730579969; 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=0FgxX+rHOYbpMPpxUAcJPxANxi/di3Eh+uNHPR1+csc=; b=dj944A/qnmdRysP4ChgHTLrFZVn6VrW8WSmF7nQIDvndoFp+Yuhmj0IwgvwgbAaflPWgH6 ZGL0Rd6UJIBzIgCpDXRoPUdfrlBKqSK2nkrImM7mOX3qg9rAOCpLLpuog/HxThB5AcIuOk 8vy0XsEybTQnG8lKcC7EKEUEtXdEkapMzFtmo0kTYdb8WYYcts/heVjkEgiFa2OSdMSkRN 1KnZnRehA7KoeEZsB9keBzXb3vzyzFTNGO/iBb/0Kp+WAjFEQq6BLuBqhHvYLhZyQssihT akalkeW1vY7pEl0XJz6q3fp1b2RUJWJhZiKIPPy9yTDDd7ogFQgiFEqgrGsp3w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1730579969; a=rsa-sha256; cv=none; b=i3bp5JWTQjA1aHaMrPUTegK+coDu1zuIVpfJI1eEa0i3VaZNZK8PhoOh7lrFAJtGUQfQl0 7UyFDmOC+9IuM5Ly4i3Ww8cKHf+1pnhMoBS5v9isl8qVnOp5GEkKgZ+wsNB9c1hf1umIzo rXfpDPV8AB9Z6x6J8lqpwsAeRJ2pUfYwVskrFHTFj2XEebAk7nMbaXjLfVygr46Wn+8keb TacX5EamhGkFGZIWmHH5xTg7AtTqsnfCDglVM8yj6LFwipHoIBFb8h13mUZaIjR8gnEfYJ P5m3YstPKYXZYtYAuPG86c+dE9SbjkKIemMLfmG3fCeSd1uhi+q5ooPwJFaCOQ== 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 4XgqN139g2zKQn; Sat, 2 Nov 2024 20:39:29 +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 4A2KdT7b046208; Sat, 2 Nov 2024 20:39:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4A2KdTCl046205; Sat, 2 Nov 2024 20:39:29 GMT (envelope-from git) Date: Sat, 2 Nov 2024 20:39:29 GMT Message-Id: <202411022039.4A2KdTCl046205@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Olivier Certner Subject: git: 664b9fcb1c05 - main - cred: Separate constant for the number of inlined groups 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/main X-Git-Reftype: branch X-Git-Commit: 664b9fcb1c051c17ba11d1e5e8a1db9938d76bd5 Auto-Submitted: auto-generated The branch main has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=664b9fcb1c051c17ba11d1e5e8a1db9938d76bd5 commit 664b9fcb1c051c17ba11d1e5e8a1db9938d76bd5 Author: Olivier Certner AuthorDate: 2024-07-16 20:37:44 +0000 Commit: Olivier Certner CommitDate: 2024-11-02 20:37:40 +0000 cred: Separate constant for the number of inlined groups CRED_SMALLGROUPS_NB now holds the number of inlined groups in field 'cr_smallgroups'. XU_NGROUPS stays the number of groups allowed in 'struct xucred'. The first is an implementation detail, while the second is part of a public interface. All mentions of XU_NGROUPS in the tree have been reviewed and only those concerning the implementation detail have been changed to use CRED_SMALLGROUPS_NB (they were all in 'kern_prot.c'). No functional change, as CRED_SMALLGROUPS_NB is set to 16, the same value as XU_NGROUPS. Reviewed by: mhorne (slightly different version) Approved by: markj (mentor) MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D46911 --- sys/kern/kern_prot.c | 6 +++--- sys/sys/ucred.h | 12 ++++++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/sys/kern/kern_prot.c b/sys/kern/kern_prot.c index ed20950b12e5..7ca08c3cf490 100644 --- a/sys/kern/kern_prot.c +++ b/sys/kern/kern_prot.c @@ -811,7 +811,7 @@ struct setgroups_args { int sys_setgroups(struct thread *td, struct setgroups_args *uap) { - gid_t smallgroups[XU_NGROUPS]; + gid_t smallgroups[CRED_SMALLGROUPS_NB]; gid_t *groups; int gidsetsize, error; @@ -819,7 +819,7 @@ sys_setgroups(struct thread *td, struct setgroups_args *uap) if (gidsetsize > ngroups_max + 1 || gidsetsize < 0) return (EINVAL); - if (gidsetsize > XU_NGROUPS) + if (gidsetsize > CRED_SMALLGROUPS_NB) groups = malloc(gidsetsize * sizeof(gid_t), M_TEMP, M_WAITOK); else groups = smallgroups; @@ -828,7 +828,7 @@ sys_setgroups(struct thread *td, struct setgroups_args *uap) if (error == 0) error = kern_setgroups(td, gidsetsize, groups); - if (gidsetsize > XU_NGROUPS) + if (gidsetsize > CRED_SMALLGROUPS_NB) free(groups, M_TEMP); return (error); } diff --git a/sys/sys/ucred.h b/sys/sys/ucred.h index 9fb3c63bbfdf..4311a73b73a5 100644 --- a/sys/sys/ucred.h +++ b/sys/sys/ucred.h @@ -42,6 +42,14 @@ struct loginclass; #define XU_NGROUPS 16 +#if defined(_KERNEL) || defined(_WANT_UCRED) +/* + * Number of groups inlined in 'struct ucred'. It must stay reasonably low as + * it is also used by some functions to allocate an array of this size on the + * stack. + */ +#define CRED_SMALLGROUPS_NB 16 + /* * Credentials. * @@ -55,7 +63,6 @@ struct loginclass; * * See "Credential management" comment in kern_prot.c for more information. */ -#if defined(_KERNEL) || defined(_WANT_UCRED) struct ucred { struct mtx cr_mtx; long cr_ref; /* (c) reference count */ @@ -78,7 +85,8 @@ struct ucred { struct label *cr_label; /* MAC label */ gid_t *cr_groups; /* groups */ int cr_agroups; /* Available groups */ - gid_t cr_smallgroups[XU_NGROUPS]; /* storage for small groups */ + /* storage for small groups */ + gid_t cr_smallgroups[CRED_SMALLGROUPS_NB]; }; #define NOCRED ((struct ucred *)0) /* no credential available */ #define FSCRED ((struct ucred *)-1) /* filesystem credential */