From d25a14305552adad86417c87d09e3ed791fbe835 Mon Sep 17 00:00:00 2001 From: Xin LI Date: Mon, 13 Apr 2020 08:42:13 +0000 Subject: [PATCH] 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 --- lib/libc/gen/arc4random.3 | 8 +++++--- lib/libc/gen/arc4random.c | 4 ++-- lib/libc/gen/arc4random_uniform.c | 4 ++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/libc/gen/arc4random.3 b/lib/libc/gen/arc4random.3 index 00fd88086197..8082b70ea1c9 100644 --- a/lib/libc/gen/arc4random.3 +++ b/lib/libc/gen/arc4random.3 @@ -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 .\" 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 . diff --git a/lib/libc/gen/arc4random.c b/lib/libc/gen/arc4random.c index 86e16e3aa857..bbcfee21d002 100644 --- a/lib/libc/gen/arc4random.c +++ b/lib/libc/gen/arc4random.c @@ -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 @@ -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); diff --git a/lib/libc/gen/arc4random_uniform.c b/lib/libc/gen/arc4random_uniform.c index 0136c66e3289..5f5e190790b0 100644 --- a/lib/libc/gen/arc4random_uniform.c +++ b/lib/libc/gen/arc4random_uniform.c @@ -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 @@ -18,7 +18,7 @@ * $FreeBSD$ */ -#include +#include #include /*