Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp3687018pxp; Wed, 23 Mar 2022 03:58:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDejDht1y2kxr9BLq2T3fPyc7m8ummqRNw5stvPTFYGNaadjJ7xoPTrpYac23RcvdYgg8u X-Received: by 2002:a05:6a00:298c:b0:4fa:8e7b:349d with SMTP id cj12-20020a056a00298c00b004fa8e7b349dmr19124852pfb.26.1648033082308; Wed, 23 Mar 2022 03:58:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648033082; cv=none; d=google.com; s=arc-20160816; b=POQ6+QMcySBhJUs2A604xRqYmDMZrVLCMdAVgDvt0MJxCBZ4oeW2PW6DRKpX6NLcia ATODQNcfgUfhrLs7HF4Rf2FuafDlENlHCxs7anRK+WLEeK5F84DwK8qDEspuAX9N4K43 AubZy++P9EuJ/LQaz54mUBnSSRFkrvzgyzwWU/oQy54TirPa13HDj7IwntteNPYJD59y Yg8pe1A/SIFXgjfUseM06Fw4FFyT3oJ6aSAX34Saawq+Se9hMq7b0sQfh0M3T1+5i6sJ AkcuaFAVO2v78tXbsvR+71zJG+IqlPMFnwItWdGq1nee0ex5P7Ks+fYmEH6IPzY9+pwY jw8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=+OgOG70Y1f1mBLxR/354i0rSjmpUoBZxt6ajEOLq/MQ=; b=HmZxyYqYvpsOpp2Cbp89WuBLJQTLAHLgkAu50p+VX5nrs4OTnuiAZpYdDQbu9it3Ee EnqopRXChBjp8JJ1WYrieUw3VooQQaLPMmqHup4O3oJ6DI6+uq0d19oWfnokpehax9Uy iRujIh8CPPPeXhEVCmP1IUv8BFh+cZZM7dlj+eqOUykRxxTvLDkXytUKx4N+5WrTimrE ZVu2S6Oqw0ZRYvRgsc7VRTTwl09Vj4D3QyiSL25bIyjtOzrBaQc52e0Ie4u9cNaKz7I6 YKbrhDY8cHqPlCn1R3wQHRGwjcAyQdKphpgKFs/JeKHePnB7L1npOpvnFt+HX/tAAutf 4v3Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mit.edu Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e4-20020a63ae44000000b003729ecc3ae7si19647217pgp.2.2022.03.23.03.57.50; Wed, 23 Mar 2022 03:58:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mit.edu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241547AbiCWDhQ (ORCPT + 99 others); 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> X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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