From nobody Fri Dec 19 19:23:29 2025 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 166F5C4332F for ; Thu, 13 Oct 2022 18:06:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231463AbiJMSGS (ORCPT ); Thu, 13 Oct 2022 14:06:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231281AbiJMSD7 (ORCPT ); Thu, 13 Oct 2022 14:03:59 -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 8EB71157F68; Thu, 13 Oct 2022 11:03:44 -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 07413B8204A; Thu, 13 Oct 2022 17:59:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8EE40C433C1; Thu, 13 Oct 2022 17:59:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665683981; bh=AHNUl8UA0Xu7B/6vMkbigBdeVNdDURdugPOvYBgn3Dw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ysZU41TOVqXAAC+vIeYahfOuaDlW9uBZt6IPDSAOz0JECZTNo8xr5GnbihNz+YQhM jEf2HgjPK0JY5iqf3REVF/L9Myc5fzkbp5kg62H4Z/n9nk3FEiDDSiMmOZ3bimxsEU DZu+WtbIuLZrMlY1FICMozUpUTO1m+36DF//15cg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Jason A. Donenfeld" Subject: [PATCH 5.19 08/33] random: clamp credited irq bits to maximum mixed Date: Thu, 13 Oct 2022 19:52:40 +0200 Message-Id: <20221013175145.515746744@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175145.236739253@linuxfoundation.org> References: <20221013175145.236739253@linuxfoundation.org> User-Agent: quilt/0.67 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" From: Jason A. Donenfeld commit e78a802a7b4febf53f2a92842f494b01062d85a8 upstream. 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") Cc: stable@vger.kernel.org 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 @@ -989,7 +989,7 @@ static void mix_interrupt_randomness(str 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, (count & U16_MAX) / 64, 1, sizeof(= pool) * 8)); =20 memzero_explicit(pool, sizeof(pool)); }