Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp6144754iog; Thu, 23 Jun 2022 12:16:16 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tuEPJtIo5KElRal2hxL6BFoU81ank2x4p+foce6uA846T28taUQzcQl0DPaKpA6Wy5gZlE X-Received: by 2002:a17:902:7e84:b0:166:395c:4b68 with SMTP id z4-20020a1709027e8400b00166395c4b68mr40914507pla.8.1656011776331; Thu, 23 Jun 2022 12:16:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656011776; cv=none; d=google.com; s=arc-20160816; b=zEMCIpbODR2PEXQh+ICo7VWVYJE7Ydsjg6CXtgjjyH8+QoRSoJ74Jku839GnmDPzjE Ywh0+o2wqewpzHeH/Doh6nRi7l6XaQtFJLyrBmAwYXjqx2R95WOzdZ36tJbaxp425qJV V6hKvTbFsn8n6G6XnwW7hCgqkBSsEAkT9e9h9lyS3UkuKjkobcAALe5/DT0UwSAzDP55 m8RnlAwPOGEz+9TpD48YZELVYq+cDWpYc7ohlHu5Y1l3S1tRoEsR67/gT4nZMGNuCJj0 2QaLokuNbTe8g9UX/HruQUhLvLMHCiFjY7YW2f6sUtP79DeNk6QQN6eCEaCa4jsiQA9z 2XLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+HXcQUx+l1Wf/Bwul44KwKlVwi0T7iQJLzGRqH9OIhI=; b=NfD6HnJuqOI0GhUFmvMp/QUYwpJ3aI2V6tjWKrP6MCO50D5XlMr6290K2rkPadxUB1 QlRIEJU8PF30XDcLRJuHRkShfvyLGpY6tlBXb36K3YMgqRIpgOR3QHCWrJKWP7T3HIMS +yTnWIffmcqpt9bavUlA6859qbhkMYC4DnHML3Pm+qasfdJdlZG1PBeIb8U5ziqJLRfT LzrPEM5FPAw8ifDuwVRl1LIpi55sZEwfgN4rlnk8SXDODZrADTDnTNWA+ySRNbJaHGkn Eu15YX//DiyDrcp0HwWxnnCo2jmu5CHiegrH1Ao1vNwBNrHokn24WUaawJ5b01Xk5TgH dZSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2ZEK6z8m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 191-20020a6302c8000000b00401b6ab1e4dsi23497631pgc.471.2022.06.23.12.16.04; Thu, 23 Jun 2022 12:16:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2ZEK6z8m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233309AbiFWQ5n (ORCPT + 99 others); Thu, 23 Jun 2022 12:57:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233648AbiFWQvT (ORCPT ); Thu, 23 Jun 2022 12:51:19 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B93B50029; Thu, 23 Jun 2022 09:49:24 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4CF4561F99; Thu, 23 Jun 2022 16:49:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3E9B2C3411B; Thu, 23 Jun 2022 16:49:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656002963; bh=5mbXSzNjpSRj9Uu7DEFHfMoAvquSppTKosRivKzhN5g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2ZEK6z8mAoWSSIr+bLIM09xmP7bDEMBulwXLf5RIXpo+IgtkCnER5ks9BvaGqDkc+ zxJ3wFlNZGPuXFEeGVCbRZ/e3omSqfVO54c4Ry9uBfprqbFOqJl4bu1wHy2F1k1Kf0 xSXpq4t2qSVvep81PVR2QgoV2bU1+/R0vDc9Mr0Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, kernel test robot , Theodore Tso , "Jason A. Donenfeld" Subject: [PATCH 4.9 043/264] random: fix soft lockup when trying to read from an uninitialized blocking pool Date: Thu, 23 Jun 2022 18:40:36 +0200 Message-Id: <20220623164345.287939032@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623164344.053938039@linuxfoundation.org> References: <20220623164344.053938039@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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-kernel@vger.kernel.org From: Theodore Ts'o commit 58be0106c5306b939b07b4b8bf00669a20593f4b upstream. Fixes: eb9d1bf079bb: "random: only read from /dev/random after its pool has received 128 bits" Reported-by: kernel test robot Signed-off-by: Theodore Ts'o Signed-off-by: Jason A. Donenfeld Signed-off-by: Greg Kroah-Hartman --- drivers/char/random.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -774,8 +774,11 @@ retry: if (cmpxchg(&r->entropy_count, orig, entropy_count) != orig) goto retry; - if (has_initialized) + if (has_initialized) { r->initialized = 1; + wake_up_interruptible(&random_read_wait); + kill_fasync(&fasync, SIGIO, POLL_IN); + } trace_credit_entropy_bits(r->name, nbits, entropy_count >> ENTROPY_SHIFT, _RET_IP_); @@ -791,6 +794,13 @@ retry: entropy_bits = r->entropy_count >> ENTROPY_SHIFT; } + /* initialize the blocking pool if necessary */ + if (entropy_bits >= random_read_wakeup_bits && + !other->initialized) { + schedule_work(&other->push_work); + return; + } + /* should we wake readers? */ if (entropy_bits >= random_read_wakeup_bits && wq_has_sleeper(&random_read_wait)) { @@ -1992,8 +2002,8 @@ _random_read(int nonblock, char __user * return -EAGAIN; wait_event_interruptible(random_read_wait, - ENTROPY_BITS(&input_pool) >= - random_read_wakeup_bits); + blocking_pool.initialized && + (ENTROPY_BITS(&input_pool) >= random_read_wakeup_bits)); if (signal_pending(current)) return -ERESTARTSYS; }