From patchwork Mon Oct 24 11:29:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8710 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp423089wru; Mon, 24 Oct 2022 05:24:04 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7YJrOvJmXzWpg8egKKjV+AO9MIxRTlTjTkb1dnPldd5ij/Zs9HxWDH/Qbmf/ittaR4ofrJ X-Received: by 2002:a17:90b:1e03:b0:20d:7f0:7671 with SMTP id pg3-20020a17090b1e0300b0020d07f07671mr37404159pjb.174.1666614244460; Mon, 24 Oct 2022 05:24:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666614244; cv=none; d=google.com; s=arc-20160816; b=u7sg6yJuC5m6xkNNJUC4BJ4KDAK/xe57IU2mhjpU2BTEYz9QdeSkifijW/3rfz9OY8 nkU3KmQ4SNJCFwaxF0C4r6GyHMLdtybJTwvbEkZVA6iCHybm3IlSItovAG9d6wk0OXDs 1v5UWvDnT5L1DQIGB9oUIPyDBf7zMH6u0jXHMsLEe136MVG6G5XFM4WMTOpeKqCEB4RZ gwwkV51iOERNilOKA0lor1zaYJSdMdSTLkCM3SWO7yoLK/nDVp52oiK94FZ0j/372adi j6kygTYYmpTHh3p1Ns2ld7aUutvP22YenNC2/o+DvWENbAeXta4BGWNlJkL/zA7/FVQe wp5Q== 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=MGPfHynmn9GvaBQrYDIs/KPTU3hCVbSHVADCwRZsfM5dcO8OybIzKxSBMe6WdflY0B FJkg5bzkQruQJ2cBmYueGlyyPoQsmS84UDwvKsUZ9ybFNaa+fHrUhPzN7GR6koWcEVd1 EXqcNWgwr8NqtjcTNptEF5MbiPJ8j28CMVA4ALoygZcgYUaeVsXLApUUTJDDVAThNPhp PtY6malAsO9VDV5TBXFNjer/79LUDh/e/yqlAIYmnqykclHvPAyHRIvVziNC1HJvOrcr CsCu9OUWD8laEnO4TGaDxu6HKB/mZP1/SXwf5jgfRwyPVVQT5EQRypesOiZ0trbwPY4l hsFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lL7JG+Aa; 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 q8-20020a654948000000b0045d1aa2a589si36416855pgs.840.2022.10.24.05.23.50; Mon, 24 Oct 2022 05:24: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=lL7JG+Aa; 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 S233337AbiJXMW4 (ORCPT + 99 others); Mon, 24 Oct 2022 08:22:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233339AbiJXMUx (ORCPT ); Mon, 24 Oct 2022 08:20:53 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2250C7B5AF; Mon, 24 Oct 2022 04:59:08 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 44567612F4; Mon, 24 Oct 2022 11:56:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 57A0DC433C1; Mon, 24 Oct 2022 11:56:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666612611; bh=Sf4p/I5+I0rasfxMUpNRv3gda7JlSUROFiBRNveWqCk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lL7JG+AadCkavVvKX5AoANZP4mRPuBxUOaE/3UUoV46dwNGfVkZQeZLfgQaipgxhQ owgQPHBx5qLocySI/ug5q/nPBqhJrpg+9bhpCCPJZv6dL+P00zCvlLLBwhC3opuV1t nze3fg1tjoXm5QgwNvcjxUa4iX9IoEwf8tMeeCkI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Jason A. Donenfeld" Subject: [PATCH 4.19 022/229] random: clamp credited irq bits to maximum mixed Date: Mon, 24 Oct 2022 13:29:01 +0200 Message-Id: <20221024112959.856505864@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112959.085534368@linuxfoundation.org> References: <20221024112959.085534368@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?1747571698393172111?= X-GMAIL-MSGID: =?utf-8?q?1747571698393172111?= 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)); }