Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2070462iof; Tue, 7 Jun 2022 18:46:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+ZvhX9HK/BtOzup0hafShJSiSO96SM751bxIHmDLFywInvUBvLlRidi9fwrx52PiqHcYS X-Received: by 2002:a17:90a:550d:b0:1e2:eb94:588e with SMTP id b13-20020a17090a550d00b001e2eb94588emr35934201pji.15.1654652800446; Tue, 07 Jun 2022 18:46:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654652800; cv=none; d=google.com; s=arc-20160816; b=gRzBklBZYPo3MXgk+k4cCHRxQgx9rFapiTzHiNhhBMvU54jwwaK4m/jN5OBQeo31aW lYMryciRXpuwpyUghcSBJZNo8zCEalKWUYCCPktI3NR4Kcv9xt3aWWtdlha9zFFckN7O DEOLQhdCzDFkyy4mvx5/2Nxu3BIeoulwwazI+vSd8ARaUbUSzCtak+RnWMSFjIsKIMaX qjbe+pcEST/utebC0Dt9oIy+gs5JnyhvknOQiw352O4VmLYiNKBXcaLyWse9iwRxpYNy +L5WmU9/5+17eTElOoa2bP1nf+cx5YCLnTxMvMaEigITb8KAF+5DAW/L+gCbJGjZ+mBz 0Bww== 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=PIkzzbA01Ke1e/RvnsMMOC+0QlwVwbLmLPr3rdaNonU=; b=hTT68Zo67e+TwjrXYIYAWnMi0947a8emC0gg3NW3c2hYboROtoN37lMbLO5EKgZVFX eJetdNVUxb7i5bQ1gCZ+Ik05+wB2aj5Me6zYJ3XbGMjBbm7Kd/qMIxaZZ+rJYdXyW4mB hhgPN5qnQslQzQm2kxh36tpdo1+UTIC/jJJ3YuMA/Wo2cgk8JG1VLHVcjkCzCfJb0K4+ piRk11swi9ESb/7C7/JPNBBATXwgJ/Dy0wlac2Uxr7va7Utd9bNs/potDLpegO5Ypce9 54tCjVVtsWwWOZMm7QvEFp/Liz7ZYi2PzCI6yzxxGG/2IT4ZwoXXGx/OYGl6w7+K/ZMT tyPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NpkMadAV; 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=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id nd3-20020a17090b4cc300b001df5e0b50d9si22619092pjb.151.2022.06.07.18.46.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 18:46:40 -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=@kernel.org header.s=k20201202 header.b=NpkMadAV; 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=kernel.org Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CB908129EC5; Tue, 7 Jun 2022 18:33:57 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242638AbiFGLLu (ORCPT + 99 others); Tue, 7 Jun 2022 07:11:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243338AbiFGLLK (ORCPT ); Tue, 7 Jun 2022 07:11:10 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0265F120B0 for ; Tue, 7 Jun 2022 04:11:09 -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 98FBBB81F68 for ; Tue, 7 Jun 2022 11:11:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 41F2FC385A5 for ; Tue, 7 Jun 2022 11:11:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654600266; bh=PIkzzbA01Ke1e/RvnsMMOC+0QlwVwbLmLPr3rdaNonU=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=NpkMadAVWM+8qyvEpWsUhzhB+bfwyX/YxFEzg6lTh6fkXOfa7vjRQWNPcsCo9L9GC yF8xCzHKzvQed+DO6cYsIgTFLgGkIE4+j282R2+4EOxqz89JM9PKY+0hueMhKvrvu9 M75u5kWdy88pyHNKWnqYewAvL8SX0In4UA23S06Xo/te+8qYIzC1yF+F15a5z9eY58 7AlfvEU8dJ6Weu7H0m6JTbkTiMfY25razWKB42jpSidP6lflLf3NkJ/OtOg3K7RCR3 /hYWLb97qOk5GJ3N8K/Wy+f1+ufg4m+3/PMZyBI6ZDjxbyIjIrYuJcP06GzMY8Qg/V liLERutnYuwcg== Received: by mail-oi1-f176.google.com with SMTP id s8so18161059oib.6 for ; Tue, 07 Jun 2022 04:11:06 -0700 (PDT) X-Gm-Message-State: AOAM532voL2al5PCbmTsFlJAMpAS2BRJ0fFeUgEgnuyEV529ySPQWeCs W+8XvCikQwUrdPFtElPhn+cNvuCL3ecz0rqVV+o= X-Received: by 2002:a05:6808:300e:b0:32c:425e:df34 with SMTP id ay14-20020a056808300e00b0032c425edf34mr16693579oib.126.1654600265478; Tue, 07 Jun 2022 04:11:05 -0700 (PDT) MIME-Version: 1.0 References: <20220607100210.683136-1-Jason@zx2c4.com> In-Reply-To: From: Ard Biesheuvel Date: Tue, 7 Jun 2022 13:10:52 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] random: do not use jump labels before they are initialized To: "Jason A. Donenfeld" Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Stephen Boyd , Catalin Marinas , 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 13:04, Jason A. Donenfeld wrote: > > 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(). Sure. > (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. > Fair enough. What I would like is to remove the need to play around with the placement of jump_label_init() across architectures. Jump labels are fundamentally a performance optimization, so unless you can explain how setting it as early as possible makes a material difference, performance or otherwise, I really think we should pursue a solution that does the static key manipulation at some later time. > >> 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. > Sure. Anything that can be deferred to an initcall() should be, as the early arch code is much too fragile to much around with.