From patchwork Thu Oct 13 17:52:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2205 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp410515wrs; Thu, 13 Oct 2022 11:06:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7QzXlZ296wv/17P94g9GHTLZRIzQFwIHCOCmncHk+i+ZczH6yEK3LGplEQk0TDeRmEi0Ow X-Received: by 2002:a63:5d18:0:b0:462:f77b:cd29 with SMTP id r24-20020a635d18000000b00462f77bcd29mr970667pgb.9.1665684404308; Thu, 13 Oct 2022 11:06:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684404; cv=none; d=google.com; s=arc-20160816; b=tZ0fFZSFkFiVQARhRoE9+TuEDHJdzu3Vm9N/UgnAx4VOLwKqDszvSQ6+x94SZ3R1V3 c66Rg/C4m+ox1irfI42pAs8mS2Fn0cyMWJ4BoOuvlxPZBW0oRPbS+DAdoVi/ffcndKwh f9X4Eui9LdnHwfZDR2MJiWFJAOWqwKiZ87MZxLKsi1BN9QpF/lTefO3ezheQoLsFjqWu PZZnW5qh6YCcaJR8YL24r0xdeFhvp/CBeoDEsNzI7iVEY6EuYm/GcT4bVx/UZYwIjCNJ /7PcnA5xROt5Ohgiu/tC9UemY8UnG4Od+dmvm4EtPwkf6j42eZScdkgh6kHhUVGYhL68 ttkA== 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=NaSejAEvZrQDRsHLs46JGp6R5NtVteXjjJHju3zcavM=; b=ThJvm/fAKxGUH1SPl45HlxlmLOAK73eIpqHdxIY/gcXwp+AE4RQqNGLUlbMFrd5JlZ 5S6ZQA6aXEasDBDf/czJbf21D63FCA0xC7ZAYbMU0KZq7qCd5VMe/81oP/Q84YolKx6Y 9mfx3DgYkRHxqlEO3XQ9ekHET90AsLBgPa+GNo0gThrcs1deNUHWo3RFhj0czzIGU8J/ v/a2tR1QJt98iXjabSy0qbWGILWIVVTeWxBibZpG8sFIffWLO8jyRlOkzhMogsduifLq NF3wkgxgH2Jq849Trzn/qZP0gUZknQtMsfFEmw7ZLaOZbIw+vPP4dQ2n+IMomWnTfr3u 8vYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ysZU41TO; 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 o19-20020a17090ac09300b0020d4d8cf1a6si320058pjs.75.2022.10.13.11.06.31; Thu, 13 Oct 2022 11:06:44 -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=ysZU41TO; 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 S230466AbiJMSGR (ORCPT + 99 others); Thu, 13 Oct 2022 14:06:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231281AbiJMSD7 (ORCPT ); Thu, 13 Oct 2022 14:03:59 -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 8EB71157F68; Thu, 13 Oct 2022 11:03:44 -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 07413B8204A; Thu, 13 Oct 2022 17:59:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8EE40C433C1; Thu, 13 Oct 2022 17:59:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665683981; bh=AHNUl8UA0Xu7B/6vMkbigBdeVNdDURdugPOvYBgn3Dw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ysZU41TOVqXAAC+vIeYahfOuaDlW9uBZt6IPDSAOz0JECZTNo8xr5GnbihNz+YQhM jEf2HgjPK0JY5iqf3REVF/L9Myc5fzkbp5kg62H4Z/n9nk3FEiDDSiMmOZ3bimxsEU DZu+WtbIuLZrMlY1FICMozUpUTO1m+36DF//15cg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Jason A. Donenfeld" Subject: [PATCH 5.19 08/33] random: clamp credited irq bits to maximum mixed Date: Thu, 13 Oct 2022 19:52:40 +0200 Message-Id: <20221013175145.515746744@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175145.236739253@linuxfoundation.org> References: <20221013175145.236739253@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746596690213160246?= X-GMAIL-MSGID: =?utf-8?q?1746596690213160246?= 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 @@ -989,7 +989,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)); }