From nobody Fri Nov 15 13:00:46 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 4XqcZl2sfpz5d6gP; Fri, 15 Nov 2024 13:00:47 +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 4XqcZk6wzrz4pPg; Fri, 15 Nov 2024 13:00:46 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1731675647; 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=E3w1PMNFtK2EAqgvZe5b+Xzdz9BD6RQ09kv5Bs0eMjc=; b=W2frEA8jQPnwJlzEJbqQETfjzVh1nDpqwYVZ3+iukJC6uBIGVPmEqnuqIKSInXYzYH3zLQ JHgQ+uWqyr799mzkUABtFU/MhcYW9ZyWXuu5TtCLnZMv8+qOLgpBZrwixqKrQLySmLqbyN MPDrKmIWZFp2agKZeQosq/6ht9jZ4y/gtMc14x/J4i6COA0i8sIGxqUUEJP6BLdblE33VL r0BjHiukX96CeqbjazC2bdQX17zQHEYY+93sFMNfLKhQl6VMWK5Qqp6ON0ll4GuK1q1G+K J5hXzl/5wPRrfGgNPnFm2P5MAUtB5N8CJ1mFrB+wqXLPnsuvBuU5okxVcj3lsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1731675647; 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=E3w1PMNFtK2EAqgvZe5b+Xzdz9BD6RQ09kv5Bs0eMjc=; b=VSah2J6DQftTODFQQjUKriwOWV0IWTJKe/qroNm/cyXD1lGfAUoTyOYbLw++Uh9U36scho jMdymsVXSXlIWCLgpbKpFubrpW8zGWndlUyxC7IBlkGOuKIDZwlm0MCxAZex2+EkXtZRlp tlBqenai/lNybVVU57ZwbQz0yI/UBE2bB/xf/XmvC7z5yA0+cQVEIyXMKSICVchAbE0Crr 7E/XNUcC9QBX68d/RoZoder1wO6bXR/TajBxPuc0SrA1T77URURrkVUbNw9TTMJF28XxAe olvA41nJVf0iuzXi7PWeFuJT6eoizot4yniMLFBhwi+Xe1FZDKEmBdZEbYw0/Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1731675647; a=rsa-sha256; cv=none; b=VQa0Xr/JGIDmyCKs328QWra5La6vJDOxPafrdCmtuVJIbhOWXktkFwK3o2IQ0wDJ1bgnuc 7vJnD7FXpnAL6nbUsBUhJcjmza9fOoM0yQ5ZbQ61c6pvxQ/AYAuvAOrXtZ4zpydriSlbHy 2Igdz1Fy3eGOZNLsOsfGh1MK2mmNFR5xM7G2ybF89SozgqZ2+5fExy/Y1uq6XfE6pBoYb5 nQlkKCjwUSrT/xTimc+4mOxC7BL5Haaf4+O3ke26mZyJJ5nIBI5tN2OKdeKHDNzwz2Ul63 pY5PyHzUcXuTDHleTJtTDDD+XsvDPVShMiU5SmaDaKH1/TmG66RTgeMu8Mo6UQ== 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 4XqcZk6YJ8zP5X; Fri, 15 Nov 2024 13:00:46 +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 4AFD0kVM069938; Fri, 15 Nov 2024 13:00:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4AFD0kvd069934; Fri, 15 Nov 2024 13:00:46 GMT (envelope-from git) Date: Fri, 15 Nov 2024 13:00:46 GMT Message-Id: <202411151300.4AFD0kvd069934@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: 3ce5ef4f7a97 - stable/13 - 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/stable/13 X-Git-Reftype: branch X-Git-Commit: 3ce5ef4f7a97d3e059fba7d6afc60881e8f3fb9f Auto-Submitted: auto-generated The branch stable/13 has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=3ce5ef4f7a97d3e059fba7d6afc60881e8f3fb9f commit 3ce5ef4f7a97d3e059fba7d6afc60881e8f3fb9f Author: Olivier Certner AuthorDate: 2024-07-16 20:37:44 +0000 Commit: Olivier Certner CommitDate: 2024-11-15 12:59:08 +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 (cherry picked from commit 664b9fcb1c051c17ba11d1e5e8a1db9938d76bd5) Approved by: markj (mentor) --- 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 5fdb0a40a425..cb9a2f3c5ae7 100644 --- a/sys/kern/kern_prot.c +++ b/sys/kern/kern_prot.c @@ -807,7 +807,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; @@ -815,7 +815,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; @@ -824,7 +824,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 da0568e9648f..243a2431bd0b 100644 --- a/sys/sys/ucred.h +++ b/sys/sys/ucred.h @@ -44,6 +44,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. * @@ -57,7 +65,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; u_int cr_ref; /* (c) reference count */ @@ -80,7 +87,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 */