Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp485561imn; Tue, 26 Jul 2022 00:47:19 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uDRQB7PfQIwlnc0viuzLgNhn8qLaLaq1phtU0AmV0WmUXOIwiPyhi9xh9lWiLDaz5dMHwu X-Received: by 2002:a17:902:f708:b0:153:839f:bf2c with SMTP id h8-20020a170902f70800b00153839fbf2cmr15260687plo.113.1658821638857; Tue, 26 Jul 2022 00:47:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658821638; cv=none; d=google.com; s=arc-20160816; b=XwhGXpaSnkO4pHTjdmch2UCgKL9TS9AEbsnPC4meJITgFTQ+Hp2J/5ysNDS0UFcWv3 VDcfq2mlSdmZ7ts2CClIdh2K8HCDXI3nytlpQH+BN1a3SY3wRAh45GswZ7UYo8ydwPVg LiJRCIT+qSlUUPtjrnhojZmE2Wv62DItEYx0vNqAjaMAykCY3x7vvadV2xMQeGmX9BYy jH+52GP1hePE1AsPhJLyNum5XrbVxIlZ3gS6HoC/rM+1KOzOtOgi6q1qc6Sop24zz6b5 vukc+a+PRe6XzNXfoGujSgAmwjB+OFyTKb0W2IJIS5B/PC4pG6daqhzzUJe70xb7l+HG TJyw== 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=HAj9m2/5H1H/3YbcmACgyc+hQaUscuP7fXCe70yXCrI=; b=0Ptm8cslc3a/ByLIKhaU5YDJvIpmtUfEtLbShGVjlrKoaeuo8P+hoeBQOP3i2CkdG0 9ogNoI6GFYod9CvQiNBFK1vhXKdMVbYA/FMY1Uj/Ym38z2CYzYQK2uAF6pgO8oh1/ihh lyiPRYHw1pAIu/NtvlUv5RTEkyiBdu0F8sRbKLnLdvMwTPWal97LZFJlH2TFGk7vD4DK JMby2UQkzCoHVxyNfjfGFefcRcMXVuas5uSvz8uRoXvF7Oyj+qKjb57BchzQzO8Q0rxj qP4q8tufeiItFLldWc6kUt1RZ/EyrUDQz8M9SWFbfKlR/cO+NpDrfYx3A2ukm0TPtnMo yBbA== 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 y5-20020a056a00180500b00525425ffa43si1439934pfa.304.2022.07.26.00.46.56; Tue, 26 Jul 2022 00:47:18 -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 S232008AbiGZHoJ (ORCPT + 99 others); Tue, 26 Jul 2022 03:44:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238177AbiGZHoH (ORCPT ); Tue, 26 Jul 2022 03:44:07 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4E1D100A for ; Tue, 26 Jul 2022 00:44:05 -0700 (PDT) Received: from dggpemm500024.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4LsTP26SyJzjXQ1; Tue, 26 Jul 2022 15:41:10 +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; Tue, 26 Jul 2022 15:43:31 +0800 Message-ID: <29c4a3ec-f23f-f17f-da49-7d79ad88e284@huawei.com> Date: Tue, 26 Jul 2022 15:43:31 +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: "Jason A. Donenfeld" , Eric Biggers CC: , , 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: dggems705-chm.china.huawei.com (10.3.19.182) 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 18:37, Jason A. Donenfeld wrote: > Hi Guozihua, > > On Wed, Jul 20, 2022 at 11:50:46PM -0700, Eric Biggers wrote: >> On Thu, Jul 21, 2022 at 02:44:54PM +0800, Guozihua (Scott) wrote: >>> >>> Hi Eric >>> >>> 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? >> >> That doesn't make any sense; you should just use /dev/urandom unconditionally. > > What Eric said: this flow doesn't really make sense. Why not use > /dev/urandom unconditionally or getrandom(GRND_INSECURE)? > > But also I have to wonder: you wrote '-EAGAIN' but usually userspace > checks errno==EAGAIN, a positive value. That makes me wonder whether you > wrote your email with your code is open. So I just wanted to triple > check that what you've described is actually what the code is doing, > just in case there's some ambiguity. > > I'm just trying to find out what this code is and where it is to assess > whether we change the userspace behavior again, given that this has been > sitting for several years now. > > Jason > . Hi Jason, Eric and Theodore, Thanks for all the comments on this inquiry. Does the community has any channel to publishes changes like these? And will the man pages get updated? If so, are there any time frame? -- Best GUO Zihua