Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3677712pxb; Mon, 24 Jan 2022 15:07:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJwTi/o3ERFuUk4QFVySS6Bgx/0rudjQOa+6Itf4e0oJdaEOTFGVc860ZM92xHmZN5hVoU6D X-Received: by 2002:a63:6a49:: with SMTP id f70mr13255942pgc.244.1643065658815; Mon, 24 Jan 2022 15:07:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643065658; cv=none; d=google.com; s=arc-20160816; b=B4jmL4mtyywgXY1Z1klnpdzJlVYJFgS+BFfXAe4GRuQxJs14Dr6jbg9KRviP0ne63t aYsqID7fYHyrZbZUh3EvqFaR0NUkVFJokjkTJunPxtzS9OEK4Ie3cZimCrvULtfiVpkk XiB+x+cwvdWR3xgh+VaH1nZDhRmN/DI609P/nxjmw4pvniWEW4TN/+EaS9ui84FeGljd u5sxGskPcnAWMd7K0HdhRDW92lt+unNYcZUd65mS73aevmHVVmrlvSNrExEQ9z9Ntbrt UwXPx5bDLhkanCgJ6AUE2FCExhJ5VRq7RYtYtVZU3WgSTbvftJCmJW8hKfU71bQGtMYb kwaQ== 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=wHjOPWvUGuL36wJ4dmFsyLuJaICgMS6VxZTbU9uc0oc=; b=fkJVvvav+2Wyill0rwt5z/Ol4Gqi0rVs71sSy/b0fCxyK0GIe91TbwNCooGp4SQDyI GQmU70z2Y+sHwYefmwmMMLKNl0SAyZxyMSz7YEmTuMS2wHn/jRwC8BOVUpep2oXXKavb 6+vahixgSeuYIiyrUtKKqoCC5KE+ZzLUWOp2HEg0tkh6+izAP3xoDmDkWgPFlMrpc9f5 Aa+AzCb0fytftcOjHT4GJrp83APc6NN6EYi7SV6kQhYKTzEjx1e+Hzg0W2eyYUJgsMDv YMTaPiEnbBnqq1yxK8itr7d4epqYvXX/3FjdIrhCTx1w6myDLNXcc37ecENgSHvElJkw pQ3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=m1qHHevW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j11si13861658plh.260.2022.01.24.15.07.26; Mon, 24 Jan 2022 15:07:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=m1qHHevW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1842657AbiAXXCV (ORCPT + 99 others); Mon, 24 Jan 2022 18:02:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1456417AbiAXVzC (ORCPT ); Mon, 24 Jan 2022 16:55:02 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45B45C07E290; Mon, 24 Jan 2022 12:35:51 -0800 (PST) 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 D618261535; Mon, 24 Jan 2022 20:35:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A3A60C340E5; Mon, 24 Jan 2022 20:35:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643056550; bh=eEaFiu9oeQzMos//9egNUUciT+D643UA7dei83tarKU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m1qHHevWd6N014UIegEekBVr+mI8gP1qbi3/TjTxKPpvjrKkrbvRIkt6xigpQan4z 4ayPNrNP9X2Mhd9nnWfDscgYmiFNOeNdXZ+rLz3bcSvD/BUwoyrrVWBe54M4UUg5dm dw7tSz3DVOUV2RQoF17sXVSm1a0hJdfM2O8IBOyg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stephan Mueller , Herbert Xu , Sasha Levin Subject: [PATCH 5.15 504/846] crypto: jitter - consider 32 LSB for APT Date: Mon, 24 Jan 2022 19:40:21 +0100 Message-Id: <20220124184118.416119024@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Stephan Müller [ Upstream commit 552d03a223eda3df84526ab2c1f4d82e15eaee7a ] The APT compares the current time stamp with a pre-set value. The current code only considered the 4 LSB only. Yet, after reviews by mathematicians of the user space Jitter RNG version >= 3.1.0, it was concluded that the APT can be calculated on the 32 LSB of the time delta. Thi change is applied to the kernel. This fixes a bug where an AMD EPYC fails this test as its RDTSC value contains zeros in the LSB. The most appropriate fix would have been to apply a GCD calculation and divide the time stamp by the GCD. Yet, this is a significant code change that will be considered for a future update. Note, tests showed that constantly the GCD always was 32 on these systems, i.e. the 5 LSB were always zero (thus failing the APT since it only considered the 4 LSB for its calculation). Signed-off-by: Stephan Mueller Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin --- crypto/jitterentropy.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crypto/jitterentropy.c b/crypto/jitterentropy.c index a11b3208760f3..f6d3a84e3c214 100644 --- a/crypto/jitterentropy.c +++ b/crypto/jitterentropy.c @@ -265,7 +265,6 @@ static int jent_stuck(struct rand_data *ec, __u64 current_delta) { __u64 delta2 = jent_delta(ec->last_delta, current_delta); __u64 delta3 = jent_delta(ec->last_delta2, delta2); - unsigned int delta_masked = current_delta & JENT_APT_WORD_MASK; ec->last_delta = current_delta; ec->last_delta2 = delta2; @@ -274,7 +273,7 @@ static int jent_stuck(struct rand_data *ec, __u64 current_delta) * Insert the result of the comparison of two back-to-back time * deltas. */ - jent_apt_insert(ec, delta_masked); + jent_apt_insert(ec, current_delta); if (!current_delta || !delta2 || !delta3) { /* RCT with a stuck bit */ -- 2.34.1