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 2A5C7C43334 for ; Tue, 7 Jun 2022 11:12:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242641AbiFGLLx (ORCPT ); Tue, 7 Jun 2022 07:11:53 -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-Google-Smtp-Source: ABdhPJx1A/CvRWfOQ3GFWIDzS3fTiGPqRgRi8dTUnmjkP0XSzpYtlEYcz6hvOOgD5Zoh3259OdkBrVt9FP81qFpcuLs= 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" 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. 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 0385FC433EF for ; Tue, 7 Jun 2022 11:12:27 +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=wNE9rOwxC0TW56ciJc2obc8BxXwrwHgIJ5t674QpH/o=; b=VsLpNPjnRScc92 YXhAjbSl30K2bovApZAk5VOBqMc5YUWhHOjO/yVe9PFGsaPJRUU2YPtx87Kwe+jbHWgUiH+pgOxZy 9SVc/NvsFPwxUdnSyFRi4KZd17ILV5MnLg6vJz3PveuVGAYMfmdGVXPt3jBL4UteN7bOSOUtVLfhO zcG5dHJugXiGc0iQtYfG0hN2lxEYV3V03SK4zTDkMxGSqTNIKZSdHyCDHXXr8dat/bLC74oq0qTRy GmYaJWQ9lmfNfihAPsTjkqUncFgiVnJUAL8ka0tE4RNljsqahCgKpEc3RKE/oWhfY3vzje3d13QQM GLQDZQWN8GYom7UAsNWA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nyX7B-006xzH-IM; Tue, 07 Jun 2022 11:11:13 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nyX77-006xxj-0o for linux-arm-kernel@lists.infradead.org; Tue, 07 Jun 2022 11:11:10 +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 8C602B81F0D for ; Tue, 7 Jun 2022 11:11:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 54420C3411E 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-f179.google.com with SMTP id i66so23385037oia.11 for ; Tue, 07 Jun 2022 04:11:06 -0700 (PDT) X-Gm-Message-State: AOAM531Z0erHZY5BuaN5/IVjL883a9BJ5Z15ZGcMcpOKFsn0OagRZUJ2 DwjIlcfRTuexOP7jVJPR5AvLG/yHnlvZJyb+vuc= X-Google-Smtp-Source: ABdhPJx1A/CvRWfOQ3GFWIDzS3fTiGPqRgRi8dTUnmjkP0XSzpYtlEYcz6hvOOgD5Zoh3259OdkBrVt9FP81qFpcuLs= 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220607_041109_383697_70A2C5D6 X-CRM114-Status: GOOD ( 32.75 ) 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 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. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel