From patchwork Mon Oct 24 11:29:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 10373 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp688379wru; Mon, 24 Oct 2022 15:50:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM73UkbdS4HWOA06HChixy6vfGlRDPDSsgHjS6Vg6gXhjpPqy5b4DRhM6UiuFcXqGRsURN0s X-Received: by 2002:a17:907:1dec:b0:7aa:6262:f23f with SMTP id og44-20020a1709071dec00b007aa6262f23fmr4047934ejc.38.1666651815817; Mon, 24 Oct 2022 15:50:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666651815; cv=none; d=google.com; s=arc-20160816; b=FZs+BwTEwd2OQRK92CLuP8JX5a7R4i3aCPufzPacmHky1JzPe1zrxHTsAp66Hs6TCF O6/vmJP4Bxf2HmeyHwglZJo78hfDiGDLLiZlo+8RYHjbHINIuQ0pCxYWstS1N3uePISo cozYnayxP1BtXsP6o/qziUN6BmaMvpq9N6EGayRhjuGoaPXjP9OVElf6NOqtFm9agx1e Sxcvd4qSrvU1Pgy8pjV60u9NX22BOkJhdB3LDTtQmDZS4UHyejTajPbPmLMmOHZpI+y1 NHDeGc4/2pxVg9blhdLU5dJy46mvfkc1Wv7JAewNDa+6Datgzb8W5Rgk72cJQFF5IrQT AEhw== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y7-20020aa7d507000000b00461aa80dfa8si882684edq.429.2022.10.24.15.49.52; Mon, 24 Oct 2022 15:50:15 -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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747611094073962499?= X-GMAIL-MSGID: =?utf-8?q?1747611094073962499?= 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)); }