Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1304233rwi; Thu, 13 Oct 2022 11:45:25 -0700 (PDT) X-Google-Smtp-Source: AMsMyM40E5r2tyFhB+08c9fvg2Ov2hMAI990K/7oSo39UNzDs4IqiprN9D2zIyt/gA694KumqQny X-Received: by 2002:a17:902:dac4:b0:178:42d4:dcc9 with SMTP id q4-20020a170902dac400b0017842d4dcc9mr1287027plx.167.1665686724958; Thu, 13 Oct 2022 11:45:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665686724; cv=none; d=google.com; s=arc-20160816; b=JaqmCXpT6EN6YoxC7nXPeSqvkbvRrBKvgDkD4gQ7+l2H37C1t339bMkJPAxGoBPMVd OxGyhtqqZ5yjs8yUDQHEVbvFaGl4A9EGHGPgMKTFLdQy8CX1isSg32U12xTM11JXwbov 8vVOuVZRCgPA/HDBvggFDzM3hwcYPt9c9t7yQQN0DYvmWHTgOk7/VD2BwPHUZBIIXBv8 yaJVOqoiuCAu4p8SiG6wHPAHWreVZRDSSFU22TAVtH2W5mL5jeII6QNlBi3ESbruz8v5 YZQJenqiuV28PigXJmNY6tSfc+iQ9EA2M7UDlPhJh+Lo5prg9Ubt0jAKA4q9fmUKvnlC kefQ== 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=aRdm5lrx2cPZwmBFDsXqsMOlmsY/kjFELh6ty8wttFc=; b=DzS/3VdOOjSR/Y4+/oOUZF0EakcJdvCIIahgHIRPTtQcZJzvGREkq1cGxV4R2z1xA5 Z32ChF4IO0WTrHZyUvFGTKfedKXm1Qyl546YmPJpMB3Hx3Y47Br+p8K0F3QaD7OWiguv 1GN8e+00yB5xOJqpQ3am6cSOZ8W6EqRf2QMhupLJrybZsT8+QnDV52ciBt3G6KbLa9+J 4sBaKkj8V3+O+/eAmXuYtF+/oyN2GWFVqTIsqv9+HVA5fb7FXg43zpMzHV64MHnGrK6O uacc8GxvUo1zil3w1qKn3KtSm4SXcL7MU018oeXTDv9oiFzWOwUb0/bLbOAK5edljSO2 sf3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=SE0BHqNM; 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 k9-20020a170902c40900b0017d2311af5dsi627454plk.69.2022.10.13.11.45.12; Thu, 13 Oct 2022 11:45:24 -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=SE0BHqNM; 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 S231932AbiJMSNs (ORCPT + 99 others); Thu, 13 Oct 2022 14:13:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231314AbiJMSMe (ORCPT ); Thu, 13 Oct 2022 14:12:34 -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 A1BF617C577; Thu, 13 Oct 2022 11:09: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 4315BB820C5; Thu, 13 Oct 2022 18:02:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9A6ACC433C1; Thu, 13 Oct 2022 18:02:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665684128; bh=251S8n2kh1CgLL9KLnRdiuwkTapMfX2u91F2Tly2WEY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SE0BHqNMaWNFoloIfuu6AmPQGaX23dSCOUkXs6fgqVPMx9Kd0hrwzCmZssnZ6HimI advVzyO1awBzzUXGTMdaKaPAY/fK+8TfOJHGRJvuZsIlwP06vSCXYpnRTKdLgHDI+E rd04AU/3RktzGRq/xptRfuzejWnCCr7wLO0x8HFM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Jason A. Donenfeld" Subject: [PATCH 6.0 07/34] random: clamp credited irq bits to maximum mixed Date: Thu, 13 Oct 2022 19:52:45 +0200 Message-Id: <20221013175146.713159261@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175146.507746257@linuxfoundation.org> References: <20221013175146.507746257@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 @@ -1006,7 +1006,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)); }