Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1162913pxb; Thu, 24 Mar 2022 14:06:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJys0bADK1WXiZ2Ds/JpVWHOPaPaSW5ayPQAYnw/nWdQLsiyFslv5MJdqAPxrRTYrzJPgqfg X-Received: by 2002:a05:6402:c81:b0:410:a329:e27a with SMTP id cm1-20020a0564020c8100b00410a329e27amr8966274edb.142.1648155993758; Thu, 24 Mar 2022 14:06:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648155993; cv=none; d=google.com; s=arc-20160816; b=0+mBtVFuzf/nRRprqRZE+aBDpzejYdGd2mXesLUYSOz7oLvaoBBXZff77A12AY4cF5 wTgFFxbSgwsGDpXJdhM8D8HbsRJR/6CD2zVHtDC5vcuHa6ofNLTWFNR6vK8ruFaqT6sT l1uJTuDmAe/myaeLGTUb0gdY3l7BJG54xUqWvZvm+U/K2rwETnzjqfY/cbWR070jig7W smungKcXfsstewXs4Z45Drev6WqI8S9lIwGz3RbBXV6lHCVtCDQpU2A28EFb/xImpvu6 BBeBhmZHKEV3JaeqBs4yE49GalNz9j5mlp5PId4z19VvtbSKLZmzI6Li8a1I35S/MfXm bkmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=UPQk2+AwvYlLOgDZBiyRkQyYynYshkiAeWdfpfXI7xs=; b=oyng2X01qKG0PWXwQMvRk48HXudpQfw2IVhCxc13w01KWcZ/QkAIjS9ZS9OVxaw3Mq Za8yO+4QEWfuTNIyCwGgoZ+MhxZiGajr1fBxG46j84Rp0UAmxHSxFgZicJmY5rRT7o7F i2joTH0vKlvnJ5uMkoFYsRvob1yo2tdg8XecllLDeGibhctPkmEzcF/2lUtYxkQGqhkV qCv+P6iKl4inaRGDzuJER89gdIR4/j5X4x2ZzQrz2LUSwF/+AGU49gaytjm1SGD1YMGI 7A6VvKa4Tq1zArW/oBlBCp9wLPmhCIoza7LEmQTBUGKndGVkpppOEI2p44Qfawzqmp3Q IdmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=T+Pp99yb; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c12-20020a50f60c000000b00418c2b5be05si904871edn.231.2022.03.24.14.06.06; Thu, 24 Mar 2022 14:06:33 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=T+Pp99yb; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345034AbiCWV6D (ORCPT + 99 others); Wed, 23 Mar 2022 17:58:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242437AbiCWV6C (ORCPT ); Wed, 23 Mar 2022 17:58:02 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E33A8C7E5; Wed, 23 Mar 2022 14:56:32 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D3211616DF; Wed, 23 Mar 2022 21:56:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3CAFEC340EE; Wed, 23 Mar 2022 21:56:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1648072591; bh=DV/xwXjMs6yUzKDL7xfk7T0Q7lFV5SMLpVQvsFGK4IE=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=T+Pp99yb0nkYq7lonLADQdVHW8DZSZo43gBJ0MHaXQDDZ4G3WkpOKmJSGEFhVfNtl atgYQSE2/ODqcpKNbDNBi/wW7KqMgNgf0HoVqZ0Pt0eKnJFH9iQMXCEkJ5v/L6W9zR VKfXxlIZYWcQp5mqvb/qH8aWLKMbnRy+Bgv5INP2sgpLIIiDZsjTLoS6GZv8KBP+1g 6ITYL8fvrPV/w+FE9KTF5yxqDgol9OCIUzDJlr9iRhzb0MI9KuFi5mtQ12SQnGQI/m WOIUCxd1du0WfiTmM5oZd6Kkz0wO4eke4MXC9Nu644xqE65/mtLgpGEYBgv+E47n8q EhvFs0vLZkBVw== Received: by mail-ot1-f42.google.com with SMTP id o20-20020a9d7194000000b005cb20cf4f1bso2020389otj.7; Wed, 23 Mar 2022 14:56:31 -0700 (PDT) X-Gm-Message-State: AOAM530a/nUurZyiSOVCr1vhGZkgsJBB5bgXnU1mgW86glqWG+yXnMjt 5obANLTcEQhM7VXl2aaUTsSsBb1Ak1wr60KDDYY= X-Received: by 2002:a05:6830:2e7:b0:5b2:68c1:182a with SMTP id r7-20020a05683002e700b005b268c1182amr913494ote.71.1648072590332; Wed, 23 Mar 2022 14:56:30 -0700 (PDT) MIME-Version: 1.0 References: <20220323041123.146459-1-Jason@zx2c4.com> In-Reply-To: <20220323041123.146459-1-Jason@zx2c4.com> From: Ard Biesheuvel Date: Wed, 23 Mar 2022 22:56:19 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] random: treat bootloader trust toggle the same way as cpu trust toggle To: "Jason A. Donenfeld" Cc: Linux Kernel Mailing List , Linux Crypto Mailing List , Dominik Brodowski , "Theodore Ts'o" , Graham Christensen Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 On Wed, 23 Mar 2022 at 05:11, Jason A. Donenfeld wrote: > > If CONFIG_RANDOM_TRUST_CPU is set, the RNG initializes using RDRAND. > But, the user can disable (or enable) this behavior by setting > `random.trust_cpu=0/1` on the kernel command line. This allows system > builders to do reasonable things while avoiding howls from tinfoil > hatters. (Or vice versa.) > > CONFIG_RANDOM_TRUST_BOOTLOADER is basically the same thing, but regards > the seed passed via EFI or device tree, which might come from RDRAND or > a TPM or somewhere else. In order to allow distros to more easily enable > this while avoiding those same howls (or vice versa), this commit adds > the corresponding `random.trust_bootloader=0/1` toggle. > > Cc: Dominik Brodowski > Cc: Theodore Ts'o > Cc: Graham Christensen > Link: https://github.com/NixOS/nixpkgs/pull/165355 > Signed-off-by: Jason A. Donenfeld Reviewed-by: Ard Biesheuvel > --- > drivers/char/random.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/drivers/char/random.c b/drivers/char/random.c > index 7b7f5e6596c2..c8974e5f57e1 100644 > --- a/drivers/char/random.c > +++ b/drivers/char/random.c > @@ -948,11 +948,17 @@ static bool drain_entropy(void *buf, size_t nbytes, bool force) > **********************************************************************/ > > static bool trust_cpu __ro_after_init = IS_ENABLED(CONFIG_RANDOM_TRUST_CPU); > +static bool trust_bootloader __ro_after_init = IS_ENABLED(CONFIG_RANDOM_TRUST_BOOTLOADER); > static int __init parse_trust_cpu(char *arg) > { > return kstrtobool(arg, &trust_cpu); > } > +static int __init parse_trust_bootloader(char *arg) > +{ > + return kstrtobool(arg, &trust_bootloader); > +} > early_param("random.trust_cpu", parse_trust_cpu); > +early_param("random.trust_bootloader", parse_trust_bootloader); > > /* > * The first collection of entropy occurs at system boot while interrupts > @@ -1160,7 +1166,7 @@ EXPORT_SYMBOL_GPL(add_hwgenerator_randomness); > */ > void add_bootloader_randomness(const void *buf, size_t size) > { > - if (IS_ENABLED(CONFIG_RANDOM_TRUST_BOOTLOADER)) > + if (trust_bootloader) > add_hwgenerator_randomness(buf, size, size * 8); > else > add_device_randomness(buf, size); > -- > 2.35.1 >