HomeFreeBSD

random(9): Restore historical [0,2^31-1] output range and related man

Description

random(9): Restore historical [0,2^31-1] output range and related man
documention.

Commit SVN r364219 / Git 8a0edc914ffd changed random(9) to be a shim around
prng32(9) and inadvertently caused random(9) to begin returning numbers in the
range [0,2^32-1] instead of [0,2^31-1], where the latter has been the documented
range for decades.

The increased output range has been identified as the source of numerous bugs in
code written against the historical output range e.g. ipfw "prob" rules and
stats(3) are known to be affected, and a non-exhaustive audit of the tree
identified other random(9) consumers which are also likely affected.

As random(9) is deprecated and slated for eventual removal in 14.0, consumers
should gradually be audited and migrated to prng(9).

Submitted by: Loic Prylli <lprylli@netflix.com>
Obtained from: Netflix
Reviewed by: cem, delphij, imp
MFC after: 1 day
MFC to: stable/13, releng/13.0
Differential Revision: https://reviews.freebsd.org/D29385

Details

Provenance
lstewartAuthored on Mar 24 2021, 4:25 AM
Reviewer
cem
Differential Revision
D29385: Make random() behaves as documented: "result is uniform in [0, 2^31 - 1]"
Parents
rG64c01719e476: libevent1: fix layout of duplicated RB_ENTRY() definition
Branches
Unknown
Tags
Unknown