Received: by 2002:a05:6358:16cd:b0:dc:6189:e246 with SMTP id r13csp3466630rwl; Sun, 6 Nov 2022 00:10:16 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6WFvlwvmssvffLXlPXcWB/gS8HzdLnab84mYGYbjxj9fiyYtRChfL30azWBps5lH/J6Uw4 X-Received: by 2002:a05:6402:2893:b0:461:59fd:9b4 with SMTP id eg19-20020a056402289300b0046159fd09b4mr43768544edb.389.1667718616470; Sun, 06 Nov 2022 00:10:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667718616; cv=none; d=google.com; s=arc-20160816; b=FlXQmBtLsIrIWxzlTXbztBvONAkoDdkzh1TpppTovFir8GcDbs2a0PtywudrUQfDXL B4GtkJIgezFRdhNHCfF7fdhIxX5zA5TX9+OrN/vxud8ayoMlnpCcWROC9lD8TY/y/84L y5Y4p26/m7MWbdE8TEP0ofdQotyOO5qMTi16S49WJC1pS4IvakH3q07Z346S4lW1AgC9 Q1CzygL6wwcoOCYqx4TZWiuMyfdTe9o5/rNorALrH6RA28mALgmNZ59skZ2272acwW/2 BAUO/wf5CrVFuaWqVyK94YVagl9D7X0fp4LggF3MpbKl63srfc4laEQfb/y1f10MY6Q/ Qu1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=WqhgtIxaqf1CBxJWUl0tudhtYMSij/bRvekP4C19ot0=; b=f8wJbz4JuFbm7fOiaEH1Lp660SfmvlJxE2EYPObjcgbwO6pEabcAIcuDKqtqVkqNST YfHZz9tNSzhASvluJFMIJvU4RMMbysuzdnKPYtjyA/c/7Yt1YXn+C3GmFqrnLZlwQWyV ZL5q1FkZwgBN0f5ieq54bwHdMJrVcmhtgf4E/+UQEwCvXestrTJezhUzosT7KnvN1qQI fZmS4uWxBKma3pnCCnzKHjT38esLcMp/vkhpmFTaWO28kMDDL5KAkaengV5jWVrecwQk FzzKDTIO+PA+gLMWIbH4KctQzfcalGlfgUwsleUOryc4WxJ1Sp0pnYGaK9m2J4VaT6Ti rH4A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n19-20020a170906165300b007806a130086si3677814ejd.302.2022.11.06.00.09.52; Sun, 06 Nov 2022 00:10:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229562AbiKFHFe (ORCPT + 99 others); Sun, 6 Nov 2022 02:05:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229551AbiKFHFd (ORCPT ); Sun, 6 Nov 2022 02:05:33 -0500 X-Greylist: delayed 147 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Sun, 06 Nov 2022 00:05:32 PDT Received: from isilmar-4.linta.de (isilmar-4.linta.de [136.243.71.142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5ED64A45A for ; Sun, 6 Nov 2022 00:05:32 -0700 (PDT) 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 5F2272000B1; Sun, 6 Nov 2022 07:05:30 +0000 (UTC) Received: by owl.dominikbrodowski.net (Postfix, from userid 1000) id 8B69D8010D; Sun, 6 Nov 2022 08:05:25 +0100 (CET) Date: Sun, 6 Nov 2022 08:05:25 +0100 From: Dominik Brodowski To: "Jason A. Donenfeld" Cc: herbert@gondor.apana.org.au, linux-crypto@vger.kernel.org, Ard Biesheuvel Subject: Re: [PATCH] hw_random: treat default_quality as a maximum and default to 1024 Message-ID: References: <20221104154230.52836-1-Jason@zx2c4.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221104154230.52836-1-Jason@zx2c4.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Am Fri, Nov 04, 2022 at 04:42:30PM +0100 schrieb Jason A. Donenfeld: > Most hw_random devices return entropy which is assumed to be of full > quality, but driver authors don't bother setting the quality knob. Some > hw_random devices return less than full quality entropy, and then driver > authors set the quality knob. Therefore, the entropy crediting should be > opt-out rather than opt-in per-driver, to reflect the actual reality on > the ground. > > For example, the two Raspberry Pi RNG drivers produce full entropy > randomness, and both EDK2 and U-Boot's drivers for these treat them as > such. The result is that EFI then uses these numbers and passes the to > Linux, and Linux credits them as boot, thereby initializing the RNG. > Yet, in Linux, the quality knob was never set to anything, and so on the > chance that Linux is booted without EFI, nothing is ever credited. > That's annoying. > > The same pattern appears to repeat itself throughout various drivers. In > fact, very very few drivers have bothered setting quality=1024. > > So let's invert this logic. A hw_random struct's quality knob now > controls the maximum quality a driver can produce, or 0 to specify 1024. > Then, the module-wide switch called "default_quality" is changed to > represent the maximum quality of any driver. By default it's 1024, and > the quality of any particular driver is then given by: > > min(default_quality, rng->quality ?: 1024); > > This way, the user can still turn this off for weird reasons, yet we get > proper crediting for relevant RNGs. Hm. Wouldn't we need to verify that 1024 is appropriate for all drivers where the quality currently is not set? Thanks, Dominik