Sync with OpenBSD:

arc4random.c: In the incredibly unbelievable circumstance where
_rs_init() fails to allocate pages, don't call abort() because of
corefile data leakage concerns, but simply _exit().  The reasoning
is _rs_init() will only fail if someone finds a way to apply
specific pressure against this failure point, for the purpose of
leaking information into a core which they can read.  We don't
need a corefile in this instance to debug that.  So take this
"lever" away from whoever in the future wants to do that.

arc4random.3: reference random(4)

arc4random_uniform.c: include stdint.h over sys/types.h
This commit is contained in:
Xin LI 2020-04-13 08:42:13 +00:00
parent 3133002560
commit d25a143055
3 changed files with 9 additions and 7 deletions

View File

@ -1,4 +1,4 @@
.\" $OpenBSD: arc4random.3,v 1.35 2014/11/25 16:45:24 millert Exp $
.\" $OpenBSD: arc4random.3,v 1.37 2019/09/29 16:30:35 jmc Exp $
.\"
.\" Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
.\" All rights reserved.
@ -31,7 +31,7 @@
.\" Manual page, using -mandoc macros
.\" $FreeBSD$
.\"
.Dd April 10, 2020
.Dd April 13, 2020
.Dt ARC4RANDOM 3
.Os
.Sh NAME
@ -71,7 +71,9 @@ On each call, a cryptographic pseudo-random number generator is used
to generate a new result.
One data pool is used for all consumers in a process, so that consumption
under program flow can act as additional stirring.
The subsystem is re-seeded from the kernel random number subsystem using
The subsystem is re-seeded from the kernel
.Xr random 4
subsystem using
.Xr getentropy 2
on a regular basis, and also upon
.Xr fork 2 .

View File

@ -1,4 +1,4 @@
/* $OpenBSD: arc4random.c,v 1.54 2015/09/13 08:31:47 guenther Exp $ */
/* $OpenBSD: arc4random.c,v 1.55 2019/03/24 17:56:54 deraadt Exp $ */
/*
* Copyright (c) 1996, David Mazieres <dm@uun.org>
@ -84,7 +84,7 @@ _rs_init(u_char *buf, size_t n)
if (rs == NULL) {
if (_rs_allocate(&rs, &rsx) == -1)
abort();
_exit(1);
}
chacha_keysetup(&rsx->rs_chacha, buf, KEYSZ * 8);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: arc4random_uniform.c,v 1.2 2015/09/13 08:31:47 guenther Exp $ */
/* $OpenBSD: arc4random_uniform.c,v 1.3 2019/01/20 02:59:07 bcook Exp $ */
/*
* Copyright (c) 2008, Damien Miller <djm@openbsd.org>
@ -18,7 +18,7 @@
* $FreeBSD$
*/
#include <sys/types.h>
#include <stdint.h>
#include <stdlib.h>
/*