Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2121109iof; Tue, 7 Jun 2022 20:26:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwVjA6Ei1JoayLXUs7mMIj/FjxTQ2pcEC3zZkQlyYEY1J7Fnn5Xi0Lj1RQ2Sxfqig0ILHdN X-Received: by 2002:a17:90b:384a:b0:1e6:9e79:4072 with SMTP id nl10-20020a17090b384a00b001e69e794072mr30847331pjb.10.1654658776136; Tue, 07 Jun 2022 20:26:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654658776; cv=none; d=google.com; s=arc-20160816; b=oS/gZrxcvcn7+XEtYTZ8bDPZh/1Zlyvq0nd6Gj4JxHQJR/ktWBrUW0sD3EakdM00Lm 4XhSg0ur25LqtND6QMc59r2EON88CRfyU5G6udiTHfninaZ2dcTSW4TW255hvyqzyo6j VdAdTKvwjhgK64EtwOTLp0ljDVh0M3AY/AIEVX8ImjwFItXcra+tk0yBcYecIQjBBoeL Ragpw6h4T2UuWRbLegZioGxW9Kgi952mgRfCKH9HSAtJj2ijjTUa6VfRLR4t+bSx2Z0m 9lng2ietT80IGtWBLC9FEAFNAmuUFI5KdzRU9L62ORIQzvZx7Nw8VUTklrg+ZbuA6+0P OCTg== 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=D1svu1UajyfIxNAAPhvM1K9dxBqWyBcnni/EsXMIQgs=; b=ZOeUvoRRXvCVxnmpcJBXMKJs793JSZsS0j/7JRrZAG5c5QETUVOYDFU4v3rBhbkl0W 06tKH/7NgwGKMSH2qU8XjLQVJGbAT3QAjjfAbHIXya0N4Glwngy7/W6iLOhcyu1qByM2 tubbAyhXNPozPTWCtdE5JPWwO3IyC4oB4o5KHS9MN8xP5pxGE1aZrHvpWYpWEYaqojER mene3QrRiALhzxBiXl6SNG5Cf0iGUxcvavtLGjleImM+jErXIqYRjlLh4e5u9FkoHRgf 5PGyRWkByUVY2D5fwR12spJMspojWpaIoMrUjY3oXe4myciF7ZfDtMOG7bXaVJAi69z6 fauA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CRXWGoTM; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id ls17-20020a17090b351100b001e2d210b8ecsi12057973pjb.188.2022.06.07.20.26.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 20:26:16 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CRXWGoTM; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 25600261802; Tue, 7 Jun 2022 19:49:23 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245133AbiFGOwG (ORCPT + 99 others); Tue, 7 Jun 2022 10:52:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343571AbiFGOwE (ORCPT ); Tue, 7 Jun 2022 10:52:04 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CDE7F506F for ; Tue, 7 Jun 2022 07:52:02 -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 ams.source.kernel.org (Postfix) with ESMTPS id 15627B81DB3 for ; Tue, 7 Jun 2022 14:52:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D7974C341C6 for ; Tue, 7 Jun 2022 14:51:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654613519; bh=nUGvY8qp8MLZCpbuA9uMm+tmCRu40sGop9jcJcMRaUs=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=CRXWGoTM5/4em/h+sfJjfc+gPXjWHAbZmBrN+Tm4epCh9HmZwLHweH2mKSnYi9Ne/ YcUJ1NXD+wZtEGYLEB9xWVf8bV7tN9Fs03h+8LzWViNR/gssFtDl1DUeZZ/9icIvco 1/Wh8nKV9XFCFGteHIBiyIBhBUtVBOJ3F8qJpuWw3C59yGI8SDti2ecHMYQwkasjK3 ODSgPa2tExwREyy0OjNYcA/zW7rtOR9kUd+PwI35kJSLAMfHxM7NGtN6w1vo3KqiDM oysrbgHFqf4XJX62JD4ZV7v0wrza4zmdSKhhTGFL3gH4jF5Y4DfH0HLewjYZRv5tw6 jcAMRdPg0hUaQ== Received: by mail-oo1-f42.google.com with SMTP id ay16-20020a056820151000b0041b71517844so1485904oob.4 for ; Tue, 07 Jun 2022 07:51:59 -0700 (PDT) X-Gm-Message-State: AOAM533tRZ6SJK4Nr8DwZTtAiRD7wbb2ewQoFWuBWoKve21UzsXWjlq6 NKSnieJaD0dko3CaPUGZqzef0O8QrB8mfDSN1yM= X-Received: by 2002:a4a:c983:0:b0:41b:9e6f:44ab with SMTP id u3-20020a4ac983000000b0041b9e6f44abmr889002ooq.98.1654613518997; Tue, 07 Jun 2022 07:51:58 -0700 (PDT) MIME-Version: 1.0 References: <20220607111514.755009-1-Jason@zx2c4.com> In-Reply-To: From: Ard Biesheuvel Date: Tue, 7 Jun 2022 16:51:43 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] random: defer use of bootloader randomness to random_init() To: "Jason A. Donenfeld" Cc: Catalin Marinas , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Stephen Boyd , Russell King , Arnd Bergmann , Phil Elwell Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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-kernel@vger.kernel.org On Tue, 7 Jun 2022 at 16:48, Jason A. Donenfeld wrote: > > Hi Ard, > > On Tue, Jun 07, 2022 at 04:19:26PM +0200, Ard Biesheuvel wrote: > > #include > > #include > > #include > > > > static unsigned char buf[16]; > > > > int main(void) > > { > > for (int i = 0; i < 1000000; i++) { > > if (getrandom(buf, sizeof(buf), > > GRND_RANDOM | GRND_NONBLOCK) < sizeof(buf)) { > > fprintf(stderr, "getrandom() error!\n"); > > exit(-1); > > } > > } > > return 0; > > } > > I'm actually more worried about the random input flow than the random > output flow and branch misprediction. But more generally, I'd just like > to keep that code as cold as possible after crng init. It's code that's > only used in that one phase and then never again. It can be entirely > disabled. > > Anyway, we've got a few solutions now to pick from on the random.c side > of things. I'm going to investigate the arm32 situation next. And then > we'll see what it all looks like. > Sure. It would be helpful if some other folks could chime in as well?