From nobody Thu Jun 25 09:38:08 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6999BC433EF for ; Tue, 22 Feb 2022 13:05:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232125AbiBVNFm (ORCPT ); Tue, 22 Feb 2022 08:05:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230250AbiBVNFi (ORCPT ); Tue, 22 Feb 2022 08:05:38 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7693212D0A4 for ; Tue, 22 Feb 2022 05:05:11 -0800 (PST) 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 162E4B81866 for ; Tue, 22 Feb 2022 13:05:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6DF47C340E8; Tue, 22 Feb 2022 13:05:08 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="E30iyLR8" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1645535106; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=4YbJtGQg0BkecnlLX0loQH7fn5kcMhVwUQrgGLGgH04=; b=E30iyLR8UNu1m5GQjQMwGeWJxJJXv3AaQ0NQwNuqs7RL5Urg6WDk24yrl0nej5Svds9opw HhU38hei82GsIXnWbRezBBNeW35ji7+JbmZ5G1GSb7MVZS4rsZpRDAYIwXn3X6Karb1SUY /k/gsEsUAbIjONv3x1BhTxL9pZO3QJw= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 3b2df2e4 (TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO); Tue, 22 Feb 2022 13:05:06 +0000 (UTC) From: "Jason A. Donenfeld" To: linux-kernel@vger.kernel.org Cc: "Jason A. Donenfeld" , Dominik Brodowski , Theodore Ts'o Subject: [PATCH] random: only wake up writers after zap if threshold was passed Date: Tue, 22 Feb 2022 14:05:03 +0100 Message-Id: <20220222130503.45043-1-Jason@zx2c4.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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: Dominik Brodowski Cc: Theodore Ts'o Signed-off-by: Jason A. Donenfeld --- drivers/char/random.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/char/random.c b/drivers/char/random.c index a4dedeea35e9..536237a0f073 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -1582,7 +1582,7 @@ static long random_ioctl(struct file *f, unsigned int= cmd, unsigned long arg) */ if (!capable(CAP_SYS_ADMIN)) return -EPERM; - if (xchg(&input_pool.entropy_count, 0)) { + if (xchg(&input_pool.entropy_count, 0) >=3D POOL_MIN_BITS) { wake_up_interruptible(&random_write_wait); kill_fasync(&fasync, SIGIO, POLL_OUT); } --=20 2.35.1