From owner-dev-commits-src-all@freebsd.org Fri Aug 6 05:13:36 2021 Return-Path: Delivered-To: dev-commits-src-all@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 1A7F3670A00; Fri, 6 Aug 2021 05:13:36 +0000 (UTC) (envelope-from git@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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Ggtt76S0lz3GRR; Fri, 6 Aug 2021 05:13:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C27CB27CA4; Fri, 6 Aug 2021 05:13:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1765DZ6O000953; Fri, 6 Aug 2021 05:13:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1765DZgo000952; Fri, 6 Aug 2021 05:13:35 GMT (envelope-from git) Date: Fri, 6 Aug 2021 05:13:35 GMT Message-Id: <202108060513.1765DZgo000952@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "David E. O'Brien" Subject: git: 17dc7d3add57 - stable/12 - Fortuna: Add failpoints to simulate initial seeding conditions MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: obrien X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 17dc7d3add57f8aa3bf5091644fb23d06a5b9c9f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Aug 2021 05:13:36 -0000 The branch stable/12 has been updated by obrien: URL: https://cgit.FreeBSD.org/src/commit/?id=17dc7d3add57f8aa3bf5091644fb23d06a5b9c9f commit 17dc7d3add57f8aa3bf5091644fb23d06a5b9c9f Author: Conrad Meyer AuthorDate: 2018-10-26 21:03:57 +0000 Commit: David E. O'Brien CommitDate: 2021-08-06 05:12:16 +0000 Fortuna: Add failpoints to simulate initial seeding conditions Set debug.fail_point.random_fortuna_pre_read=return(1) and debug.fail_point.random_fortuna_seeded=return(1) to return to unseeded status (sort of). See the Differential URL for more detail. The goal is to reproduce e.g. Lev's recent CURRENT report[1] about failing newfs arc4random(3) usage (fixed in r338542). No functional change when failpoints are not set. [1]: https://lists.freebsd.org/pipermail/freebsd-current/2018-September/071067.html Reported by: lev Reviewed by: delphij, markm Approved by: secteam (delphij) Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D17047 (cherry picked from commit 9b8d0fe462b2f3f689cb87fe34bd42c388e23d49) --- sys/dev/random/fortuna.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/sys/dev/random/fortuna.c b/sys/dev/random/fortuna.c index 866899846212..3a46d527fa9a 100644 --- a/sys/dev/random/fortuna.c +++ b/sys/dev/random/fortuna.c @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); #ifdef _KERNEL #include +#include #include #include #include @@ -384,6 +385,18 @@ random_fortuna_pre_read(void) return; } +#ifdef _KERNEL + /* + * When set, pretend we do not have enough entropy to reseed yet. + */ + KFAIL_POINT_CODE(DEBUG_FP, random_fortuna_pre_read, { + if (RETURN_VALUE != 0) { + RANDOM_RESEED_UNLOCK(); + return; + } + }); +#endif + #ifdef _KERNEL fortuna_state.fs_lasttime = now; #endif @@ -442,5 +455,13 @@ bool random_fortuna_seeded(void) { +#ifdef _KERNEL + /* When set, act as if we are not seeded. */ + KFAIL_POINT_CODE(DEBUG_FP, random_fortuna_seeded, { + if (RETURN_VALUE != 0) + fortuna_state.fs_counter = UINT128_ZERO; + }); +#endif + return (!uint128_is_zero(fortuna_state.fs_counter)); }