From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C28113B592; Thu, 23 May 2024 10:02:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716458531; cv=none; b=qg7SDnltq/fpLe4a1TeyrhMPUv/POUG6MdixcqafhAGauoRtAu0119sq8ZGUJ3Py0Vp68ZySfh3oyzDC8R5cl/rwz3tFwW9aQUd3AZ7TqC5o5NxtNmKP2932wMGyWuSmg0A9Xm7UYIWufsN8mtLlmoPMh/PYmAPZFYlC9lVSYSA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716458531; c=relaxed/simple; bh=UPgFW9vuL3g5qypadrRDJdjIEzGJX3EMLiS63N0hICM=; h=Mime-Version:Content-Type:Date:Message-Id:From:To:Cc:Subject: References:In-Reply-To; b=S6vqVPp6vJ7LhmdO4MisnaAEYcj2QdGe4V+tVI0HwwXjtz5eqDIYtWJFMbWwhDK1bDoaIb9pCfmeVm8xVHj015gBOqmkt68qlr7wTnuQRHApRK6KYD8lF9lld1qT7QB0fGPytaDp6g82s0MKFqdgXOL1Z7/qSmdBUSLFS8zrrcI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dR7zJ40l; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dR7zJ40l" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E295EC2BD10; Thu, 23 May 2024 10:02:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716458530; bh=UPgFW9vuL3g5qypadrRDJdjIEzGJX3EMLiS63N0hICM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=dR7zJ40lwquVtY7dVKnnYTIz+66EOJk8cFguLQ4mvLH7tQIZ8lgnKOJKCoCLjXUoh 8cocuvw4pJt7A1VanISjFFVDDKu5hgPXgg510vMUYaH/ODAaM9WWv9X/cptiNx/sp8 cni4bMODk/lWLV9RX0KxO53rpboDWMis3NzCeh2/xG8VK9ehCv6Pdsq7eAtOuz4Nal KS8jWCj7sa/hPUncnTHA3IOLy4RVYHogYbG4HvC0CKVmtIrQKqwjzHt6p1MPPujPCq HOOoYAdO84c6DyqtFAJf8x0xIK0xegDPKzin27kYfQ5gNdlAsB8kr4MPXdP3VNOcem KyCh8iakZNFug== Precedence: bulk X-Mailing-List: linux-integrity@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Thu, 23 May 2024 13:02:05 +0300 Message-Id: From: "Jarkko Sakkinen" To: "Jarkko Sakkinen" , "Herbert Xu" , "Linus Torvalds" Cc: =?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= , "Eric Biggers" , "James Bottomley" , "Ard Biesheuvel" , "Linux Crypto Mailing List" , , , , , "Tejun Heo" , "Linux Kernel Mailing List" , "Kees Cook" , "Torsten Duwe" , "H. Peter Anvin" , "Theodore Ts'o" , "Jason A. Donenfeld" Subject: Re: [v3 PATCH] hwrng: core - Remove add_early_randomness X-Mailer: aerc 0.17.0 References: <66ec985f3ee229135bf748f1b0874d5367a74d7f.camel@HansenPartnership.com> <20240518043115.GA53815@sol.localdomain> <00bcfa65-384d-46ae-ab8b-30f12487928b@notapiano> <07512097-8198-4a84-b166-ef9809c2913b@notapiano> In-Reply-To: On Thu May 23, 2024 at 12:53 PM EEST, Jarkko Sakkinen wrote: > On Thu May 23, 2024 at 7:49 AM EEST, Herbert Xu wrote: > > On Wed, May 22, 2024 at 03:53:23PM -0700, Linus Torvalds wrote: > > >=20 > > > That said, looking at the code in question, there are other oddities > > > going on. Even the "we found a favorite new rng" case looks rather > > > strange. The thread we use - nice and asynchronous - seems to sleep > > > only if the randomness source is emptied. > > >=20 > > > What if you have a really good source of hw randomness? That looks > > > like a busy loop to me, but hopefully I'm missing something obvious. > > > > Yes that does look strange. So I dug up the original patch at > > > > https://lore.kernel.org/all/20140317165012.GC1763@lst.de/ > > > > and therein lies the answer. It's relying on random.c to push back > > when the amount of new entropy exceeds what it needs. IOW we will > > sleep via add_hwgenerator_randomness when random.c decides that > > enough is enough. In fact the rate is much less now compared to > > when the patch was first applied. > > Just throwing something because came to mind, not a serious suggestion. > > In crypto_larval_lookup I see statements like this: > > request_module("crypto-%s", name); > > You could potentially bake up a section/table to vmlinux which would > have entries like: > > "module name", 1/0 > > '1' would mean built-in. Then for early randomness use only stuff > that is built-in. > > Came to mind from arch/x86/realmode for which I baked in a table > for relocation (this was a collaborative work with H. Peter Anvin > in 2012 to make trampoline code relocatable but is still a legit > example to do such shenanigans in a subystem). This could be even parameter in __request_module() itself e.g. int __request_module(bool wait, bool builtin_only, const char *fmt, ...); And would not matter which initcall layer we are running at. BR, Jarkko