From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4CC17C433F5 for ; Thu, 10 Feb 2022 06:04:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234987AbiBJGEs (ORCPT ); Thu, 10 Feb 2022 01:04:48 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:51604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233149AbiBJGEr (ORCPT ); Thu, 10 Feb 2022 01:04:47 -0500 Received: from isilmar-4.linta.de (isilmar-4.linta.de [136.243.71.142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7E991C5; Wed, 9 Feb 2022 22:04:47 -0800 (PST) X-isilmar-external: YES X-isilmar-external: YES X-isilmar-external: YES X-isilmar-external: YES Received: from owl.dominikbrodowski.net (owl.brodo.linta [10.2.0.111]) by isilmar-4.linta.de (Postfix) with ESMTPSA id 2627D201421; Thu, 10 Feb 2022 06:04:46 +0000 (UTC) Received: by owl.dominikbrodowski.net (Postfix, from userid 1000) id 8EB9D804B3; Thu, 10 Feb 2022 06:43:42 +0100 (CET) Date: Thu, 10 Feb 2022 06:43:42 +0100 From: Dominik Brodowski To: "Jason A. Donenfeld" Cc: Theodore Ts'o , LKML , Linux Crypto Mailing List Subject: Re: [PATCH] random: fix locking for crng_init in crng_reseed() Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Hi Jason, Am Wed, Feb 09, 2022 at 10:39:17PM +0100 schrieb Jason A. Donenfeld: > Thanks, applied. I changed complete_init to finalize_init, to match > our naming scheme from earlier, and I moved > invalidate_batched_entropy() to outside the lock and after > crng_init=2, since now it uses atomics, and it should probably be > ordered after crng_init = 2, so the new batch gets the new entropy. Doesn't that mean that there is a small window where crng_init == 2, but get_random_u64/get_random_u32 still returns old data, with potentially insufficient entropy (as obtained at a time when crng_init was still < 2)? That's why I moved invalidate_batched_entropy() under the lock. But with your subsequent patch, it doesn't matter any more. Thanks, Dominik