Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2105720iof; Tue, 7 Jun 2022 19:56:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgX6AA++Ud/Pw2OvDNHPGcvwfa5UhXE3nEwzDq4nBKynoy79yDKF+mHd3QYB2Wy/GURIV/ X-Received: by 2002:a05:6a00:2293:b0:51c:155a:1868 with SMTP id f19-20020a056a00229300b0051c155a1868mr14260653pfe.79.1654656994498; Tue, 07 Jun 2022 19:56:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654656994; cv=none; d=google.com; s=arc-20160816; b=niBEmmCs910CkxkRWlNSNcqUt3GtHya1P5FuPKRUhRXoKjFoLwbTSoAFOy0ztCMHSg 3fDWV7qJU42V0JMFIcFy6KJV/GYlFt783vG2SRZPhAEhdnVL7ai8F83a596KEEpe5WdF ELFeXJrS7BOuCkIEpUoRTNbXUtnAlW5oHm9pbhDD2ukztp92+oOBXcX4y3dgzAfV+z7V Mo0FlAV6Q7ZtgLdQLnCEdUmgzo/Or+aork5mWpGlsD0eaPTtMCLrPAvfxox133gu97kX zlBNBn1lupVIjUlh5gPmcecO0Y6S7s67zrl8yII1VyuFDDGC+aNUejixF6TGqVVuDsUU InHQ== 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=4Na1QxItsDzfUviMSrEXGmi8fosYGZhD1mBHh/enj5s=; b=0psiOedJNoUUO6CMvf8bSXEXKNs/KELil2xfI2wdztVwu1tUoGXDIQelR0v4YsADY9 jVea4sQ5ihKTudnSUrOw2UYGN/O16MoUdkoSHGOlHWbY8+hTxx2F7PIt5Or4rwf3hVry JDhKPA3UwR13DZZpv3OWCs50gWEPqlT9APS+TMVPiDZsWsCiIZDMT3UgvFKOoEHbbqFB h1ygJB7jnUpdjBStNHA+AfU+jMGr8/z6YymVlqk+VsiuelFSMMcKFVcXQitNphlfCca4 EK16NS0QpFDpuxLOk6fNwLDRCwO+bA2v9tpy3YiD1PFpQdTKChelKe95r7K5cw5ip1Y1 Cd8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=T3dW7Kqe; 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 j13-20020a056a00234d00b00518b91753b2si32642427pfj.207.2022.06.07.19.56.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 19:56:34 -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=T3dW7Kqe; 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 5AD87329363; Tue, 7 Jun 2022 18:47:05 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243666AbiFGMWk (ORCPT + 99 others); Tue, 7 Jun 2022 08:22:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243660AbiFGMWI (ORCPT ); Tue, 7 Jun 2022 08:22:08 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2407EFB43F for ; Tue, 7 Jun 2022 05:21:28 -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 AFFDC61774 for ; Tue, 7 Jun 2022 12:21:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1E1E7C34119 for ; Tue, 7 Jun 2022 12:21:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654604487; bh=ksFFNe7xm0oX79tCDDomZZrarZbbV5nWWlbLyEOTlgw=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=T3dW7KqeOlbw6vNZ+A1ENczdRQnjOofrTjCfa9nO9hGXI+Ry4NR9hBt+dTF9Etins FNF+8i64Vc2Uced8qWB33PXka4jNAPDQIDqPoqzK1pSpOY9yuOc13pbaBpXz3OOx5/ e/yihUo/0B0WkLwUmcQGSdrMwXaY1VXNdaYJNhRKrevuAJopct2zitPJZaT0ocQ5dq lnzJROuCAuP09nOlB6uULbg3+a0W3Hdu5KMYNFGNPIOG9BtBTkxcYLXtv6KjQMeQgO /rtoLnutJXxs+vUBa+NIYSq+xyOoS50xC5deWAXHtyIARaNexlWMkzjBNKXTtpn9Ei JYe9jrvcXGplw== Received: by mail-oa1-f53.google.com with SMTP id 586e51a60fabf-f2e0a41009so22922718fac.6 for ; Tue, 07 Jun 2022 05:21:27 -0700 (PDT) X-Gm-Message-State: AOAM531L/B1jwcktANunt4k7wAVM1pHS6WdHWZg18rHBBjEh4hbanUm5 eGW7vdFNRPhbtBv/f14CNDNz3oNTc6FXL2zEPUs= X-Received: by 2002:a05:6871:5c8:b0:f3:3c1c:126f with SMTP id v8-20020a05687105c800b000f33c1c126fmr16341810oan.126.1654604486249; Tue, 07 Jun 2022 05:21:26 -0700 (PDT) MIME-Version: 1.0 References: <20220607100210.683136-1-Jason@zx2c4.com> In-Reply-To: From: Ard Biesheuvel Date: Tue, 7 Jun 2022 14:21:13 +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 14:16, Jason A. Donenfeld wrote: > > Hi Ard, > > On Tue, Jun 07, 2022 at 02:03:28PM +0200, Ard Biesheuvel wrote: > > On Tue, 7 Jun 2022 at 13:35, Jason A. Donenfeld wrote: > > > > > > Hi Ard, > > > > > > On Tue, Jun 07, 2022 at 01:10:52PM +0200, Ard Biesheuvel wrote: > > > > 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. > > > > > > Alright. It sounds like Catalin also prefers the same. This seems simple > > > enough with minimal downsides: https://lore.kernel.org/lkml/20220607113238.769088-1-Jason@zx2c4.com/ > > > > > > > That looks simple enough. Do we risk causing any boot stalls due to > > the crediting being deferred? Or new warnings about randomness being > > used before CRNG is ready? > > We don't risk boot stalls. But there will be warnings for developers who > have enabled the CONFIG_WARN_ALL_UNSEEDED_RANDOM debug option. > > > > > So maybe we should just go that route. > > > > > > > It is not my preferred approach, but I can live with it. > > I'm not sure what your preferred approach is at this point in time > actually. I'll summarize all the approaches discussed so far: > > 1) Fix archs to initialize jump labels earlier: > https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git/commit/?id=73e2d827a501 > https://lore.kernel.org/lkml/20220603121543.360283-1-Jason@zx2c4.com/ > > 2) Defer mixing & crediting until random_init(): > https://lore.kernel.org/lkml/20220607111514.755009-1-Jason@zx2c4.com/ > > 3) Defer crediting (but not mixing) until random_init(): > https://lore.kernel.org/lkml/20220607113238.769088-1-Jason@zx2c4.com/ > > 4) Defer changing the static branch (but neither mixing nor crediting) until random_init(): > https://lore.kernel.org/lkml/20220607100210.683136-1-Jason@zx2c4.com/ > > > My first choice is (1) if it's feasible. > > (2) is not possible without introducing a copy, so that's out. > > What's your preferred approach? Or is there a number 5 you have in mind? > Seems like we need a mutex instead of going back concurrently on two different threads :-) I'll shut up now and wait for your reply on the other thread.