2023-07-21 12:46:13

by Stefan Wahren

[permalink] [raw]
Subject: Bug: jitter entropy health test unreliable on Rpi 4 (arm64)

Hi,

i recently tested Linux 6.5-rc2 on the Raspberry Pi 4 (arm64/defconfig)
and noticed the following message:

[ 0.136349] jitterentropy: Initialization failed with host not
compliant with requirements: 9

Since Linux 6.5-rc2 this message occurs in around about 1 of 2 cases
during boot. In Linux 6.4 this message i never saw this message.

I bisected this issue:
git bisect start
# good: [6995e2de6891c724bfeb2db33d7b87775f913ad1] Linux 6.4
git bisect good 6995e2de6891c724bfeb2db33d7b87775f913ad1
# bad: [fdf0eaf11452d72945af31804e2a1048ee1b574c] Linux 6.5-rc2
git bisect bad fdf0eaf11452d72945af31804e2a1048ee1b574c
# good: [1b722407a13b7f8658d2e26917791f32805980a2] Merge tag
'drm-next-2023-06-29' of git://anongit.freedesktop.org/drm/drm
git bisect good 1b722407a13b7f8658d2e26917791f32805980a2
# bad: [0a1c979c6b7dfe5b6c105d0f0f9f068b5eb07e25] Merge tag
'libnvdimm-for-6.5' of
git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm
git bisect bad 0a1c979c6b7dfe5b6c105d0f0f9f068b5eb07e25
# good: [0873694a339821277d9f2cae7ef981a1283b44f5] Merge tag
'soc-defconfig-6.5' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc
git bisect good 0873694a339821277d9f2cae7ef981a1283b44f5
# good: [1546cd4bfda49fd6faad47eb30f4e744e2d79a8f] Merge tag
'ata-6.5-rc1' of
git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/libata
git bisect good 1546cd4bfda49fd6faad47eb30f4e744e2d79a8f
# good: [9c3255a8f3946a4c8844f1e2e093313f3b71cb30] Merge tag
'platform-drivers-x86-v6.5-1' of
git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86
git bisect good 9c3255a8f3946a4c8844f1e2e093313f3b71cb30
# good: [9070577ae9d6065e447d422bdf85a09f89eaa9e8] Merge tag
'pci-v6.5-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/pci/pci
git bisect good 9070577ae9d6065e447d422bdf85a09f89eaa9e8
# bad: [486bfb05913ac9969a3a71a4dc48f17f31cb162d] crypto: akcipher - Do
not copy dst if it is NULL
git bisect bad 486bfb05913ac9969a3a71a4dc48f17f31cb162d
# good: [506579e88caf882b91ff2c62a203af793f468183] hwrng: cn10k - Add
extended trng register support
git bisect good 506579e88caf882b91ff2c62a203af793f468183
# bad: [2be0d806e25e7b068113187f9245575914daf0dc] crypto: caam - add a
test for the RNG
git bisect bad 2be0d806e25e7b068113187f9245575914daf0dc
# bad: [eb7713f5ca97697b92f225127440d1525119b8de] crypto: qat - unmap
buffer before free for DH
git bisect bad eb7713f5ca97697b92f225127440d1525119b8de
# bad: [1d217fa26680b074dbb44f6183f971a5304eaf8b] dt-bindings: qcom-qce:
Add compatibles for SM6115 and QCM2290
git bisect bad 1d217fa26680b074dbb44f6183f971a5304eaf8b
# bad: [755b4e7f7c224e10af10edafe34577b5512f7cbb] crypto: atmel - Switch
i2c drivers back to use .probe()
git bisect bad 755b4e7f7c224e10af10edafe34577b5512f7cbb
# bad: [d23659769ad1bf2cbafaa0efcbae20ef1a74f77e] crypto: jitter -
correct health test during initialization
git bisect bad d23659769ad1bf2cbafaa0efcbae20ef1a74f77e
# first bad commit: [d23659769ad1bf2cbafaa0efcbae20ef1a74f77e] crypto:
jitter - correct health test during initialization

Even if this commit only reveal this issue, it would be helpful to get
some guidance here. My expectation would be that a health check works
reliable.

Thanks


2023-07-25 09:27:42

by Stephan Müller

[permalink] [raw]
Subject: Re: Bug: jitter entropy health test unreliable on Rpi 4 (arm64)

Am Freitag, 21. Juli 2023, 14:28:29 CEST schrieb Stefan Wahren:

Hi Stefan,

sorry for the delay.

> Hi,
>
> i recently tested Linux 6.5-rc2 on the Raspberry Pi 4 (arm64/defconfig)
> and noticed the following message:
>
> [ 0.136349] jitterentropy: Initialization failed with host not
> compliant with requirements: 9
>
> Since Linux 6.5-rc2 this message occurs in around about 1 of 2 cases
> during boot. In Linux 6.4 this message i never saw this message.

This system has not that much entropy. A short-term fix would be to set the
oversampling rate to a higher value than 1, the current value.

See jent_entropy_collector_alloc:

/* verify and set the oversampling rate */
if (osr == 0)
osr = 1; /* minimum sampling rate is 1 */

The osr could be set to 3, for example. This makes the Jitter RNG slower, but
it can now handle lower-entropy environments.

Let me see how this can be fixed.

Thanks for the report.

Ciao
Stephan