Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1349633rwi; Thu, 13 Oct 2022 12:23:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7SLLPY1kl9moawXmjmNKlMphau3Px4WRnfrIWg59CNckohw+dYy0t7ku7Iv+Te+VWJfSJs X-Received: by 2002:a65:6bcb:0:b0:44c:3e11:a7ac with SMTP id e11-20020a656bcb000000b0044c3e11a7acmr1287347pgw.274.1665689011871; Thu, 13 Oct 2022 12:23:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665689011; cv=none; d=google.com; s=arc-20160816; b=Rf4d9X1xzpccp/sKFCaUp9JkAUTKiWX1VQ5qzt4ZbFMIgmpIW1lINSOb/oEW2YVn0A PaN+Pln2gZd1W6O1uuGdCFk5BayxOodhmdogbh+Mc9N9RDMYNAT86Yvpw+oAW5dyrf3v S2ka2Rg0l/BNYsBsTST2kh05wM3eMTLUofHWlshUulLQCBcAqzYQdBvrBK+QtsdpzTCN BIQxmkcVvxGEdvBkQVhzqNUtA+h3x22fNhYK58CiVaAs+L2THZDrJ8glQ7F7uqJcw+dI QATMLXT7MdxoN07kqw/Bec3H6M2dycgPxuheWD2ge6Q5tCqBb2YnvNHwmf0cyxZw8UDG G4rQ== 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=TEa+9wcQTN6Oqv9c5QlN+buJsl5atb3Xa06GanWXoKg=; b=bhuMcCO54INw0+xtkMmeTQVk81qbPBXLfiY7qVKNzIqqjKOTDj7ozc9GVL2U+HLfKI bq+27I6sG2SGSY5R/wU/Ioz/x+945pGA5/VUXEhc5sKrRPh4p8VNQgyPO+mA3WQQZiCY JrHGuH8w4ecNe9FQiUhjmEjlvQinToCEHr8wc8Qne31tQ+1F6WAbXqvJYBEPLKbk1CNh 5xx2PUvNj41BHZVkDXFdyTHYFDxy8vxSuYOOFnlBJPSCQcDuO5Avczyzj2mcBX+JtwH8 CxDhV6CS9e5FwRKauBm/icb0uSfe79eBkGZdQFX8WIsjAyy84b4AgI7RPpGPdlA0g6Od 7FkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="LS2mzlz/"; 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 z21-20020a17090a541500b001fe30c193c1si292259pjh.185.2022.10.13.12.23.19; Thu, 13 Oct 2022 12:23:31 -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="LS2mzlz/"; 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 S230463AbiJMSC4 (ORCPT + 99 others); Thu, 13 Oct 2022 14:02:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230453AbiJMSC3 (ORCPT ); Thu, 13 Oct 2022 14:02:29 -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 780C611465; Thu, 13 Oct 2022 11:02:26 -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 98879B82050; Thu, 13 Oct 2022 17:58:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E9A31C433D6; Thu, 13 Oct 2022 17:58:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665683919; bh=SzjUWlrxdx6dSBn+CgiQOoaJon3rIv0huAMKubMWhmc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LS2mzlz/b5Kdya9N8IqyEurfMDytA4edDfDeSbIDYL3REvu4ea7HDWrPj8vFLd6Sn TdOXRbLBTAF1LUTA/HjeeiuBSMt2+4of6iUHoPJRV6dIZVdMLa2FfYkkd7p2JzbDMS bsC1whr5v7gOQELPhVJfCWdhmlmAMs0XB2H/xyfk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Jason A. Donenfeld" Subject: [PATCH 5.15 07/27] random: clamp credited irq bits to maximum mixed Date: Thu, 13 Oct 2022 19:52:36 +0200 Message-Id: <20221013175143.791866092@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175143.518476113@linuxfoundation.org> References: <20221013175143.518476113@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.1 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 @@ -980,7 +980,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)); }