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

(cherry picked from commit ea26c0e797525634dd25dede233ff2ded053cf2d)

Approved by: markj (mentor)

Details

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