Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1303804rwi; Thu, 13 Oct 2022 11:44:58 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4FleqaxI6TSaWiFhvct/5OnSOZuXswVZatsj5+M3sZhWTO9ogjsFiueViRbbJJr7DAC9kZ X-Received: by 2002:a17:902:e74f:b0:178:3af4:fb13 with SMTP id p15-20020a170902e74f00b001783af4fb13mr1051768plf.19.1665686698562; Thu, 13 Oct 2022 11:44:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665686698; cv=none; d=google.com; s=arc-20160816; b=wknbnJeR5PfCrAZwjHT4GtZf4bnpf38uKRKAhvuLlVueuCGDhgbZAeTKUxhMXrRBtW Z30ecBNUXL4OfCxdTydkQWSRO0kiuZYs5tCIsMzShkcx/pmWJxJ1AYprNQE/V2Sv38kn 6yYD5dFT5jJeAKx2fuHR1PxyClc3LU9YgKWykI4VwhiXioW11+GbHFlg3sykr5KWjyUA odvgXfxL0lQOevTbg3MVQUWtm9hxbH3JoQegXS0vhyG454a9a7nVbrlot02TTG0T0669 atY4Y81P9SH8IpCvwAqlt0ArP4U0RnuYpI6lMdCx++1n2hI3t2Hn0cJLy7EhWq5XuzzI TiWQ== 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=nhPH6vFIKEP1K0GciuICNS7rUvYCqqkrOjvsWDg2bCrJoinbIfiVuZMUy8tDYoZxBI +Q68vhvq6/lkKqD7z0QPchfqyUuTrdRVAPRGg+3/Utt214lXV9IR4YqnG01vo0HFDzu3 DumWoRTIyKlQ/wjNYuiiz9v0veVvlLDqSXaZxQM1QHRb3JYrdN5bHLWHytXQenWybVT+ 0s8wZ0sevwf9BDMyYO41oJdVg++RVBUZ2kG+W8wUF5x7unGGp1UKUQ5HRUxrX7KmfYKB E6BqTwYg99/t+pb4GZy2G4D2UzMuvyWxJQxE6sJhj9aiomOfwg6a5L6YACNDM/z9IPX/ FWIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DDrYy4FR; 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 v191-20020a6389c8000000b0045b85251c12si157535pgd.260.2022.10.13.11.44.46; Thu, 13 Oct 2022 11:44:58 -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=DDrYy4FR; 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 S230148AbiJMR43 (ORCPT + 99 others); Thu, 13 Oct 2022 13:56:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230040AbiJMR4G (ORCPT ); Thu, 13 Oct 2022 13:56:06 -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 8496A15383D; Thu, 13 Oct 2022 10:54:23 -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 18253B82024; Thu, 13 Oct 2022 17:54:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5C327C433C1; Thu, 13 Oct 2022 17:54:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665683658; bh=Sf4p/I5+I0rasfxMUpNRv3gda7JlSUROFiBRNveWqCk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DDrYy4FRIRqSLvsPyDbO2nH1ip4qdmr6ON4PUWD8/TG6O6X3FRj0+BFpBs7ZNyfXQ AS95eH7kUtTiFM56E34BmanF9224KN/5DbTlLgQ1nuKyM4LYk6kMoyeqj2njrY50OA hHSQdCe6GZy/Cak1Dpffnb/eVnqrOeXKxEpNSn0Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Jason A. Donenfeld" Subject: [PATCH 5.4 22/38] random: clamp credited irq bits to maximum mixed Date: Thu, 13 Oct 2022 19:52:23 +0200 Message-Id: <20221013175145.009920659@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175144.245431424@linuxfoundation.org> References: <20221013175144.245431424@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 @@ -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)); }