aboutsummaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorLawrence Stewart <lstewart@FreeBSD.org>2021-03-24 04:25:49 +0000
committerLawrence Stewart <lstewart@FreeBSD.org>2021-03-24 05:14:58 +0000
commitdbbf3e3f37d67d3eae0931855f8b62b9b299b80a (patch)
tree0b18513509bf267880edd1f2e67ac6062ee467a8 /share
parent64c01719e476923fe1b24e5a6c6012a677cd017f (diff)
downloadsrc-dbbf3e3f37d67d3eae0931855f8b62b9b299b80a.tar.gz
src-dbbf3e3f37d67d3eae0931855f8b62b9b299b80a.zip
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
Diffstat (limited to 'share')
-rw-r--r--share/man/man9/random.925
1 files changed, 14 insertions, 11 deletions
diff --git a/share/man/man9/random.9 b/share/man/man9/random.9
index fb5f2156df16..1c5f962b1363 100644
--- a/share/man/man9/random.9
+++ b/share/man/man9/random.9
@@ -26,7 +26,7 @@
.\"
.\" $FreeBSD$
.\" "
-.Dd December 26, 2019
+.Dd March 22, 2021
.Dt RANDOM 9
.Os
.Sh NAME
@@ -132,17 +132,13 @@ If the function is interrupted before the random device is seeded, no data is
returned.
.Pp
The deprecated
-.Xr random 9
-function will produce a sequence of pseudorandom numbers using a similar weak
-linear congruential generator as
-.Xr rand 3
-(the 1988 Park-Miller LCG).
+.Fn random
+function will return a 31-bit value.
It is obsolete and scheduled to be removed in
-.Fx 13.0 .
-It is strongly advised that the
-.Xr random 9
-function not be used to generate random numbers.
-See
+.Fx 14.0 .
+Consider
+.Xr prng 9
+instead and see
.Sx SECURITY CONSIDERATIONS .
.Sh RETURN VALUES
The
@@ -167,6 +163,13 @@ the number of bytes placed in
.Fn read_random_uio
returns zero when successful,
otherwise an error code is returned.
+.Pp
+.Fn random
+returns numbers
+in the range from 0 to
+.if t 2\u\s731\s10\d\(mi1.
+.if n (2**31)\(mi1.
+
.Sh ERRORS
.Fn read_random_uio
may fail if: