Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp6138555iog; Thu, 23 Jun 2022 12:09:00 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vCr8ksuVTdnV1lOz/oY1D3IU1ws+/jAE2t2Ju0eSrW+5CTwWQz7/ETxdF+HGAbetc7hqgs X-Received: by 2002:a17:90b:4d0a:b0:1e2:c0b4:8bb8 with SMTP id mw10-20020a17090b4d0a00b001e2c0b48bb8mr5452637pjb.94.1656011340300; Thu, 23 Jun 2022 12:09:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656011340; cv=none; d=google.com; s=arc-20160816; b=aGZNYRzT3UFKO0TDM+O3B9Tgdz7PITCJGz8K3v2AiNQHoRyuScvcVvUi2RRIONc6JS SGJ03DMF54LJXSIVntQd+zSqlLsW2xY1Bb3ciSooXd/q3qgRlJLzxWdIR6p8lmPmRIy9 wAsD65ieXN5Oh8OF5+TmPdqUMSvlidMJWhyKyISoCppBX3Xh4I/qprE7myflkgbclysT flzgv1fy9nXqkprhKfq+4Ve2P1F7vbiA8i6JVuCsxzPsIYeEhqEXYcrWWZhuPbYn2JNw 1zn5RgSMhlj+x977V42xj6jnvzPzATM2W3sIjZ6LT0AB3J2rLIBRnIB/fT5696dSDWMD AHUQ== 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=h9NZDBajeMUdR6jMqAyEVbxhVIbgt0bq1i8R9dW2xms=; b=xiNivBJvxOYyZU0v8/SyWGq6GzMN0vu0ukv+OtclA9BZwQi6N6XFwV6y5JawKggHZ9 NZ/+DOGuzh1vttd3wzQywb84E3EX75kBCgDIowX21KgpzrkwBhxkfQOcsS+rGBgEnSwj 1Y0Tgk918i8PDpmp5OfhRwXTOfzU5o1zyWFUREk5MNdtdJt3q2aFEPE4EvO5BW88vTXw bf5R58K70lF4sfRPTDOZNkqa0biPYUwzpGrEibZNbt9nIqernfAy6pGu7+XI5OSdSE4Y vlVd4nxSMVg7Ypmr+qX37lAZ7Q9qLO9QVkDJzWE+DO07U/hNoDy80igQS+7SbFM6iEpF UVUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HO5Gj6g4; 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 p35-20020a634f63000000b00401b6bc63c7si29159982pgl.452.2022.06.23.12.08.48; Thu, 23 Jun 2022 12:09:00 -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=HO5Gj6g4; 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 S235944AbiFWSGm (ORCPT + 99 others); Thu, 23 Jun 2022 14:06:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235931AbiFWSF4 (ORCPT ); Thu, 23 Jun 2022 14:05:56 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B41FA6159; Thu, 23 Jun 2022 10:17:55 -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 39348B824B8; Thu, 23 Jun 2022 17:17:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8D189C341C4; Thu, 23 Jun 2022 17:17:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656004672; bh=Fks3+OFrDCp2LBtgm5CxPt8bbalF/wsU+t94FuobBRA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HO5Gj6g4ImEtIPQTgvHZSZzAzQ8JYGJFMdLRFDiFSYkEQf0ZQpkUSdZ2CDbi6xIAV F4ZkpOICda9A2XsEWnyL3MJ+6W1nX5uUa2CSGmofZ9SlUuIianIO8eeYISfY/uLNmu NM/rf01peDYUGnqkagf3n6gsSn5J3zOWGKSKHSQU= 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.19 112/234] random: only wake up writers after zap if threshold was passed Date: Thu, 23 Jun 2022 18:42:59 +0200 Message-Id: <20220623164346.227877336@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623164343.042598055@linuxfoundation.org> References: <20220623164343.042598055@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 @@ -1577,7 +1577,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); }