Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp456348imi; Thu, 21 Jul 2022 04:40:23 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u7VwL/DAczg3Hnx95mVk1RIW5O0SguU9itfOzFjxS/SGpQhGorznvMo5PdE+bHbnrw/MAC X-Received: by 2002:a17:902:cecd:b0:16c:3ecc:eb58 with SMTP id d13-20020a170902cecd00b0016c3ecceb58mr44392883plg.96.1658403623634; Thu, 21 Jul 2022 04:40:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658403623; cv=none; d=google.com; s=arc-20160816; b=b6/NJw2EF9RTjp7zgBriIOUMj+oU3c1dhLYXDgwoHBF2AW+6Bko/5EXA9l805C6hpR wH8RbRNRiOSTPe8HmmB/2hBTR3oeGnUaduzmOFOn08Y0pBRSoZHClw2uxYpOD62zBaoR rOVbRrCI3g4MMepIjZ6AhSo/yCGu3Kj2MOC0J0olggSaIYupxZ2BCOFuR5Lypda0sYFs c/wjtaCy4qP9alGGJGwOztBXgHqqv2/EuIKJKFXMouJPvAZndzFYp4iSf/wNGMf2E7YQ aP8DVZuPxTIPB0l+29IE7YHAeQ9119JdxgorBkmWOIpSizdUn0jaX0GyXLPFPM0jL4VW Fn3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=OkGHTcbHtZZZBd+1nMQuHxfNterGLPwuHfXm3Qer1LI=; b=JYp/AOVkGq61HZC9E4b3KZ2vy2HblXwc8XUxMlMFVkqOx7/ge5ANQmV2d4t0hk/FBZ XDPbgmpBW/jKX6ltYD6UAoEPnh9R/d8768IlPtLFQJX3Qn6G88tjGwCIA9yrMjmLxZno P9GUzTZQO3ToUPnSd1jBFPG1eYx7KmBbh8qgEGs28vXb77fkpqmmoEoHKeVKWjf+JUcq r0OyCqNQjUwtADpTY60YbK1thy2mRq4hMOfLFbdS84iuRX8WDTlP/FS9m54h4I4HGC7F pWFrB3mEe93ZTtPX0NYGW8heMeOY33aHwu3p/z9unN7kUmg3JF80SA+uNnf+FRQK+Tf7 oIsg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 14-20020a63134e000000b00415abc3c2c6si1916393pgt.521.2022.07.21.04.40.05; Thu, 21 Jul 2022 04:40:23 -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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232745AbiGULaW (ORCPT + 99 others); Thu, 21 Jul 2022 07:30:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229866AbiGULaR (ORCPT ); Thu, 21 Jul 2022 07:30:17 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64EE7FD36 for ; Thu, 21 Jul 2022 04:30:15 -0700 (PDT) Received: from dggpemm500024.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4LpVgf2q4XzmV8F; Thu, 21 Jul 2022 19:28:30 +0800 (CST) Received: from [10.67.110.173] (10.67.110.173) by dggpemm500024.china.huawei.com (7.185.36.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 21 Jul 2022 19:30:13 +0800 Message-ID: <4f21d499-9080-e911-f393-8559ab8eecc6@huawei.com> Date: Thu, 21 Jul 2022 19:30:13 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: Inquiry about the removal of flag O_NONBLOCK on /dev/random Content-Language: en-US To: Theodore Ts'o CC: Eric Biggers , "Jason A. Donenfeld" , , References: <13e1fa9d-4df8-1a99-ca22-d9d655f2d023@huawei.com> From: "Guozihua (Scott)" In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.110.173] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm500024.china.huawei.com (7.185.36.203) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS 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 On 2022/7/21 19:09, Theodore Ts'o wrote: > On Thu, Jul 21, 2022 at 02:44:54PM +0800, Guozihua (Scott) wrote: > > >> We have a userspace program that starts pretty early in the boot process and >> it tries to fetch random bits from /dev/random with O_NONBLOCK, if that >> returns -EAGAIN, it turns to /dev/urandom. Is this a correct handling of >> -EAGAIN? Or this is not one of the intended use case of O_NONBLOCK? > > In addition to the good points which Eric and Jason have raised, the > other thing I would ask you is ***why*** is your userspace program > trying to fetch random bits early in the boot process? Is it, say, > trying to generate a cryptographic key which is security critical. If > so, then DON'T DO THAT. > > There have been plenty of really embarrassing security problems caused > by consumer grade products who generate a public/private key pair > within seconds of the customer taking the product out of the box, and > plugging it into the wall for the first time. At which point, > hilarity ensues, unless the box is life- or mission- critical, in > which case tragedy ensues.... > > Is it possible to move the userspace program so it's not being started > early in the boot process? What is it doing, and why does it need > random data in the first place? > > - Ted > . Hi Ted, Thanks for the comment. The code is not written by me, but I think you made a good point here and I'll definitely bring this up to the author. -- Best GUO Zihua