Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp573751ybn; Thu, 3 Oct 2019 09:03:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqxaoaDkegiaQMr/782kukGcjhc8hSM3Jz8rjPfjRWMqBMJib57THIYUJPy9O16jBLNDW1pf X-Received: by 2002:a17:906:944b:: with SMTP id z11mr8143779ejx.46.1570118624065; Thu, 03 Oct 2019 09:03:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570118624; cv=none; d=google.com; s=arc-20160816; b=gryvRusQ0nk5ZrLoiLN5h8TI4RMwFiB5ApwbQevX7qI28xWfS0VfIIluujLA+wXdiO XwO6tLd+L/1PQCz9v1MvyPbGnYmgpsCc/E0eLGlWyMUiTog6gG5a1o4QYaNd4VqrcQDO NfdDp2O/KMs1kD8ZgbWY35+ASk2l2urBi5PdN81T9jzCnrDmxExy8MBfu1s5xb11l+uY Kf4vDs5Maqex7MPNxsJo4sJRF1pQnvTe+DLL+AK0V2l7PUeXSGfJGu9bidM3kZl7g+NT +YVwo0DmXuGAn93gcDeZL9usKzEW57bR7W1LR8aOK/hxK/1ciZ6vpL9Xiow9/ztuRVCr MubA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=yl0jLp78u+nZmRWm7NXtHjBGf6yBllK9p4yGpiyun2A=; b=cKDiYSg40vVVDQWa0Bj1tWAMSN2u5tNYDT5pYPeKIML05Jm82Z4LoYPDQ700Edd7QI h05DnQdjewJW96KpraTMTiVEOCbfI3fltkyzPayLEr/ykSlYMuzA7lnv4zYMNtutwloy ZMTah8mlifaN4zr6hVgP2rCIoBQ223Vfrk3V9eTARCGxhGjsB/yBlVW7khcICe7aNRNV 2adSdnR3ocN1/bQxT9iBvIr5f/4Ogxu5tHp4EDHQS8j1Fxa8L88LnUapgZAWAJjPL3kH /kfi39hqwquvMblHJ4z/wvvhTZ2CHINesk5e4ClVh2GSkbcYNmBRph70435X4fsMlpz4 1LlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kWjP7Bzd; 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 n2si1818871edq.264.2019.10.03.09.03.18; Thu, 03 Oct 2019 09:03:44 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=kWjP7Bzd; 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 S1731433AbfJCP7v (ORCPT + 99 others); Thu, 3 Oct 2019 11:59:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:43154 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731411AbfJCP7r (ORCPT ); Thu, 3 Oct 2019 11:59:47 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EB317222BE; Thu, 3 Oct 2019 15:59:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570118386; bh=y443mZgJMPW97Mpfp8ZziGu2lKXh9L7Mmoa5z5wOjxM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kWjP7BzdHfXflPCBrpeX2XpXU2MFixCfhhvMiajGcUJ7Q4ozC8+eZvirqnylnByWo wm6yL/F05QALGvGzmPDibzO5Rm8sZ7NXT/s/P5q8fFWtwZrJ8uQbH8kHQM5+JvHKyU INfknfYDE/d3eogiC4H/YZP+QvmAIzxa+ncXSd+w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Laurent Vivier , Theodore Tso , Herbert Xu Subject: [PATCH 4.4 93/99] hwrng: core - dont wait on add_early_randomness() Date: Thu, 3 Oct 2019 17:53:56 +0200 Message-Id: <20191003154340.534059398@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191003154252.297991283@linuxfoundation.org> References: <20191003154252.297991283@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Laurent Vivier commit 78887832e76541f77169a24ac238fccb51059b63 upstream. add_early_randomness() is called by hwrng_register() when the hardware is added. If this hardware and its module are present at boot, and if there is no data available the boot hangs until data are available and can't be interrupted. For instance, in the case of virtio-rng, in some cases the host can be not able to provide enough entropy for all the guests. We can have two easy ways to reproduce the problem but they rely on misconfiguration of the hypervisor or the egd daemon: - if virtio-rng device is configured to connect to the egd daemon of the host but when the virtio-rng driver asks for data the daemon is not connected, - if virtio-rng device is configured to connect to the egd daemon of the host but the egd daemon doesn't provide data. The guest kernel will hang at boot until the virtio-rng driver provides enough data. To avoid that, call rng_get_data() in non-blocking mode (wait=0) from add_early_randomness(). Signed-off-by: Laurent Vivier Fixes: d9e797261933 ("hwrng: add randomness to system from rng...") Cc: Reviewed-by: Theodore Ts'o Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- drivers/char/hw_random/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/char/hw_random/core.c +++ b/drivers/char/hw_random/core.c @@ -88,7 +88,7 @@ static void add_early_randomness(struct size_t size = min_t(size_t, 16, rng_buffer_size()); mutex_lock(&reading_mutex); - bytes_read = rng_get_data(rng, rng_buffer, size, 1); + bytes_read = rng_get_data(rng, rng_buffer, size, 0); mutex_unlock(&reading_mutex); if (bytes_read > 0) add_device_randomness(rng_buffer, bytes_read);