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 27616C433EF for ; Wed, 23 Mar 2022 03:35:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241538AbiCWDhQ (ORCPT ); Tue, 22 Mar 2022 23:37:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236272AbiCWDhP (ORCPT ); Tue, 22 Mar 2022 23:37:15 -0400 Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91FFB7087E; Tue, 22 Mar 2022 20:35:46 -0700 (PDT) Received: from cwcc.thunk.org (pool-108-7-220-252.bstnma.fios.verizon.net [108.7.220.252]) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 22N3ZN3u001577 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Mar 2022 23:35:23 -0400 Received: by cwcc.thunk.org (Postfix, from userid 15806) id D2EF915C0038; Tue, 22 Mar 2022 23:35:22 -0400 (EDT) Date: Tue, 22 Mar 2022 23:35:22 -0400 From: "Theodore Ts'o" To: "Jason A. Donenfeld" Cc: linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, Linus Torvalds , Guenter Roeck , Dominik Brodowski , Jann Horn Subject: Re: [PATCH] random: allow writes to /dev/urandom to influence fast init Message-ID: References: <20220322191436.110963-1-Jason@zx2c4.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220322191436.110963-1-Jason@zx2c4.com> Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Tue, Mar 22, 2022 at 01:14:36PM -0600, Jason A. Donenfeld wrote: > So this patch fixes the issue by including /dev/urandom writes as part > of the "fast init", but not crediting it as part of the fast init > counter. This is more or less exactly what's already done for > kernel-sourced entropy whose quality we don't know, when we use > add_device_randomness(), which both contributes to the input pool and to > the fast init key. One of the big issues with /dev/urandom writes is that *anyone*, including malicious user space, can force specific bytes to be mixed in. That's the source of the reluctance to immediate use inputs from writes into /dev/[u]random until there is a chance for it to be mixed in with other entropy which is hopefully not under the control of malicious userspace. Now, I recognize that things are a bit special in early boot, and if we have a malicious script running in a systemd unit script, we might as well go home. But something to consider is whether we want to do soemthing special if the process writing to /dev/[u]random has CAP_SYS_ADMIN, or some such. > There is one caveat to consider, which is what happens if the user > additionally calls RNDADDTOENTCNT after having written to /dev/urandom, > expecting to credit that write. That might give way to this pathological > pattern: Yeah, no one should ever ver ever be using RNDADDTOENTCNT. It's an ioctl which requires root privilegs, and if it breaks, you get to keep both pieces. > The better interface for userspace is RNDADDENTROPY, which takes the > input buffer and the entropy credit all at once, so we can make the > right decision. For the RNDADDENTROPY, we do not take part in fast init > if entropy is being credited. > > And perhaps we might consider attempting to deprecate RNDADDTOENTCNT at > some point in the future. That would be a good idea. :-) - Ted