From nobody Mon Feb 21 08:07:44 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 9510F19C91DD; Mon, 21 Feb 2022 08:07:44 +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 4K2FKD3Gsnz3qH9; Mon, 21 Feb 2022 08:07:44 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645430864; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=aT0erMfGNGNNI9VLAhyeKhwTAk0AdCspxiU1Sp8vByE=; b=NIdqTNgsPwiofAHSHxKS4BiCetwprDhci4YhiPgg70ZPdyfny2nlnJr9eIYWsgl74OPx0P TTpJdMlUwgW2ou+XuPUUaISttjWw0jNPcdAHl49gBjf667Y39klssV0z8nbfp+Gy0Azn0J 2R5wsOdSmqJmcRY4a8d7lkXTct9TCrca5wM+8mMSqVgbntmnJvYsdaQN4uOKKGI4LbC8ZR gApD90yzGP+MrK3C6pH6fGcvu4qWUbdFxBffkR8xaoUZyz1//DP6m16CbAku63iCaPsUZh iEvZuL2Tjfc019fsSE/rgVkS3+dC5ZMGtG3zgJKy3TdSMTE6DYMwNtMxCsFUxg== 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 36F6D4B00; Mon, 21 Feb 2022 08:07:44 +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 21L87ihj036969; Mon, 21 Feb 2022 08:07:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 21L87iiZ036968; Mon, 21 Feb 2022 08:07:44 GMT (envelope-from git) Date: Mon, 21 Feb 2022 08:07:44 GMT Message-Id: <202202210807.21L87iiZ036968@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: c91dd7ea7cd7 - stable/12 - random(4): Don't complain noisily when an entropy source is slow List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org 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: c91dd7ea7cd70b6b42693a3acb987173c63ec5bb Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645430864; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=aT0erMfGNGNNI9VLAhyeKhwTAk0AdCspxiU1Sp8vByE=; b=ZOuS20POv9VrOHdKc21rUCWTMCCTvt4/5dcY9qZ0fIkxKQLZnHDZmN1OScuZ/nNcXX0fDe cKtbCMnZX0P5KzkpFPN6/eiNUa+owWUIOiWgPxyKSyfz5M8LOw2vcXSTcnW7N8AIvF3R/d 1CYor1Z7BMMGrroCARFShnSfRyrixxhFS22yqr2N4LgR4g3SqWKfNmC5YP287gFsZZ0Vk+ dVglwS7SLiQMAezZsu6yTzGGr85CKC3Sfd28H9dzsq0iRQednMBl3hcaopbiF7WEkslH7H yVd+pV/ZMlKSP573wGEXXqIL4KIefzl2/IqZHltuuguV1LB07syHZRewj7UkhA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1645430864; a=rsa-sha256; cv=none; b=YumoXwExI5GwWbdnx2s8uFJduapJu9eMqH+l3HVQsO0l/YpBDr4IaRYxJ1NJXFNoAFwW5C Bp1EMmDj0yzgXcCPlc9ISW3V1jWvXCZiRkYOOmf32ha1hsiE9qrg51608RpW9IKfbwhRNL DbQK+rFovRZppAePiRUeyPjct01Uo0YCu9tJrxpU1px/wvrZd5ZgRiFfeMko0d6RgLCwTx tVYG89HsVZjzdIcfHQ0MqWqoqUzB1xl6rhQf8FcQe9qcyPOlfm9Or/qg/JIlaxID9U3xc9 aIm02tH1yhp2+DzWyH7gVy4gwP7InO6xFvxsoClkgKTlBkZ5fhnBHbIn3BnoKQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by obrien: URL: https://cgit.FreeBSD.org/src/commit/?id=c91dd7ea7cd70b6b42693a3acb987173c63ec5bb commit c91dd7ea7cd70b6b42693a3acb987173c63ec5bb Author: Conrad Meyer AuthorDate: 2019-05-08 14:54:32 +0000 Commit: David E. O'Brien CommitDate: 2022-02-21 05:56:42 +0000 random(4): Don't complain noisily when an entropy source is slow Mjg@ reports that RDSEED (r347239) causes a lot of logspam from this printf, and I don't feel that it is especially useful (even ratelimited). There are many other quality/quantity checks we're not performing on entropy sources; lack of high frequency availability does not disqualify a good entropy source. There is some discussion in the linked Differential about what logging might be appropriate and/or polling policy for slower TRNG sources. Please feel free to chime in if you have opinions. (cherry picked from commit e01ada5c44c66db8e1f7ed2c1f5622a794a1c43b) --- sys/dev/random/random_harvestq.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/sys/dev/random/random_harvestq.c b/sys/dev/random/random_harvestq.c index d98730d0054f..bb9ec5e4cea0 100644 --- a/sys/dev/random/random_harvestq.c +++ b/sys/dev/random/random_harvestq.c @@ -254,15 +254,19 @@ random_sources_feed(void) for (i = 0; i < npools; i++) { n = rrs->rrs_source->rs_read(entropy, sizeof(entropy)); KASSERT((n <= sizeof(entropy)), ("%s: rs_read returned too much data (%u > %zu)", __func__, n, sizeof(entropy))); - /* It would appear that in some circumstances (e.g. virtualisation), - * the underlying hardware entropy source might not always return - * random numbers. Accept this but make a noise. If too much happens, - * can that source be trusted? + /* + * Sometimes the HW entropy source doesn't have anything + * ready for us. This isn't necessarily untrustworthy. + * We don't perform any other verification of an entropy + * source (i.e., length is allowed to be anywhere from 1 + * to sizeof(entropy), quality is unchecked, etc), so + * don't balk verbosely at slow random sources either. + * There are reports that RDSEED on x86 metal falls + * behind the rate at which we query it, for example. + * But it's still a better entropy source than RDRAND. */ - if (n == 0) { - printf("%s: rs_read for hardware device '%s' returned no entropy.\n", __func__, rrs->rrs_source->rs_ident); + if (n == 0) continue; - } random_harvest_direct(entropy, n, rrs->rrs_source->rs_source); } }