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 20186C433EF for ; Tue, 7 Jun 2022 12:22:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243670AbiFGMWl (ORCPT ); Tue, 7 Jun 2022 08:22:41 -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-Google-Smtp-Source: ABdhPJwF9WaK98yWUyqrrQMSRr8QQvyarEiVENFU+gfpjxrB+sdK+dC0buBYdz8WbuehbhbY3YvjNy1ULHb17/71pOM= 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" 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. 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4DDDCC43334 for ; Tue, 7 Jun 2022 12:22:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=t4kfyBPaF/gBxGwiG7jZNuGVAUn1K9Q3Rmatp7EmjAA=; b=07UBg0hQeQTnKZ G41v50A+86OUybP3Rpe0iurZYPC/mee3+8KvUAPQdkDvTdD6FzHqYCekxmW7nkGR35/Az0l8lLq+c Zn36qxaZ9Ag2NUw1zB8GGU8+IPWO42FT+WeNj7wo9r7jjGBerNCRgAi3ldjAwwRT28kVCuKi7gji5 8TynNmasAkWFGl5V3GJIAt88ErHU1dDF1n8zIGhhpxzJf8v/VZrcgQZejb6XWifJbZyIr34FgIX+G f/5J13Qa5PVSbfdKWt5VKxSVG3Jc+xkqEqG525X6uN1xEuZbyIh0hAe338t4qNBaRe1o5RiIbXD4/ vVRPW8RWjMSTJyPtT1Kg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nyYDG-007Iz3-Vf; Tue, 07 Jun 2022 12:21:35 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nyYDC-007Ixm-Fv for linux-arm-kernel@lists.infradead.org; Tue, 07 Jun 2022 12:21:32 +0000 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 E6518B81F85 for ; Tue, 7 Jun 2022 12:21:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2B67DC341C0 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-f45.google.com with SMTP id 586e51a60fabf-f2cbceefb8so22895181fac.11 for ; Tue, 07 Jun 2022 05:21:27 -0700 (PDT) X-Gm-Message-State: AOAM530SXu/smwpPKr44u5pF/lbFmzdpMs2fQRx0L7rUm3QMIudsuInK wOJn0lzkJ7XXdPVlnbYP7o97WNUll1Dq/nlMwJI= X-Google-Smtp-Source: ABdhPJwF9WaK98yWUyqrrQMSRr8QQvyarEiVENFU+gfpjxrB+sdK+dC0buBYdz8WbuehbhbY3YvjNy1ULHb17/71pOM= 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220607_052130_859313_A3655996 X-CRM114-Status: GOOD ( 31.01 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel