Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp6137600iog; Thu, 23 Jun 2022 12:07:50 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uwtUb0Wldz7F38zhA3tGGhK63WtpbwcRv8Tq6swMbFfCC0KMfDQ8Ykt0xqeIJOdaYGXd7c X-Received: by 2002:aa7:96da:0:b0:525:1752:85b with SMTP id h26-20020aa796da000000b005251752085bmr27489376pfq.63.1656011270450; Thu, 23 Jun 2022 12:07:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656011270; cv=none; d=google.com; s=arc-20160816; b=y3YPAlQTNWwh+AiC+L4PvRBXgvDiV0xYY7Svq8lQX48pLTErj9lHM/nnsnX26aY7ci 00tZ3mQ8JSVd1M0WIpi0TS4gSmzHC5ZONdauOsQoKV1BfBJxN0UWIBw8hC5HUv3vp59K Fbh5ofocIJDywlakKPnH43OWJ6clxUXI0xbdWypi0uDRRK5W2iqxMQctU+TPGogtuw7s xVexxr2/bPptzXTBEz0n2YmO8Vq4BKX9pgU2J/DvhCXJ3jH+A/VrUSO3+9H4jSr0kqff ar2n2PHRgXKhSWiOL4rdPEeLcI7ieqhfwSydhxG5Ww5M7uOL9wFOEPcpVDp+p6RqPXlj D7ZA== 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=PsoO3Vl0V602/DlNwcNz2qwjfN24Iyutc6L2XQ63w4s=; b=gcvmgYhTYAs3SO7wBtBNlchAuAXz2ji9ILwmflu/behNupFoC7HowbCQnOH8Kct0jK l96N3ue1rpS1u+4E0dZX3siIgJU3g67qGQPEbklaHr3nHoD5tPaBmGJhQ0IEOHkL9yHO OlvMJZ3dO2gXIiBAwCK1zqNWeZaRqkwmBYsjAr4nu6LIUs4jewUW7H6zHB/4r47yxZpA s1WhOzl14bWudi/bFfQfMEwPMPvb5MwWiyV1W28U6fL8xl6dZBNjcSL5dGqOekSkXWCX FNg7PXX6p6p/+vNkOtpdziTwpmfgggKtPhogia0lqR7LuVwfNnY9WyrAUIxQjlojqpq8 q2xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Js8fA8kb; 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 u9-20020a63ef09000000b00408cab62ca2si28035102pgh.152.2022.06.23.12.07.38; Thu, 23 Jun 2022 12:07:50 -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=Js8fA8kb; 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 S231249AbiFWRBX (ORCPT + 99 others); Thu, 23 Jun 2022 13:01:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232425AbiFWQ4E (ORCPT ); Thu, 23 Jun 2022 12:56:04 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDF0449B48; Thu, 23 Jun 2022 09:53:00 -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 ams.source.kernel.org (Postfix) with ESMTPS id C9CC7B8248C; Thu, 23 Jun 2022 16:52:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1CE7BC3411B; Thu, 23 Jun 2022 16:52:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656003177; bh=0EZw4lAzKGTm4VAg0yuLIJ//bKI0op+kfkcDODdZSZM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Js8fA8kbigzINi3bEv7TQWEV5Aka3OAC0psHJuZKvNuxt8+y8a4yKeOaJsUJSwrv/ Aaia3rF2c4czJzjHV7SQf0cIh8LQSI1wZpRg1LBOKhezFbSV5RpWCZKCDnSfyY2hot xtToekQqvLCCZp8px5tyKGqNZMnxUxHE7gdm++E8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Theodore Tso , Dominik Brodowski , "Jason A. Donenfeld" Subject: [PATCH 4.9 155/264] random: only wake up writers after zap if threshold was passed Date: Thu, 23 Jun 2022 18:42:28 +0200 Message-Id: <20220623164348.449470376@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: "Jason A. Donenfeld" commit a3f9e8910e1584d7725ef7d5ac870920d42d0bb4 upstream. The only time that we need to wake up /dev/random writers on RNDCLEARPOOL/RNDZAPPOOL is when we're changing from a value that is greater than or equal to POOL_MIN_BITS to zero, because if we're changing from below POOL_MIN_BITS to zero, the writers are already unblocked. Cc: Theodore Ts'o Reviewed-by: Dominik Brodowski Signed-off-by: Jason A. Donenfeld Signed-off-by: Greg Kroah-Hartman --- drivers/char/random.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -1578,7 +1578,7 @@ static long random_ioctl(struct file *f, */ if (!capable(CAP_SYS_ADMIN)) return -EPERM; - if (xchg(&input_pool.entropy_count, 0)) { + if (xchg(&input_pool.entropy_count, 0) >= POOL_MIN_BITS) { wake_up_interruptible(&random_write_wait); kill_fasync(&fasync, SIGIO, POLL_OUT); }