HomeFreeBSD

cred: kern_setgroups(): Internally use int as number of groups' type

Description

cred: kern_setgroups(): Internally use int as number of groups' type

sys_setgroups() (and sys_getgroups()) was changed in commit "kern: fail
getgroup and setgroup with negative int" (4bc2174a1b48) to take the
number of groups as an 'int' (for sys_getgroups(), POSIX mandates this
change; for sys_setgroups(), which it does not standardize, it's
arguably for consistency).

All our internal APIs related to groups on 'struct ucred', as well as
related members on the latter, treat that number as an 'int' as well
(and not a 'u_int').

Consequently, to avoid surprises, change kern_setgroups() to behave the
same, and fix audit_arg_groupset() accordingly. With that change,
everything is handled with signed integers internally.

Update sanity checks accordingly.

Reviewed by: mhorne
Approved by: markj (mentor)
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D46912

(cherry picked from commit abd39811cd7e4bb928da503f4a5c79364ac8d0f5)

Approved by: markj (mentor)

Details

Provenance
olceAuthored on Oct 1 2024, 4:46 PM
Reviewer
mhorne
Differential Revision
D46912: cred: kern_setgroups(): Internally use int as number of groups' type
Parents
rG3ce5ef4f7a97: cred: Separate constant for the number of inlined groups
Branches
Unknown
Tags
Unknown