Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp3011561ybe; Sun, 15 Sep 2019 05:45:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqzc023nsiq/W/b1+gx9743LR6YVCRQ1Ku7d0wv5EWtUMY5AEv9DUDy+YmstAy6jhi81N0cI X-Received: by 2002:a17:906:5813:: with SMTP id m19mr26451237ejq.246.1568551523298; Sun, 15 Sep 2019 05:45:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568551523; cv=none; d=google.com; s=arc-20160816; b=ZPs7o38K8DL9tVnnsqYKC0abeOjZmtBy2H+Up9xo/1Z1sXhUOiWuAuzDbN5cF8TTbC cNXnocU80Ezngr1SgxogiLN/7EFovzI9dfPPe1qy4ZXmCDvl+zegnQaPBKQN8kCIu7nc Q9YUIXCJboVPrw47R75PGpT8s090ihz6JKMutO7WT8EPS/bDO3iWwySSscr7huP1S1my iard3lf6BWXn0SfFenWDL5JXmmNb2Rirp+b0JnlD9JhEKIrHJF0kNSwBfIOhBnr8rtB2 vUM40MT9IIJ5XDlcpkLNZ2L8o5dplHhvqId+PxQPkqIcab+qpBYeNKZ/RL0R8giew+uv J0Iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=KsRXrkfGYBioKCZkm9u5NiWNfg0oPuDIqLiDEx9+nik=; b=d9oUAFz+r0opeDc0+20Ao2lz+mJecZbJ09sCcRR0oWbQVS1TWecUKw8zAIyLSwjHNe sH7uw8PaGYfrseE81ti56wOKl9EkmvfXHwRnc71imO8hE5fdTIIPCTIoriqYE+lm8o+E aklHOoNAX3bFcGCW3bY131wEIvVV1TMEXRKsBVv9Je4XE7O4hBPLWtsDUOK+ZeXgv9zE /I2vbstia3qmOLZvNxx59PgheogM48UayssJGCTqh55U6ZTGzM4mUPPK7BOe2xfprvog ZynW7oLjbMed4y+wN0/sn+upbtaT3Rn9Xsc/1esF7Xtx0N2ThD2pleoPfkY5fvRC+UZI /Zzg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i55si22792169eda.88.2019.09.15.05.44.58; Sun, 15 Sep 2019 05:45:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729904AbfIOLRv (ORCPT + 99 others); Sun, 15 Sep 2019 07:17:51 -0400 Received: from wtarreau.pck.nerim.net ([62.212.114.60]:45215 "EHLO 1wt.eu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725997AbfIOLRv (ORCPT ); Sun, 15 Sep 2019 07:17:51 -0400 Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id x8FBHUCn022005; Sun, 15 Sep 2019 13:17:30 +0200 Date: Sun, 15 Sep 2019 13:17:30 +0200 From: Willy Tarreau To: "Ahmed S. Darwish" Cc: Lennart Poettering , "Theodore Y. Ts'o" , Linus Torvalds , "Alexander E. Patrakov" , Michael Kerrisk , Andreas Dilger , Jan Kara , Ray Strode , William Jon McCann , zhangjs , linux-ext4@vger.kernel.org, lkml Subject: Re: [PATCH RFC v3] random: getrandom(2): optionally block when CRNG is uninitialized Message-ID: <20190915111730.GA21993@1wt.eu> References: <20190914122500.GA1425@darwi-home-pc> <008f17bc-102b-e762-a17c-e2766d48f515@gmail.com> <20190915052242.GG19710@mit.edu> <20190915081747.GA1058@darwi-home-pc> <20190915085907.GC29771@gardel-login> <20190915093057.GF20811@1wt.eu> <20190915100201.GA2663@darwi-home-pc> <20190915104027.GG20811@1wt.eu> <20190915105539.GA1082@darwi-home-pc> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190915105539.GA1082@darwi-home-pc> User-Agent: Mutt/1.6.1 (2016-04-27) Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Sun, Sep 15, 2019 at 12:55:39PM +0200, Ahmed S. Darwish wrote: > On Sun, Sep 15, 2019 at 12:40:27PM +0200, Willy Tarreau wrote: > > On Sun, Sep 15, 2019 at 12:02:01PM +0200, Ahmed S. Darwish wrote: > > > On Sun, Sep 15, 2019 at 11:30:57AM +0200, Willy Tarreau wrote: > > > > On Sun, Sep 15, 2019 at 10:59:07AM +0200, Lennart Poettering wrote: > [...] > > > > > If Linux lets all that stuff run with awful entropy then > > > > > you pretend things where secure while they actually aren't. It's much > > > > > better to fail loudly in that case, I am sure. > > > > > > > > This is precisely what this change permits : fail instead of block > > > > by default, and let applications decide based on the use case. > > > > > > > > > > Unfortunately, not exactly. > > > > > > Linus didn't want getrandom to return an error code / "to fail" in > > > that case, but to silently return CRNG-uninitialized /dev/urandom > > > data, to avoid user-space even working around the error code through > > > busy-loops. > > > > But with this EINVAL you have the information that it only filled > > the buffer with whatever it could, right ? At least that was the > > last point I manage to catch in the discussion. Otherwise if it's > > totally silent, I fear that it will reintroduce the problem in a > > different form (i.e. libc will say "our randoms are not reliable > > anymore, let us work around this and produce blocking, solid randoms > > again to help all our users"). > > > > V1 of the patch I posted did indeed return -EINVAL. Linus then > suggested that this might make still some user-space act smart and > just busy-loop around that, basically blocking the boot again: > > https://lkml.kernel.org/r/CAHk-=wiB0e_uGpidYHf+dV4eeT+XmG-+rQBx=JJ110R48QFFWw@mail.gmail.com > https://lkml.kernel.org/r/CAHk-=whSbo=dBiqozLoa6TFmMgbeB8d9krXXvXBKtpRWkG0rMQ@mail.gmail.com > > So it was then requested to actually return what /dev/urandom would > return, so that user-space has no way whatsoever in knowing if > getrandom has failed. Then, it's the job of system integratos / BSP > builders to fix the inspect the big fat WARN on the kernel and fix > that. Then I was indeed a bit confused in the middle of the discussion as I didn't understand exactly this, thanks for the clarifying :-) But does it still block when called with GRND_RANDOM ? If so I guess I'm fine as it translates exactly the previous behavior of random vs urandom, and that GRND_NONBLOCK allows the application to fall back to reliable sources if needed (typically human interactions). Thanks, Willy