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 1873EC433EF for ; Tue, 7 Jun 2022 11:06:08 +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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=vzzTps8+LnOVWcUJ9hWIgNSFmE91mGfVxeCMtzH/k00=; b=w1ldFZL6/NWbjN cZ4enAgKvn6vJC1FWbsvgb+Mb5POg5hsXS+d7voFAmCxcAXwj7A8hsrzs11YBOIOgiMFY8GeXPVVK Aj8HLDdA/VPaKjD9qsk8aFGtY+phCs8sYSsKeErYff1BzBpoQGR69N/p7cQwh/0+xSpZYAZqv5TUe es1iLt9DGWA0qfso6a1l+5/lMWSELMdTBE4Ox0rSL/1mNOIJ+qGVBzPY9VjIhkq45El3itLd03H4E bycS3BjnsV0uRtwwqFPnO3Gyg7hPmbgXwxf3LhCYoroY02x27/msPm95bltGTBnfgao9Qk0r77AMi E9SqSTMovaLxp4vheWow==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nyX1C-006vg4-D9; Tue, 07 Jun 2022 11:05:02 +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 1nyX18-006veh-Jx for linux-arm-kernel@lists.infradead.org; Tue, 07 Jun 2022 11:05:00 +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 1648CB81F0D; Tue, 7 Jun 2022 11:04:57 +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-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220607_040459_067430_2683D2B5 X-CRM114-Status: GOOD ( 21.85 ) 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 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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 92EDCC43334 for ; Tue, 7 Jun 2022 11:09:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242675AbiFGLJq (ORCPT ); Tue, 7 Jun 2022 07:09:46 -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: 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