From patchwork Mon Oct 24 11:29:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8751 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp430099wru; Mon, 24 Oct 2022 05:40:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM76p5nelDPyoJlAfQa7lS39fq0Fo9oi82JvI0XjJtAGLrmdRSt8BXe/Q+sbihskbU8xW1xW X-Received: by 2002:a62:1e83:0:b0:545:6896:188 with SMTP id e125-20020a621e83000000b0054568960188mr33172102pfe.51.1666615243710; Mon, 24 Oct 2022 05:40:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666615243; cv=none; d=google.com; s=arc-20160816; b=SRQFk1djjA+op61Yl4g+WHH2Ruq7J4wnytEbxTrPOEeiHNdLfh6BR6wmGMlkU1KeNC bGbfghkvmkplXMRSeG+lVG832kqkBP1o7WAP/7TKjCDwExDHOCgz7ZhkPPBouv+Zlffh HZss22Lkd0nt3mjNAeV+ZriPhODYbPk4qicicj5RPdPYSIP5mJCl2rN58ZzoffW2hXij 7b3FkI8dYYCUrDsR9mPbN44RvpXF2IUi3mIQ0iNWh7Kao/Wvm21PEtzwJYFozhxPjlsN j+588jzTcEcr/rJwXrmYcDkdPsFCRSDJ7kgQjGh+F1ksDQ+YTa5eBXGF6dDzhz516vi5 5b5w== 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=U2xQXoPt+FX2SBD4bYKwM4aDsYYo64oanVm+mOHTsnf6Uvj/6sUMh81I5or/ww8gVX RpkGKfDAIaGbWYxi03/VyUEw9kBdBtbrTgtr819agc2MPwEQ0Q6CID3rT/Z2GkjVXfcz ucJcWVjIiTRWzd5ZlSlc7VQb29DJeOiddSE5Nujoht6EY34dmJw8X+SK0Mv3CuyD65/u 5h2/3EHGgOS0pLKbAZ1ffyI+xhutIR7X2xtgVLXTh3uNvC9Xs8w/8+KnkCG/CsOYe+IQ u4y642oshO97yobBnJJL05Nsg2lN897444V4hIg9hWtal4k7OEmquWFJW8TEyo4qwbFT Dx2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vi1rAUrh; 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 u12-20020a17090341cc00b0017486813f81si590676ple.528.2022.10.24.05.40.29; Mon, 24 Oct 2022 05:40:43 -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=vi1rAUrh; 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 S233639AbiJXM0r (ORCPT + 99 others); Mon, 24 Oct 2022 08:26:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230472AbiJXMZb (ORCPT ); Mon, 24 Oct 2022 08:25:31 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFB5258140; Mon, 24 Oct 2022 05:00:41 -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 B6FA6B8118A; Mon, 24 Oct 2022 11:48:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 111AFC433D6; Mon, 24 Oct 2022 11:48:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666612104; bh=Sf4p/I5+I0rasfxMUpNRv3gda7JlSUROFiBRNveWqCk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vi1rAUrhZfxizR3g36tsgkkye98QnJztEKh1rqMN81XdOfKOk9r9du9NSTnyVJIyw k4Wwnaio3ARfTwy23AMkyj1Lvk1UREycdQJsoeTfESCLBqQfztDjfDHR1DFbZyFkCM uvTJgEoW0ZGeffb//xIQ2MXUkU8Ma6+zJ3dV+t1I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Jason A. Donenfeld" Subject: [PATCH 4.14 040/210] random: clamp credited irq bits to maximum mixed Date: Mon, 24 Oct 2022 13:29:17 +0200 Message-Id: <20221024112958.289237020@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112956.797777597@linuxfoundation.org> References: <20221024112956.797777597@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?1747572745486144461?= X-GMAIL-MSGID: =?utf-8?q?1747572745486144461?= 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)); }