HomeFreeBSD

cred: convert the refcount from int to long

Description

cred: convert the refcount from int to long

On 64-bit platforms this sorts out worries about mitigating bugs which
overflow the counter, all while not pessimizng anything -- most notably
it avoids whacking per-thread operation in favor of refcount(9) API.

The struct already had two instances of 4 byte padding with 256 bytes in
size, cr_flags gets moved around to avoid growing it.

32-bit platforms could also get the extended counter, but I did not do
it as one day(tm) the mutex protecting centralized operation should be
replaced with atomics and 64-bit ops on 32-bit platforms remain quite
penalizing.

While worries of counter overflow are addressed, the following is not
(just like it would not be with conversion to refcount(9)):

  • counter *underflows*
  • buffer overruns from adjacent allocations
  • UAF due to stale cred pointer
  • .. and other goodies

As such, while lipstick was placed, the pig should not be participating
in any beauty pageants.

Prodded by: emaste
Differential Revision: https://reviews.freebsd.org/D39220

Details

Provenance
mjgAuthored on Mar 22 2023, 8:42 PM
Differential Revision
D39220: cred: convert the refcount from int to long
Parents
rG21d29c519221: cred: make the refcount signed
Branches
Unknown
Tags
Unknown