Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2943067iog; Mon, 20 Jun 2022 08:00:04 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uLxTnn7FoprBvIFl+oT6YNBc2FF7p4NZrI5rEeFOO5vwhedsGXidVzlUwC+YSBK/149uFt X-Received: by 2002:a17:902:b08c:b0:168:f08d:4cea with SMTP id p12-20020a170902b08c00b00168f08d4ceamr23835762plr.113.1655737203649; Mon, 20 Jun 2022 08:00:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655737203; cv=none; d=google.com; s=arc-20160816; b=wwqC4ONZ10qCXBj9m/HGrFzJAjYXenKKhe+dfNaKaxh/9w78wG7Myb70q9ageg0qGK atgoCFmknfE88lJmz6psJrBtcb00yUoqgajm0QYuKRNZLqCYFQcbkIKAPSJwJUL/HUXf jQ4zZIxXo+RvrK/j12V9SQp5uTNWlTAQp9s+o0qU5mlz50BO2fUV9xkrXyJEG/QlIwLk rJcJ/39t79LctIx++Oj4xYm3ofFDNj9LwKlXgpGzbuBG6lBCqxSEzJiK6XJtVPW+LFF7 AaEoBdaNjoSQFafU1RkLuyhqr9tU77qqHQHC+4n3mLhrqvcNAg0ixIrB3EmCawz/VY6f GOKQ== 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=HmM6CKqfVu39zElXJLaTr+c8IS/od4ARtzYuHsLg6eoyoSzK0TvcYrccdGHtb5UpIt 4YN9VwGTX+3dXBKJCMzXbCuEYcAc56rKqeD/KEm1M23eSEpS8O/NQJucJedx+u6QjOAu FINVBIHlx1CHNgoHaHqUcn3QtpqKXUqPeYLvcASwilv8xZmXRk/4ewM6cVmxu4MVuQNA NY++1gZwQb4Nj6b2ajz4tE7pALgv/JGkn9d7+3RTWawUgl2rEVqErTpMX0dByzsnXtnG /dS+WFguZyf0/a+QY8D2oSoAYakh4bFPJUd/+dBFtwPlhfvfBAmvYlcZmn5H4YJC7GB0 uLug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=X21GY6Cr; 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 t9-20020a17090aba8900b001ec2b1a6e56si8724491pjr.93.2022.06.20.07.59.51; Mon, 20 Jun 2022 08:00:03 -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=X21GY6Cr; 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 S1350636AbiFTOHT (ORCPT + 99 others); Mon, 20 Jun 2022 10:07:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349475AbiFTNwd (ORCPT ); Mon, 20 Jun 2022 09:52:33 -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 273A3D6C; Mon, 20 Jun 2022 06:19:08 -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 EEB03B811A9; Mon, 20 Jun 2022 13:18:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 40FF7C341C4; Mon, 20 Jun 2022 13:18:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655731115; bh=Fks3+OFrDCp2LBtgm5CxPt8bbalF/wsU+t94FuobBRA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X21GY6CrFKNZiSyqj7Jof9ELE5wY03Y/J7S93Le4G33TBPpX/YpTbjv0AG4u66ewH yj+HmxH4qqseaahsl83AkLY104dnVuWEHPMVicBA6m/nPaoQDRy3IMGDHAme2gf/QC VdjiivwFH6VMn69UkKmv1EeSLtIFmGJTo5/nTkLU= 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 5.4 107/240] random: only wake up writers after zap if threshold was passed Date: Mon, 20 Jun 2022 14:50:08 +0200 Message-Id: <20220620124742.116189202@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220620124737.799371052@linuxfoundation.org> References: <20220620124737.799371052@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); }