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 441F6C433EF for ; Tue, 7 Jun 2022 14:52:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343568AbiFGOwG (ORCPT ); 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-Google-Smtp-Source: ABdhPJy7N2gw3L1N+nkZAsBmhvp5r0K2l+ufRiclF6nmLKyCbQ/Muh6ib8LV02EZM9XOPq7KMeJLtAPs9Z/Z7ZdWe54= 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" 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?