Message ID | 20200921075857.4424-16-nstange@suse.de (mailing list archive) |
---|---|
State | Not Applicable |
Delegated to: | Herbert Xu |
Headers | show
Return-Path: <SRS0=YoIG=C6=vger.kernel.org=linux-crypto-owner@kernel.org> Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2003B139A for <patchwork-linux-crypto@patchwork.kernel.org>; Mon, 21 Sep 2020 08:00:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0FFAF214F1 for <patchwork-linux-crypto@patchwork.kernel.org>; Mon, 21 Sep 2020 08:00:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726674AbgIUIAO (ORCPT <rfc822;patchwork-linux-crypto@patchwork.kernel.org>); Mon, 21 Sep 2020 04:00:14 -0400 Received: from mx2.suse.de ([195.135.220.15]:57298 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726506AbgIUH7X (ORCPT <rfc822;linux-crypto@vger.kernel.org>); Mon, 21 Sep 2020 03:59:23 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id C919BB512; Mon, 21 Sep 2020 07:59:57 +0000 (UTC) From: Nicolai Stange <nstange@suse.de> To: "Theodore Y. Ts'o" <tytso@mit.edu> Cc: linux-crypto@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>, Arnd Bergmann <arnd@arndb.de>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, "Eric W. Biederman" <ebiederm@xmission.com>, "Alexander E. Patrakov" <patrakov@gmail.com>, "Ahmed S. Darwish" <darwish.07@gmail.com>, Willy Tarreau <w@1wt.eu>, Matthew Garrett <mjg59@srcf.ucam.org>, Vito Caputo <vcaputo@pengaru.com>, Andreas Dilger <adilger.kernel@dilger.ca>, Jan Kara <jack@suse.cz>, Ray Strode <rstrode@redhat.com>, William Jon McCann <mccann@jhu.edu>, zhangjs <zachary@baishancloud.com>, Andy Lutomirski <luto@kernel.org>, Florian Weimer <fweimer@redhat.com>, Lennart Poettering <mzxreary@0pointer.de>, Peter Matthias <matthias.peter@bsi.bund.de>, Marcelo Henrique Cerri <marcelo.cerri@canonical.com>, Roman Drahtmueller <draht@schaltsekun.de>, Neil Horman <nhorman@redhat.com>, Randy Dunlap <rdunlap@infradead.org>, Julia Lawall <julia.lawall@inria.fr>, Dan Carpenter <dan.carpenter@oracle.com>, Andy Lavr <andy.lavr@gmail.com>, Eric Biggers <ebiggers@kernel.org>, "Jason A. Donenfeld" <Jason@zx2c4.com>, =?utf-8?q?Stephan_M=C3=BCller?= <smueller@chronox.de>, Torsten Duwe <duwe@suse.de>, Petr Tesarik <ptesarik@suse.cz>, Nicolai Stange <nstange@suse.de> Subject: [RFC PATCH 15/41] random: convert add_hwgenerator_randomness() to queued_entropy API Date: Mon, 21 Sep 2020 09:58:31 +0200 Message-Id: <20200921075857.4424-16-nstange@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200921075857.4424-1-nstange@suse.de> References: <20200921075857.4424-1-nstange@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-crypto.vger.kernel.org> X-Mailing-List: linux-crypto@vger.kernel.org |
Series |
random: possible ways towards NIST SP800-90B compliance
|
expand
|
diff --git a/drivers/char/random.c b/drivers/char/random.c index 60ce185d7b2d..78e65367ea86 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -2640,6 +2640,7 @@ void add_hwgenerator_randomness(const char *buffer, size_t count, size_t entropy) { struct entropy_store *poolp = &input_pool; + struct queued_entropy q = { 0 }; if (unlikely(crng_init == 0)) { crng_fast_load(buffer, count); @@ -2652,8 +2653,9 @@ void add_hwgenerator_randomness(const char *buffer, size_t count, */ wait_event_interruptible(random_write_wait, kthread_should_stop() || ENTROPY_BITS(&input_pool) <= random_write_wakeup_bits); + queue_entropy(poolp, &q, entropy << ENTROPY_SHIFT); mix_pool_bytes(poolp, buffer, count); - credit_entropy_bits(poolp, entropy); + dispatch_queued_entropy(poolp, &q); } EXPORT_SYMBOL_GPL(add_hwgenerator_randomness);
In an effort to drop credit_entropy_bits() in favor of the new queue_entropy()/dispatch_queued_entropy() API, convert add_hwgenerator_randomness() from the former to the latter. As a side effect, the pool entropy watermark as tracked over the duration of the mix_pool_bytes() operation is now taken correctly taken into account when calulating the amount of new entropy to dispatch to the pool based on the latter's fill level. Signed-off-by: Nicolai Stange <nstange@suse.de> --- drivers/char/random.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)