HomeFreeBSD

cred: crextend(): Harden, simplify

Description

cred: crextend(): Harden, simplify

Harden by adding more assertions, and a plain panic in case of an
unrepresentable size for the groups array (this can never happen after
the change of the 'kern.ngroups' computation to impose some not too high
maximum value a few commits ago). Fix an impact in kern_setgroups().

Simplify by removing the iterative process whose purpose is actually to
determine the closest power of two that is greater than the wanted
number of bytes. Using the proper target quantity (number of bytes)
incidentally helps with eliminating divisions (and the reliance on
sizeof(gid_t) being a power of two).

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

Details

Provenance
olceAuthored on Oct 1 2024, 2:37 PM
Reviewer
mhorne
Differential Revision
D46915: cred: crextend(): Harden, simplify
Parents
rG634675067867: cred: groupmember() and co.: Sanity check cred's groups (INVARIANTS)
Branches
Unknown
Tags
Unknown