Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2191019iof; Tue, 7 Jun 2022 22:42:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwL/1XLyfuXVgtNZia32CeHJLL1vSbnWq3itewBu/+0Yas5GBCr5eP29cDtbKcXzPmV6Re/ X-Received: by 2002:a17:90b:3e85:b0:1e8:8f2f:bd2f with SMTP id rj5-20020a17090b3e8500b001e88f2fbd2fmr12513604pjb.120.1654666925690; Tue, 07 Jun 2022 22:42:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654666925; cv=none; d=google.com; s=arc-20160816; b=Pblza1EpAqK8AVT8geD6jNzLE0VpjVh5PnsKD1wozT7l2JHBUGlsbMXBKrZI0Y9cTB p9SMFr6AsDT19js5Q2WfrqPl1OvyaMh3am7k0SAJV0CSvywu/E0U3kIJf0NHArql7kU5 5TQdYW5hMXwbTcSoAKbseVo7aMRfRi2YYmuegauMy+obtgVwnE5cL94GrParkVmeVmYy u1jvC2f3ukum3ISsTb/KsLUzr+pvpQuP6P1RrrT5us8rnTe+8sSOUBpw+aOtwfkh+646 vkZukjD2EgIaKSUJxwtNWcbSh434ApS1WDupq3KUnXUMA2oy5UM9bS3uK58XdhYq2FWv sZdg== 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=pLbg+TRUH6aNHSqlpwLrYjAG/GDDxPAkzL7dlKJUm+U=; b=exYQMK2kYw9HgWxA5LqOuzj4ReDzIcMNbY0PA3mg0CGV1udlPc17tSjB4nOt/vPI4/ HZ0nyt6vni/KH2FhTMDAECYrMWaakM2oS6YlOxucXAPVg7JDOHFyz1Qjw35kjDJWaHy+ vadoxDYL+1JLl1JTGxEj4pVfeMjkYgJDT9UMQ+TWi8wPNr8qUFF2uM+AGZONjHPGLU/D YURy1N5qSp8/7yIboWj3SDtloTQhserKuvQ21O9WqiMag4DMzUnSYOfPnOPTXIaFWGkD gnktMHMLnDXhGjsVA+VvaXJpweRx7DsaECs8ughrhrNb4h1SUnl6TuhhvSUdO5d5PU5q Pbfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=RmRcAWBG; 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 ji1-20020a170903324100b00163915db48fsi22935659plb.304.2022.06.07.22.42.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:42:05 -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=RmRcAWBG; 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 358D738FBAC; Tue, 7 Jun 2022 22:07:40 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242642AbiFGLJo (ORCPT + 99 others); Tue, 7 Jun 2022 07:09:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242566AbiFGLJH (ORCPT ); Tue, 7 Jun 2022 07:09:07 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0D5B11047E for ; Tue, 7 Jun 2022 04:04:56 -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 5BA8761630 for ; Tue, 7 Jun 2022 11:04:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CC647C385A5; Tue, 7 Jun 2022 11:04:54 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="RmRcAWBG" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1654599893; 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=pLbg+TRUH6aNHSqlpwLrYjAG/GDDxPAkzL7dlKJUm+U=; b=RmRcAWBGSH3K7FBjd1mGn0C2bl3pEIa7D0gY/o4J5ba4EU5YNnMsZxUrFHa52s3NBus7Ab U++HjufPsObfnIwyDc93cfeD8zM/fqf35gCyMcwkgtsHCWRsFE8bWN0FpyRnzjW8EYTRe2 cSDW0F1IbcriTJy1zN8muYL773odWXE= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 6df8dc51 (TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO); Tue, 7 Jun 2022 11:04:52 +0000 (UTC) Date: Tue, 7 Jun 2022 13:04:47 +0200 From: "Jason A. Donenfeld" To: Ard Biesheuvel Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Stephen Boyd , Catalin Marinas , Russell King , Arnd Bergmann , Phil Elwell Subject: Re: [PATCH] random: do not use jump labels before they are initialized Message-ID: References: <20220607100210.683136-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 12:56:20PM +0200, Ard Biesheuvel wrote: > Could we do this to defer the static key manipulation? That way, the > first call to crng_reseed() that occurs after the static keys API > becomes available will set the static key, and patch itself away at > the same time. That's almost the same as the patch I just posted, except you pushed the logic down into crng_reseed() instead of credit_init_bits(). (A previous mini-project aimed to remove as much logic as possible from crng_reseed(), counting on those blocks in crng_init_bits() to only ever run once.) What this means is that the static key won't get changed until whenever the next reseeding is. I guess that's "fine" but I think I'd prefer to keep the entropy counting stuff as separate from the init bits stuff as possible. >> As a third, I could just defer doing anything with the bootloader seed >> until random_init(). This might actually be the simplest solution... >> I'll sketch something out. A downside, which might be sort of >> significant, is that a few odd things actually use randomness before >> random_init() is called. So these would miss out on having that seed. >> I'll have to look what exactly to see if we're actually getting anything >> real out of that. >> > > This is kind of the point of using a firmware provided seed, i.e., > that it is available much earlier than anything else. I'll send a patch for this anyway because I'm sort of curious now. Maybe it'll be a dead end, for the reason you mentioned, but I think I'll still try to evaluate it. Jason