Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp3109263pxp; Tue, 22 Mar 2022 12:15:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz466RKsoQJcgphhLSc2bpgppNfOoO9Qgy2fwVqkWADcEyZGoqtLA9ymkh0ut4of4mG21wJ X-Received: by 2002:a05:6a00:26cf:b0:4f6:fc52:7b6a with SMTP id p15-20020a056a0026cf00b004f6fc527b6amr30605263pfw.39.1647976537615; Tue, 22 Mar 2022 12:15:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647976537; cv=none; d=google.com; s=arc-20160816; b=YsAZlD7uBwXOgg5y3y+k1eShDZITBU8FXuCE2jTiHIfsUCMwVIlJGqz79pC/7Y9br3 ayc4ZduA57Svgla8TX9kW2tRIqoL0XTZ5S84bs/yDRZna1C0Ppw79T19Ls6lT0UGOHZq Wup/t047phznRC1woFikQttXw5TGDQj9pNMYOrfYL8r7ajAcmDDFD2cYcyPrCdagZS/T 0D5Fo+Dv+QfaRudrgenn9vBgRjEPN5UvCl3fx0yPYCfTfbmNzDSS+jMtlEyRh4+ucXOU V/KiM6ZVf7fZugNdkBL1Tj5F+c2tgWA4eMB5WH974KJZWCWboylFaWVx2ng9k/LGEZRD 43ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=PFNl2hhMhFSK/CjCgits39oiGFWK73F16o9EWoPZX7Y=; b=MCEqzwQfAyrA1ubqDkfo35fV5fAPnIg7faEeIPDtoWdUPa+UsOIrnatevThpTxRKyQ 98io1NPof3UHkZ7CeuXJtFL/WIpEww8bBec/Pw3WD1XddtxXyBdlTprehNflO7u3ZRcd kqbQhldnGVCGr87knkauIhfiNja0BdAN/82KhrUqVw9voQUnV5XM+4/4E+wpEKDvA0Ob VIV0Frm2KdIgdO9DZ7GFgE59dFvxJkXiki2Xl2d8fDQuPRiWj8lck5F8B/4R+Z3JECyo jDLbdYK5zRXbYvVS532EdPezkeqXrKNcn7p9UI8PBaVc6X0rIibGA8f086nv+C49MuGx 1HzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b="U6eTZV/j"; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zx2c4.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o17-20020a635d51000000b003816043f129si17095545pgm.798.2022.03.22.12.15.05; Tue, 22 Mar 2022 12:15:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-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; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b="U6eTZV/j"; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zx2c4.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240743AbiCVSio (ORCPT + 99 others); Tue, 22 Mar 2022 14:38:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240887AbiCVSiX (ORCPT ); Tue, 22 Mar 2022 14:38:23 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93D684D279; Tue, 22 Mar 2022 11:36:55 -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 2C173615FD; Tue, 22 Mar 2022 18:36:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 143F8C340F6; Tue, 22 Mar 2022 18:36:53 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="U6eTZV/j" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1647974210; 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=PFNl2hhMhFSK/CjCgits39oiGFWK73F16o9EWoPZX7Y=; b=U6eTZV/jEq7GcZ7SXAwdSpLlLP1XFmZKMdWHADW/M1rz11ul0qik8F2ClsditzoBrJMXKl 6pO+qMEQ65jzy6oOlrGqJzILBtCk8bv//uOd4pWHQphuHCWAM6yW0fDbF3LqT1UpjvMTLF akBYSubeYcp6dhVPyRY/0GD5oQQHVGk= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id e8345de8 (TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO); Tue, 22 Mar 2022 18:36:50 +0000 (UTC) Received: by mail-yb1-f175.google.com with SMTP id z8so35270844ybh.7; Tue, 22 Mar 2022 11:36:49 -0700 (PDT) X-Gm-Message-State: AOAM530rC/KDqezWoWTCmr6czTbMN7ERT25zw9UGbOifS/zjOPsxJ0h8 i+O3wwgrakrLLbcD5LiY0QReXDNjZK5ugWSS6RU= X-Received: by 2002:a25:b905:0:b0:61e:23e4:949f with SMTP id x5-20020a25b905000000b0061e23e4949fmr29614489ybj.373.1647974206146; Tue, 22 Mar 2022 11:36:46 -0700 (PDT) MIME-Version: 1.0 References: <20220217162848.303601-1-Jason@zx2c4.com> <20220322155820.GA1745955@roeck-us.net> In-Reply-To: From: "Jason A. Donenfeld" Date: Tue, 22 Mar 2022 12:36:35 -0600 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v1] random: block in /dev/urandom To: Linus Torvalds Cc: Guenter Roeck , Linux Kernel Mailing List , Linux Crypto Mailing List , linux-arch , 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 , Andy Lutomirski , Kees Cook , Lennart Poettering , Konstantin Ryabitsev , Greg Kroah-Hartman , "Theodore Ts'o" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS,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-crypto@vger.kernel.org Hi Linus, On Tue, Mar 22, 2022 at 12:29 PM Linus Torvalds wrote: > Christ, how I hate the crazy "no entropy means that we can't use it". > > It's a disease, I tell you. > > And it seems to be the direct cause of this misfeature. A disease indeed. > By all means the code can say "I can't credit this as entropy", but > the fact that it then doesn't even mix it into the fast pool is just > wrong, wrong, wrong. > > I think *that* is what we should fix. The fact is, urandom has > long-standing semantics as "don't block", and that it shouldn't care > about the (often completely insane) entropy crediting rules. > > But that "don't care about entropy rules" should then also mean "oh, > we'll mix things in even if we don't credit entropy". > > I hope that's the easy fix you are thinking about. Yes, exactly. And the patch to fix it is literally 2 lines. I'm playing with it now and I'll think about it a bit and hopefully have something for you to pull not before long. In general, your intuition is correct, I think, that the entropy crediting scheme is sort of insane and leads to problems. As I wrote in at the end, other RNG schemes like Fortuna don't really suffer from this in the same way because they're not even counting entropy. This might be something to look at seriously in the future. Jason