Received: by 2002:a05:622a:251a:b0:39a:b4a2:e86 with SMTP id cm26csp314213qtb; Wed, 19 Oct 2022 02:38:42 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7zXgAGv2xuhG1TDfREG+6ZrSYjpvuVext7OVqeQEgqjwQGiIlz215eNmTqCfxool0zcctQ X-Received: by 2002:a17:902:b210:b0:17d:c3ca:4a4f with SMTP id t16-20020a170902b21000b0017dc3ca4a4fmr7294854plr.33.1666172322597; Wed, 19 Oct 2022 02:38:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666172322; cv=none; d=google.com; s=arc-20160816; b=x8E7ds2AUeHvKKtRkd86dowx5WVYLtPWvFYy2WrAT9BrV9nZsnMR463afaLGMV0ASi V50PjPyfJ98oZ/oWkimgJPxGapg3AipBRzNApHITFW6ji3OIe+LnGewfyunjEA+VdDyv LNHB+4BAxwe2wAobgsMxoZHqlZZiRyI725PmjjtMzMTThypu8NLZzIIn7wV4Uonz9gq9 F7lTjXmKAH8pb1grEmx/vI7ZyM6ZKGnRkoFXeaTFo3jX/jk5eCOhFrQHy3WotAzTSc8q fqMV+XGj3agIPNxbmQadBwup5ogYh9k7/DWCwMBHmqc3nUxJmhCQ5prMFblwhp/L9b8I wCaQ== 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=8RBzZXfFsXoaDF0cuHBCRrFrYa2uH463JaD/dSWbTKc=; b=AiyCr+ZzLU466kyNJMmEFEf1iLaMghfj289YnxLnJRbfh9uE5p/pF4fcXGs3kC1KxJ iTJpWLZUdpS+iDGod44sl4FKsSrByXZLPVvDRgBeFxfwpx7gpmmRxPNueh4L5zVVW5lg VI1Q3tlPGeUzZ38aT4hTRnXD1CqAU9TcobaPUi5tackkS205aH9xjV5+fXQU8OE1fHRA DN0oLYg4+dUXnPtHDVh+iUYQOAT2cyfqSNc8jStj7YGfcNypGdZdkDGqzMWzi+UQXI08 NpTsUsb289RWGCtEVnZuBa5qhPs0pQRb4YsBBG+PSwbQroata2NFbijuFkhvSrsWEBex AVrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Yk1vgJG3; 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 b5-20020a170902e94500b0017c9ffbab0fsi17004362pll.152.2022.10.19.02.38.20; Wed, 19 Oct 2022 02:38:42 -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=Yk1vgJG3; 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 S233555AbiJSJ03 (ORCPT + 99 others); Wed, 19 Oct 2022 05:26:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233791AbiJSJY6 (ORCPT ); Wed, 19 Oct 2022 05:24:58 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9925E09FA; Wed, 19 Oct 2022 02:11:18 -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 9FB216186A; Wed, 19 Oct 2022 09:07:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B708DC433D6; Wed, 19 Oct 2022 09:07:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666170428; bh=3Gfi9agU9cU+uff4O12IY+gLmC0ZvLn3iv815Gceu7s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Yk1vgJG3QqXONevtsnu0Q2QKCmVG0dHDb4rrKGcUU6wsR3/G5Rb8uw07rFODAVVuf Q6J2ISnjT4T1VSN5Qd97NJEPTNpuR5MCLeSAYISdpW+7EHJ63bHEJVJ3Sz2B3i+uHN NFp50uSFb6sY3+N/Tdgx2d58D/YO94Q1uupmSse0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dominik Brodowski , Sebastian Andrzej Siewior , Sultan Alsawaf , "Jason A. Donenfeld" , Sasha Levin Subject: [PATCH 6.0 652/862] random: schedule jitter credit for next jiffy, not in two jiffies Date: Wed, 19 Oct 2022 10:32:19 +0200 Message-Id: <20221019083318.739414078@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@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.4 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 [ Upstream commit 122733471384be8c23f019fbbd46bdf7be561dcd ] Counterintuitively, mod_timer(..., jiffies + 1) will cause the timer to fire not in the next jiffy, but in two jiffies. The way to cause the timer to fire in the next jiffy is with mod_timer(..., jiffies). Doing so then lets us bump the upper bound back up again. Fixes: 50ee7529ec45 ("random: try to actively add entropy rather than passively wait for it") Fixes: 829d680e82a9 ("random: cap jitter samples per bit to factor of HZ") Cc: Dominik Brodowski Cc: Sebastian Andrzej Siewior Cc: Sultan Alsawaf Signed-off-by: Jason A. Donenfeld Signed-off-by: Sasha Levin --- drivers/char/random.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/char/random.c b/drivers/char/random.c index 060f999dcffb..46d6100fa3a7 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -1195,7 +1195,7 @@ static void __cold entropy_timer(struct timer_list *timer) */ static void __cold try_to_generate_entropy(void) { - enum { NUM_TRIAL_SAMPLES = 8192, MAX_SAMPLES_PER_BIT = HZ / 30 }; + enum { NUM_TRIAL_SAMPLES = 8192, MAX_SAMPLES_PER_BIT = HZ / 15 }; struct entropy_timer_state stack; unsigned int i, num_different = 0; unsigned long last = random_get_entropy(); @@ -1214,7 +1214,7 @@ static void __cold try_to_generate_entropy(void) timer_setup_on_stack(&stack.timer, entropy_timer, 0); while (!crng_ready() && !signal_pending(current)) { if (!timer_pending(&stack.timer)) - mod_timer(&stack.timer, jiffies + 1); + mod_timer(&stack.timer, jiffies); mix_pool_bytes(&stack.entropy, sizeof(stack.entropy)); schedule(); stack.entropy = random_get_entropy(); -- 2.35.1