Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2182643iof; Tue, 7 Jun 2022 22:26:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxSKpWHx5FKnw91BMAS3tKn2GDKyS6l0QQYm6F3SwfW066eCFV+8JvmNnmcJ4B0mxEUu7EU X-Received: by 2002:a17:90a:550d:b0:1e2:eb94:588e with SMTP id b13-20020a17090a550d00b001e2eb94588emr36718316pji.15.1654665995327; Tue, 07 Jun 2022 22:26:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654665995; cv=none; d=google.com; s=arc-20160816; b=rJstKFj+FYJgwNBP2INqAQd3mcjRS1/AGnxRdHUAOZhzXO8hpl4ub3DWk2rg5e2URK geOMjrNfP2kjqWzYZf9w29w7+mQba/5zFx6BtgK4zE+7FJPDXcz9oUkvmlXrLza1BKSi eMTDZ1J6txL50TmdReNzagrtoagQDAfO5EqoikcvPXqktUyWwSR/zVUeWMpWALwRPlUp iQC9QtZStxb66pOXzTykHkkLAlvF55MWpIFLl3OqoHoUhQbRMa0WFVlBcga7xllFJEWw JlI3kfRQr32OirVCYTuIE2qQ66TEOsbGqCuVdGpRASQqMB/J7p7CsQ7UPR0ji+0BSplX bCLA== 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:dkim-signature; bh=Z70E+/bePHMZXWFc5IMl07eyedk5gGD4ksSfdTvg+YM=; b=wcjJJ8ByUNT0UPvV40QPzofXGN6D5TL4cjWXtouGbadCs/Y1NyzsQAY3N3e6G9Qu72 x7gRZEZjdMFKZaH/9+Wsql65ilK4n3iWIZMx8zJhw/cCBBacA8EyHEYdRCqoKcKiD85D ejCpxpI9c+a7ZDwRdhrXQvjQhymGvF5nSLh1Au2uWvWWVDSWa1sY1Dsi5ewcLIZA+9vF UB5ymFSS2IsP3H058/NKLSnkbD8j+Q2fTaTJxDQCWS/a+4K5nK4qTAuK54+COvvrRoGr 96qp7ax31xoX7K6LCXIyIIJQoE2B+vIWS1K8SZf1ZK+nvIaHvMvy43dtvAnkpxod01DN e99w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=RtzR44g4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zx2c4.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id u186-20020a6385c3000000b003fc98b0a94esi20481353pgd.321.2022.06.07.22.26.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:26:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=RtzR44g4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zx2c4.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E5AEA27FE21; Tue, 7 Jun 2022 21:53:22 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343559AbiFGOsf (ORCPT + 99 others); Tue, 7 Jun 2022 10:48:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343535AbiFGOsY (ORCPT ); Tue, 7 Jun 2022 10:48:24 -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 3B528BCE86 for ; Tue, 7 Jun 2022 07:48:23 -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 BC8A9B8206D for ; Tue, 7 Jun 2022 14:48:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8D266C385A5; Tue, 7 Jun 2022 14:48:19 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="RtzR44g4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1654613298; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Z70E+/bePHMZXWFc5IMl07eyedk5gGD4ksSfdTvg+YM=; b=RtzR44g4nGZGdcERgigfe7dVpjd9fjVB8qtu3KRIR6eM/fXYSfSaYMXyfue0xJIk6qKmjQ tJTWUPoMGZTxdDtQ4T0h0kpJEqLpauFvlpOrOrSmsT/Pt+tCzympbY9UloKBrY683+NTyh Bv4BocTWarxLmW8GTxSkosMdaFZ5FwY= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id ebcf4317 (TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO); Tue, 7 Jun 2022 14:48:17 +0000 (UTC) Date: Tue, 7 Jun 2022 16:48:14 +0200 From: "Jason A. Donenfeld" To: Ard Biesheuvel Cc: Catalin Marinas , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Stephen Boyd , Russell King , Arnd Bergmann , Phil Elwell Subject: Re: [PATCH] random: defer use of bootloader randomness to random_init() Message-ID: References: <20220607111514.755009-1-Jason@zx2c4.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 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. Jason