Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp7546015rwi; Mon, 24 Oct 2022 16:33:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM76M2yGjRuJovzQgP1jAuUJzo95HNq2O7oFipTRw+kI91u95buY4Ix9G4+rrdOiqHSwAuay X-Received: by 2002:a17:907:7ea6:b0:791:81f4:b0e3 with SMTP id qb38-20020a1709077ea600b0079181f4b0e3mr30269666ejc.164.1666654384849; Mon, 24 Oct 2022 16:33:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666654384; cv=none; d=google.com; s=arc-20160816; b=P3RnWFw3ul/4vy+xcuJMyWMFe5+uEY3lA1LYYHrV5gPnm7DPQXDyycqohTV4OEbyXP jdn6aBFWtWrKOMwpbBfbBDOC/Gj6kfZm/gvKLxCZmTQ0pubC7PAfLJl+AH1v78bhzPy0 v1+MYHTi0KPZlR33BB27eREAJUU0ROvQ1OM8rbJSQAr6fgp15N0yWaAB6eUmIhZR+edU Ik9IjHICXo53u/S9GrXZ/8fkF9aBVLgCKyCbBrRNCU7PYaUiTe8FN4r65q6XAtEcdhZ2 T7j/XtdCgaCCbhemp1VdCOhJ8r4YcCjVIlSAk8uG23YMeLwekr5dBxYhPMyhlHxW0E9H aQTw== 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=Lit0bBARiwIiPQHbUTyfFIvvPOW7Ifm0gLpqWiJWctM=; b=mMsTjlkEehC0zJnBo4PG/IcVnM2CNsOBu94KZO1SMkOwih/SnCKok7pE/n2FxNSesM lBMl8LmZ6houeR2p8bi/d1MarFCcPqTD4EHoxPx6wzQcz5YS79KVrVk6AEiou/3HZ9pL j7nS6IBXTtlJ1ZoksbuPPVSHcsgRUTfxsdHgVwrHDFu3+Ap+qUd5h0lO3Bn7HjLcCnq7 lUjZw0wGOTPZqoR9HgRDz72hGOQ7FSGb8hdMclbAQRVXlNUfp3ko6IaIBwQqt7aGyR3Q 7hlY/94RaLaARZlhZ5tXrcYR0fs8BhR54OO0moYUcYmDUFb0Gqyomocm2/TEdsnpAcIt 53YA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PQOl9iOX; 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 qk6-20020a1709077f8600b0078db71898f2si982520ejc.851.2022.10.24.16.32.39; Mon, 24 Oct 2022 16:33:04 -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=PQOl9iOX; 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 S230221AbiJXWt1 (ORCPT + 99 others); Mon, 24 Oct 2022 18:49:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231490AbiJXWsl (ORCPT ); Mon, 24 Oct 2022 18:48:41 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EEC52CF4A7; Mon, 24 Oct 2022 14:10:51 -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 sin.source.kernel.org (Postfix) with ESMTPS id 61AD7CE1318; Mon, 24 Oct 2022 11:39:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 54791C433C1; Mon, 24 Oct 2022 11:39:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666611574; bh=7d0m2Z6BIjDkYt6daIwwF++izl41uVIUnp2ibyflk6Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PQOl9iOX1nyMMdTkqlnUOGy+zJo4rwFZrxjLlMSfp2LoYeAZ45xncW5QYJMIocoGV fuxc9X6yt0vC4cWJFirkCcwj/aLDv6/8xlck+d2zl5JxydpwRuvTf+A/cOO0vclN4s hfkyiQi9DLFe2/SwEufbbfoCBE0AraVp5skKVth8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Jason A. Donenfeld" Subject: [PATCH 4.9 031/159] random: clamp credited irq bits to maximum mixed Date: Mon, 24 Oct 2022 13:29:45 +0200 Message-Id: <20221024112950.545644221@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112949.358278806@linuxfoundation.org> References: <20221024112949.358278806@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 @@ -977,7 +977,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)); }