From owner-svn-src-head@freebsd.org Mon Oct 12 10:42:16 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 168B3433717; Mon, 12 Oct 2020 10:42:16 +0000 (UTC) (envelope-from arichardson@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4C8wGv6jfJz41fy; Mon, 12 Oct 2020 10:42:15 +0000 (UTC) (envelope-from arichardson@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B0430B4A3; Mon, 12 Oct 2020 10:42:15 +0000 (UTC) (envelope-from arichardson@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 09CAgFKY071435; Mon, 12 Oct 2020 10:42:15 GMT (envelope-from arichardson@FreeBSD.org) Received: (from arichardson@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09CAgFYw071433; Mon, 12 Oct 2020 10:42:15 GMT (envelope-from arichardson@FreeBSD.org) Message-Id: <202010121042.09CAgFYw071433@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: arichardson set sender to arichardson@FreeBSD.org using -f From: Alex Richardson Date: Mon, 12 Oct 2020 10:42:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r366632 - head/lib/libc/gen X-SVN-Group: head X-SVN-Commit-Author: arichardson X-SVN-Commit-Paths: head/lib/libc/gen X-SVN-Commit-Revision: 366632 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Oct 2020 10:42:16 -0000 Author: arichardson Date: Mon Oct 12 10:42:14 2020 New Revision: 366632 URL: https://svnweb.freebsd.org/changeset/base/366632 Log: Fix building on Linux/macOS after r366622 We have to bootstrap arc4random.c, so guard the FenestrasX code to avoid using it on Linux/macOS. Reviewed By: cem Differential Revision: https://reviews.freebsd.org/D26738 Modified: head/lib/libc/gen/arc4random.c head/lib/libc/gen/arc4random.h Modified: head/lib/libc/gen/arc4random.c ============================================================================== --- head/lib/libc/gen/arc4random.c Mon Oct 12 09:34:50 2020 (r366631) +++ head/lib/libc/gen/arc4random.c Mon Oct 12 10:42:14 2020 (r366632) @@ -46,6 +46,11 @@ __FBSDID("$FreeBSD$"); #define CHACHA_EMBED #define KEYSTREAM_ONLY +#if defined(__FreeBSD__) +#define ARC4RANDOM_FXRNG 1 +#else +#define ARC4RANDOM_FXRNG 0 +#endif #include "chacha.c" #define minimum(a, b) ((a) < (b) ? (a) : (b)) Modified: head/lib/libc/gen/arc4random.h ============================================================================== --- head/lib/libc/gen/arc4random.h Mon Oct 12 09:34:50 2020 (r366631) +++ head/lib/libc/gen/arc4random.h Mon Oct 12 10:42:14 2020 (r366632) @@ -27,9 +27,11 @@ #include #include #include +#if ARC4RANDOM_FXRNG != 0 #include /* for sys/vdso.h only. */ #include #include +#endif #include #include @@ -37,6 +39,7 @@ #include #include +#if ARC4RANDOM_FXRNG != 0 /* * The kernel root seed version is a 64-bit counter, but we truncate it to a * 32-bit value in userspace for the convenience of 32-bit platforms. 32-bit @@ -51,6 +54,7 @@ */ #define fxrng_load_acq_generation(x) atomic_load_acq_32(x) static struct vdso_fxrng_generation_1 *vdso_fxrngp; +#endif static pthread_mutex_t arc4random_mtx = PTHREAD_MUTEX_INITIALIZER; #define _ARC4_LOCK() \ @@ -74,6 +78,7 @@ _getentropy_fail(void) static inline void _rs_initialize_fxrng(void) { +#if ARC4RANDOM_FXRNG != 0 struct vdso_fxrng_generation_1 *fxrngp; int error; @@ -91,6 +96,7 @@ _rs_initialize_fxrng(void) return; vdso_fxrngp = fxrngp; +#endif } static inline int @@ -131,13 +137,14 @@ _rs_forkdetect(void) /* Detect fork (minherit(2) INHERIT_ZERO). */ if (__predict_false(rs == NULL || rsx == NULL)) return; +#if ARC4RANDOM_FXRNG != 0 /* If present, detect kernel FenestrasX seed version change. */ if (vdso_fxrngp == NULL) return; if (__predict_true(rsx->rs_seed_generation == fxrng_load_acq_generation(&vdso_fxrngp->fx_generation32))) return; - +#endif /* Invalidate rs_buf to force "stir" (reseed). */ memset(rs, 0, sizeof(*rs)); }