From nobody Sun Feb 8 03:28:36 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 217C8ECAAD8 for ; Fri, 23 Sep 2022 09:22:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231600AbiIWJWT (ORCPT ); Fri, 23 Sep 2022 05:22:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231592AbiIWJWP (ORCPT ); Fri, 23 Sep 2022 05:22:15 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7974DE1088 for ; Fri, 23 Sep 2022 02:22:13 -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 1E3E3B828E0 for ; Fri, 23 Sep 2022 09:22:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78C50C433C1 for ; Fri, 23 Sep 2022 09:22:10 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="piqziyMi" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1663924928; 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=TZxaazyLLjOQHosv4dvUaW193XKPhOnbRkX+9IL88q8=; b=piqziyMiEWGcc00ADpPKP4rTup//UWqYrWofxqlGg9hU5N4GufNl/CQqtXFwtJpjJ2alh+ TFIWxlvEaO5gF9W8vlVqajb5vUr1nB0wdLM8bJ+0htxdVqxwFcm7Ot3hpZHkJ2hpZeNHgY 5RM0X5WZ66D4VExBUAyD92Df+NN/Lhw= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 3a9b30df (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Fri, 23 Sep 2022 09:22:08 +0000 (UTC) From: "Jason A. Donenfeld" To: linux-kernel@vger.kernel.org Cc: "Jason A. Donenfeld" Subject: [PATCH] random: clamp credited irq bits to maximum mixed Date: Fri, 23 Sep 2022 11:22:04 +0200 Message-Id: <20220923092204.3818698-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" Since the most that's mixed into the pool is sizeof(long)*2, don't credit more than that many bytes of entropy. Fixes: e3e33fc2ea7f ("random: do not use input pool from hard IRQs") 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 520a385c7dab..593fb3b3cf74 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -1004,7 +1004,7 @@ static void mix_interrupt_randomness(struct work_stru= ct *work) local_irq_enable(); =20 mix_pool_bytes(pool, sizeof(pool)); - credit_init_bits(max(1u, (count & U16_MAX) / 64)); + credit_init_bits(clamp_t(unsigned int, 1, (count & U16_MAX) / 64, sizeof(= pool) * 8)); =20 memzero_explicit(pool, sizeof(pool)); } --=20 2.37.3