Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp26663ybp; Thu, 3 Oct 2019 09:41:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqyXAmm6JBHFcx7+DIlUIbSxKnQwNIhdeTgg1TQFDErslPtwClLXWIFWH3FmsnIcr7Ce2Tet X-Received: by 2002:a50:9f42:: with SMTP id b60mr10758027edf.192.1570120907008; Thu, 03 Oct 2019 09:41:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570120907; cv=none; d=google.com; s=arc-20160816; b=Hx1SppidEdC/5EiAkEFw8l+i9yiiGU2xZuPVMVh/cmGdf3Yv3NCYMGweBAPOb5VaS3 82W/deGwjeXiWOK6vc2b4xZnOYoRBwCNhYm1EqehXQN5HH7aTTxKpvjoa5sAkhAqSi4X HfqJiouwZb6r9Qr5cdl1TrBhQ4zU/GsPmwYZJdfXyFiNVfMb5Z56VWDGawU2AKFYqLPo J8+6z6v9VSv/ANJ8c/+2qh8/4ktJ1OihEGSJ/LyD4GMpGoEKFVJ2+DXFQ3u6lgBxVBCA aS++iMtlDepcgeuI8EhtNH99FVAfbwRZ7sHKTQm4suniTdJfET9Xd3605kXy1bzOblZS VPLw== 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=KrTDOwPElTlyllOfjxELCAdC8uhERP2kT/ZlS48Ak/U=; b=pYBMBEFCfx5ilZqjZfhqtoljKb/pkLKTo30rjH/GY6H44iJiuivm5vTOHg7fvdBVvJ J3zb8TSGu8hnvHm8zhbSclzhQa6vrPMDL6g4smnxmtl6Rze1tieZBhNAvLLC3ReAdlbw jOEJYDbc0ktmff/0VNXSiZzMor8Km+dqVjiN0UlENnFyYB2GnzJqSRxyXi8FHt0t0Eih TIwVEXOWHzpZRN9v4iE0NOdUN+7lIq0TMEYmKz2NH25WTZ8Oc95rgeiA0gw5bGSbFsQX qXMlA92XH6B2M4UQezGE25A2PiDzYM7bhtw8JufQ4qJusHU5onyBKniocyC50mieP0r6 ZDfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wNnKXvnP; 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 dt14si1542427ejb.168.2019.10.03.09.41.22; Thu, 03 Oct 2019 09:41:46 -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=wNnKXvnP; 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 S2404638AbfJCQho (ORCPT + 99 others); Thu, 3 Oct 2019 12:37:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:47102 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404627AbfJCQhm (ORCPT ); Thu, 3 Oct 2019 12:37:42 -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 6D45C2086A; Thu, 3 Oct 2019 16:37:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570120661; bh=UGqMufujAPeYf8XfJuRbDlboz+r/vDuLTwr5F1tDuSA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wNnKXvnPwVr8S9KJAkA6DRR8y2OA/ay/ocVRXhtLRhYb8KD4HlXcd/G64Nqqxmdce HXqqsjHe2mK4I056am/fL/8YDZhd+I06faD2ErSNJIpqdMql8z/63TgISgUn7wqEFD xoAsOlcgY+F/6RgJStLBI4V5VFlLFFZMzyZMvXNo= 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 5.2 305/313] hwrng: core - dont wait on add_early_randomness() Date: Thu, 3 Oct 2019 17:54:43 +0200 Message-Id: <20191003154603.241542353@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191003154533.590915454@linuxfoundation.org> References: <20191003154533.590915454@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 @@ -67,7 +67,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);