Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp3238219imj; Mon, 18 Feb 2019 23:18:22 -0800 (PST) X-Google-Smtp-Source: AHgI3IY4kH+tnpJq97pSwPbHH/QPD8dXR0MwcaqYyoYN798fLJPuhvilojbDr3lt+cwHWCj6QOpW X-Received: by 2002:aa7:8042:: with SMTP id y2mr28130077pfm.39.1550560702605; Mon, 18 Feb 2019 23:18:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550560702; cv=none; d=google.com; s=arc-20160816; b=H20p3Nthn6Bp3x0dnV7ZZ+E7UcEnA07lOmGmUMy9e74tlYMNJdakVFY8ihVWiP0WMQ DXY+K/x58yO7FpqBcoDo/OqNDYaC9r43b3RlQdFR6Q/0rEVA8h6AIBIpFNsAcC4OLTdF I0VkflLOOzZWs/IgV+SZHUoPHHeJVnvR7qZZ9NbShF7dUHO21ic9RStHnhXiFdA+mkm9 LUwFb65fwGwNEkRiegIPajazlWrmqHjqUZ+AjJqpHQbNpKXEEqmypcQPk4bI43tF5e0w k28UQSPGiova26vs31DIq+YnnGFf9qp8IvqIYR7B1QA8ZKELMnLRrnk7oDPFgqgqx3GS Pdzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:to:from; bh=uDPzT5lDAaNGGsDdEueJPtEWLwT96sUIAULhdmLOdCQ=; b=l88I8Mr/rqD+c2o0Ep0dfvQXpf63SKzUD8+2Z3jRBQ7uHuLqYrbU8Gnv3m9d7oMrH1 Mhoq+d8pmYH07yE6LGywhUidK6QpyiIbMI+7OIx2atJ+GUNDGdh26lXhXXMqiDUPE0Ip 2F0/TwesLvT/DknxLknIDXPx55WZ2bFlAOek3hyKxmF/El7yyXSK4e+gZqzpnizXRbzc pY5CvpJi3YS8fg0KYiCZezYQVWu7TY+bRHShJM7aqsc8sk1tsCpiwlOJOwY3l+nUmt8d 913EVb7J0l/5kZg8z8zVXWAq4SKJxOmIc4gtU+N+HBYn8uzO2QFlbMLGnYmtYc5HmJjF R6mA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 a8si14723826pgi.359.2019.02.18.23.18.06; Mon, 18 Feb 2019 23:18:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726330AbfBSHQc convert rfc822-to-8bit (ORCPT + 99 others); Tue, 19 Feb 2019 02:16:32 -0500 Received: from mail-oln040092069108.outbound.protection.outlook.com ([40.92.69.108]:6164 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725536AbfBSHQc (ORCPT ); Tue, 19 Feb 2019 02:16:32 -0500 Received: from AM5EUR02FT003.eop-EUR02.prod.protection.outlook.com (10.152.8.58) by AM5EUR02HT095.eop-EUR02.prod.protection.outlook.com (10.152.9.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1580.10; Tue, 19 Feb 2019 07:16:28 +0000 Received: from VI1PR0702MB3840.eurprd07.prod.outlook.com (10.152.8.56) by AM5EUR02FT003.mail.protection.outlook.com (10.152.8.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1580.10 via Frontend Transport; Tue, 19 Feb 2019 07:16:28 +0000 Received: from VI1PR0702MB3840.eurprd07.prod.outlook.com ([fe80::6139:4cf3:fb81:b105]) by VI1PR0702MB3840.eurprd07.prod.outlook.com ([fe80::6139:4cf3:fb81:b105%5]) with mapi id 15.20.1643.008; Tue, 19 Feb 2019 07:16:28 +0000 From: Bernd Edlinger To: "Theodore Y. Ts'o" , Arnd Bergmann , "Greg Kroah-Hartman" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCHv4] random: Make /dev/random wait for input_pool initialized Thread-Topic: [PATCHv4] random: Make /dev/random wait for input_pool initialized Thread-Index: AQHUxwMldu7JSGDWkkyAZcNCWFdW+6XmrAqK Date: Tue, 19 Feb 2019 07:16:28 +0000 Message-ID: References: <20190216182355.GE23000@mit.edu> , In-Reply-To: Accept-Language: en-US, en-GB, de-DE Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:0BAE49BC10391D817B65117266A4495998BF3A81972E6A3D348D562EEB9C6924;UpperCasedChecksum:12E718EDF0BD48AAD3FD33B38A79654C6ED9F605894B7FC926467AA7E1A143F1;SizeAsReceived:7473;Count:44 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [qGc7881LEF23rqR+g2ZY+TyW+p9cOAWW] x-ms-publictraffictype: Email x-incomingheadercount: 44 x-eopattributedmessage: 0 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(201702061078)(5061506573)(5061507331)(1603103135)(2017031320274)(2017031323274)(2017031324274)(2017031322404)(1601125500)(1603101475)(1701031045);SRVR:AM5EUR02HT095; x-ms-traffictypediagnostic: AM5EUR02HT095: x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(4566010)(82015058);SRVR:AM5EUR02HT095;BCL:0;PCL:0;RULEID:;SRVR:AM5EUR02HT095; x-microsoft-antispam-message-info: kFt7wxjPPwITkXaPWXHBuVS27zLUC68oISmkbK2EaZ9XE2wsG8YaLZD/ItXxY/Hs Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: d4d70346-2c10-4f39-8c00-e767963926d9 X-MS-Exchange-CrossTenant-Network-Message-Id: a63959fb-e918-425b-f402-08d6963a2a55 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: d4d70346-2c10-4f39-8c00-e767963926d9 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Feb 2019 07:16:28.0888 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5EUR02HT095 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > @@ -1826,7 +1830,9 @@ _random_read(int nonblock, char __user *buf, size_t nbytes) > > nbytes = min_t(size_t, nbytes, SEC_XFER_SIZE); > while (1) { > - n = extract_entropy_user(&blocking_pool, buf, nbytes); > + n = input_pool.initialized > + ? extract_entropy_user(&blocking_pool, buf, nbytes) Aehm, sorry, now I see this creates a race condition with this code here, since this the crng_reseed here also tries to read from the input_pool, but input_pool.initialized is already true: if (crng_init < 2 && entropy_bits >= 128) { crng_reseed(&primary_crng, r); entropy_bits = r->entropy_count >> ENTROPY_SHIFT; I was able to get a system in this behavior by running 3 instances of #include #include #include int main() { int f = open("/dev/random", O_NDELAY); if (f<0) return 1; for(;;) { unsigned char buf[16]; int x = read(f, buf, sizeof(buf)); if (x>=0) { int i; printf("read %d bytes: ", x); for (i=0; i + n = input_pool.initialized && crng_ready() > + ? extract_entropy_user(&blocking_pool, buf, nbytes) Thanks (for your patience :-) Bernd.