X-Received: by 2002:a17:90b:2496:b0:1b9:a6dd:ae7 with SMTP id nt22-20020a17090b249600b001b9a6dd0ae7mr2399835pjb.35.1645507408671; Mon, 21 Feb 2022 21:23:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645507408; cv=none; d=google.com; s=arc-20160816; b=WU2LOIhf5iEp2baOe7rnEqwmIoZCBG+O04WkfAtcreE4HA755J8Ul4SoJYxC2NXmPY WQSDNzNmDZlkZ8O1Ixy0O1cx8T16ISow7lZ7iBPg9Ban5qgF0aOkKj6CMQ9nx0iDrJwL Qha61kdBiwY6E7MKkT86c9t2FtHhe3ynYzgG0ykHDwJ7e1cJM/CqFbdS/Gq/lDUU3zro akusbA8KMKSvXxdtudF9D76D/333GActHOImYWKYlF86Hcg3RSQayY9lU7TP6+AoLJgb y8pHBt8MFOfB65uJEKsBy8KuB97DrSHfy2SH09sllCd9QRRbWIkaRfoPPj/vVWNEsP7y Ncjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:date:references:in-reply-to :message-id:mime-version:user-agent:dkim-signature; bh=vBUAoZ3UzQQOZ472PP5USbXMOxs9lLadAR07/aQaOWw=; b=qxWLvNbGpQAX3R6rUtgoKlLyhpJBUsqMnFf0Fwhbn0cuzvi3I/v1SRM4HTk08DuSUk FtBIDs6ekcBDEerM6glMgEgkRpD2Z33LjlqcXqcfScaOOhkX/TxemVJBudrejo/wJQ98 vGlzXOKGoA3YdkjEjo+mvp19WU8mPaCvAk/Zfb96o+JAc6B5V5jrCghw8J8f2aJrNWHZ glV3my8tGWzZKpoQMalp7qP382NCk+KCQxIWI0z5tBRkPV3ksRbre8hIGVEAB4hLFan/ Zj5ctDd+nvy5AT3qUAZYGN1CCHCl6Tz6MlwdYqhWzKq/0Drdqfpa1u13+v60Voq/xRPh EXow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="O/vRl4W+"; spf=softfail (google.com: domain of transitioning linux-crypto-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id s12-20020a17090a5d0c00b001b9975f431esi1073918pji.158.2022.02.21.21.23.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 21:23:28 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-crypto-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="O/vRl4W+"; spf=softfail (google.com: domain of transitioning linux-crypto-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C60CCFDF87; Mon, 21 Feb 2022 20:54:20 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229865AbiBUSOQ (ORCPT + 99 others); Mon, 21 Feb 2022 13:14:16 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:41404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232277AbiBUSLk (ORCPT ); Mon, 21 Feb 2022 13:11:40 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61B2B13DFA for ; Mon, 21 Feb 2022 10:02:06 -0800 (PST) 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 DBE82B81369 for ; Mon, 21 Feb 2022 18:02:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 27E24C340F1; Mon, 21 Feb 2022 18:02:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645466523; bh=1o//f7ci38Nltr9ZStFH8Ui/1ANWC7noWUcvVsxH4Dk=; h=In-Reply-To:References:Date:From:To:Cc:Subject:From; b=O/vRl4W+1q3OlItbDWSIT1wpSOf+ke+C7ZG3LvL0E8Ya+3/aZd9JcNcVisu3jckU0 6sbYLe74cjvHHDMv8RnWlk5rBR1EOVZIGMboUNzvw4cJDnPk/2X52CjsYCEn65ZP9L 1jikMaz56J0R+vmkyJTLNY1ZN0ifhA0wlQmJHoPx/4CLp/b0mMktJUZkYIGqXptfWx wLKcajj5/CDlapJ1A9YwGJOZK80GD/T6iWV1Ps8xJofVKspQVK3dkoDfWcGiIBVO70 ESAI4GM2Si1Nk030GEry7hHcn0i4RBdSvZ/3ox5sr7Y+J7MEhoVAom/tcuoj7Nvvk9 Bx8kmNoE88v7A== Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailauth.nyi.internal (Postfix) with ESMTP id C58BF27C005C; Mon, 21 Feb 2022 13:02:00 -0500 (EST) Received: from imap48 ([10.202.2.98]) by compute5.internal (MEProxy); Mon, 21 Feb 2022 13:02:00 -0500 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrkeeigddutdeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgesthdtredtreertdenucfhrhhomhepfdetnhgu hicunfhuthhomhhirhhskhhifdcuoehluhhtoheskhgvrhhnvghlrdhorhhgqeenucggtf frrghtthgvrhhnpeffffekfeeuueffkedvueeujeduledvteefveevvdeftdfhtdegfeej geehveefudenucffohhmrghinhepuhhrrghnughomhdruggvvhdpshgvrhhvvghrrdguvg hvnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghn ugihodhmvghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdduudeiudekheeifedvqd dvieefudeiiedtkedqlhhuthhopeepkhgvrhhnvghlrdhorhhgsehlihhnuhigrdhluhht ohdruhhs X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 01C9B21E006E; Mon, 21 Feb 2022 13:01:57 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-4778-g14fba9972e-fm-20220217.001-g14fba997 Mime-Version: 1.0 Message-Id: <6e117393-9c2f-441c-9c72-62c209643622@www.fastmail.com> In-Reply-To: <20220217162848.303601-1-Jason@zx2c4.com> References: <20220217162848.303601-1-Jason@zx2c4.com> Date: Mon, 21 Feb 2022 10:01:37 -0800 From: "Andy Lutomirski" To: "Jason A. Donenfeld" , "Linux Kernel Mailing List" , "Linux Crypto Mailing List" , linux-arch@vger.kernel.org Cc: "Dinh Nguyen" , "Nick Hu" , "Max Filippov" , "Palmer Dabbelt" , "David S . Miller" , "Yoshinori Sato" , "Michal Simek" , "Borislav Petkov" , "Guo Ren" , "Geert Uytterhoeven" , "Joshua Kinard" , "David Laight" , "Dominik Brodowski" , "Eric Biggers" , "Ard Biesheuvel" , "Arnd Bergmann" , "Thomas Gleixner" , "Kees Cook" , "Lennart Poettering" , "Konstantin Ryabitsev" , "Linus Torvalds" , "Greg Kroah-Hartman" , "Theodore Ts'o" Subject: Re: [PATCH v1] random: block in /dev/urandom Content-Type: text/plain X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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-crypto@vger.kernel.org On Thu, Feb 17, 2022, at 8:28 AM, Jason A. Donenfeld wrote: > This topic has come up countless times, and usually doesn't go anywhere. > This time I thought I'd bring it up with a slightly narrower focus, > updated for some developments over the last three years: we finally can > make /dev/urandom always secure, in light of the fact that our RNG is > now always seeded. > > Ever since Linus' 50ee7529ec45 ("random: try to actively add entropy > rather than passively wait for it"), the RNG does a haveged-style jitter > dance around the scheduler, in order to produce entropy (and credit it) > for the case when we're stuck in wait_for_random_bytes(). How ever you > feel about the Linus Jitter Dance is beside the point: it's been there > for three years and usually gets the RNG initialized in a second or so. > > As a matter of fact, this is what happens currently when people use > getrandom(). It's already there and working, and most people have been > using it for years without realizing. > > So, given that the kernel has grown this mechanism for seeding itself > from nothing, and that this procedure happens pretty fast, maybe there's > no point any longer in having /dev/urandom give insecure bytes. In the > past we didn't want the boot process to deadlock, which was > understandable. But now, in the worst case, a second goes by, and the > problem is resolved. It seems like maybe we're finally at a point when > we can get rid of the infamous "urandom read hole". > This patch is 100% about a historical mistake. Way back when (not actually that long ago), there were two usable interfaces to the random number generator: /dev/random and /dev/urandom. /dev/random was, at least in principle, secure, but it blocked unnecessarily and was, therefore, incredibly slow. It was totally unsuitable for repeated use by any sort of server. /dev/urandom didn't block but was insecure if called too early. *But* urandom was also the correct interface to get best-effort-i-need-them-right-now random bits. The actual semantics that general crypography users wanted were not available. Fast forward to today. /dev/random has the correct semantics for cryptographic purposes. getrandom() also has the correct semantics for cryptographic purposes and is reliable as such -- it is guaranteed to either not exist or to DTRT. And best-effort users can use GRND_INSECURE or /dev/urandom. If we imagine that every user program we care about uses GRND_INSECURE for best-effort and /dev/random or getrandom() without GRND_INSECURE for cryptography, then we're in great shape and this patch is irrelevant. But we don't get to rely on that. New kernels are supposed to be compatible with old userspace. And with *old* userspace, we do not know whether /dev/urandom users want cryptographically secure output or whether they want insecure output. And there is this window during boot that lasts, supposedly, up to 1 second, there is a massive difference. [0] So, sorry, this patch is an ABI break. You're reinterpreting any program that wanted best-effort randomness right after boot as wanting cryptographic randomness, this can delay boot by up to a second [0], and that's more than enough delay to be considered a break. So I don't like this without a stronger justification and a clearer compatibility story. I could *maybe* get on board if you had a urandom=insecure boot option to switch back to the old behavior and a very clear message like "random: startup of %s is delayed. Set urandom=insecure for faster boot if you do not need cryptographically secure urandom during boot", but I don't think this patch is okay otherwise. Or we stick with the status quo and make the warning clearer. "random: %s us using insecure urandom output. Fix it to use getrandom() or /dev/rando as appropriate." [0] I just booted 5.16 in a Skylake -rdrand,-rdseed VM and it took 1.14 seconds to initialize.