Skip to content

Commit 6e71459

Browse files
committed
crypto: jitter - consider 32 LSB for APT
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2164067 Upstream Status: merged into the linux.git commit 552d03a Author: Stephan Müller <smueller@chronox.de> Date: Sun Nov 21 15:14:20 2021 +0100 crypto: jitter - consider 32 LSB for APT 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 <smueller@chronox.de> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Vladis Dronov <vdronov@redhat.com>
1 parent 71e807d commit 6e71459

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

crypto/jitterentropy.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,6 @@ static int jent_stuck(struct rand_data *ec, __u64 current_delta)
281281
{
282282
__u64 delta2 = jent_delta(ec->last_delta, current_delta);
283283
__u64 delta3 = jent_delta(ec->last_delta2, delta2);
284-
unsigned int delta_masked = current_delta & JENT_APT_WORD_MASK;
285284

286285
ec->last_delta = current_delta;
287286
ec->last_delta2 = delta2;
@@ -290,7 +289,7 @@ static int jent_stuck(struct rand_data *ec, __u64 current_delta)
290289
* Insert the result of the comparison of two back-to-back time
291290
* deltas.
292291
*/
293-
jent_apt_insert(ec, delta_masked);
292+
jent_apt_insert(ec, current_delta);
294293

295294
if (!current_delta || !delta2 || !delta3) {
296295
/* RCT with a stuck bit */

0 commit comments

Comments
 (0)