Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp6744203rwi; Mon, 24 Oct 2022 05:41:17 -0700 (PDT) X-Google-Smtp-Source: AMsMyM73CaDuoHIx0j06XcxGQQCwh4FtyLkVEGhiOi0AoXFTYCghRVn11L8jpmZ5yWVBxt3xqrol X-Received: by 2002:a65:6e8c:0:b0:435:144e:445e with SMTP id bm12-20020a656e8c000000b00435144e445emr29129377pgb.96.1666615277686; Mon, 24 Oct 2022 05:41:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666615277; cv=none; d=google.com; s=arc-20160816; b=IB2lNMrCw7HZUahX8AIYko8THJyTqiAL2kpZMlcUmZ3nyPs3wXgr7MJBo9OT9gZmIh 8XoeqMLmxK6gLOPrp/toPLSZVKI3SzIBB5T4YuuCJ6wWXITJY5AhJe1W2wWPNkotcE6r 64sLAtru+gTEqvLQnR1l2ANahgRhXLK+0nSm6iXS5ZxrQokhX9bBrAcRUKXh4uJbUItV G9y/OUYq8/mFH2ev3ebgp5XyQvO1yP29L3RknU64H8UdYaSjzqQCcvHu1aW1v6RVei7t QcjD/q0oHfs6qZPfPmClX44roSQ9gkPneD3mG0DTsS6Kl8+RE+I6Bgqn8TNl2oY+gTqA SB1g== 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=pmf6mzXEJEilQdJUZRxaNdE4ILcO7NZa149O8jke8BI=; b=U2xQXoPt+FX2SBD4bYKwM4aDsYYo64oanVm+mOHTsnf6Uvj/6sUMh81I5or/ww8gVX RpkGKfDAIaGbWYxi03/VyUEw9kBdBtbrTgtr819agc2MPwEQ0Q6CID3rT/Z2GkjVXfcz ucJcWVjIiTRWzd5ZlSlc7VQb29DJeOiddSE5Nujoht6EY34dmJw8X+SK0Mv3CuyD65/u 5h2/3EHGgOS0pLKbAZ1ffyI+xhutIR7X2xtgVLXTh3uNvC9Xs8w/8+KnkCG/CsOYe+IQ u4y642oshO97yobBnJJL05Nsg2lN897444V4hIg9hWtal4k7OEmquWFJW8TEyo4qwbFT Dx2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vi1rAUrh; 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 u12-20020a17090341cc00b0017486813f81si590676ple.528.2022.10.24.05.41.06; Mon, 24 Oct 2022 05:41:17 -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=vi1rAUrh; 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 S233639AbiJXM0r (ORCPT + 99 others); Mon, 24 Oct 2022 08:26:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230472AbiJXMZb (ORCPT ); Mon, 24 Oct 2022 08:25:31 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFB5258140; Mon, 24 Oct 2022 05:00:41 -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 B6FA6B8118A; Mon, 24 Oct 2022 11:48:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 111AFC433D6; Mon, 24 Oct 2022 11:48:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666612104; bh=Sf4p/I5+I0rasfxMUpNRv3gda7JlSUROFiBRNveWqCk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vi1rAUrhZfxizR3g36tsgkkye98QnJztEKh1rqMN81XdOfKOk9r9du9NSTnyVJIyw k4Wwnaio3ARfTwy23AMkyj1Lvk1UREycdQJsoeTfESCLBqQfztDjfDHR1DFbZyFkCM uvTJgEoW0ZGeffb//xIQ2MXUkU8Ma6+zJ3dV+t1I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Jason A. Donenfeld" Subject: [PATCH 4.14 040/210] random: clamp credited irq bits to maximum mixed Date: Mon, 24 Oct 2022 13:29:17 +0200 Message-Id: <20221024112958.289237020@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112956.797777597@linuxfoundation.org> References: <20221024112956.797777597@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.6 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 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 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 @@ -976,7 +976,7 @@ static void mix_interrupt_randomness(str local_irq_enable(); 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)); memzero_explicit(pool, sizeof(pool)); }