Skip to contentSkip to conversation

package/rng-tools: make jitterentropy conditional

PATCH New Matt Weber 4 participants 10 messages Feb 5, 2020 – May 19, 2020

lore
Share & tools
lore

Matt Weber

author
#0 lore raw

PATCH 1/1 package/rng-tools: make jitterentropy conditional

The update of rng-tools from 5 to 6.7 introduced a change where the jitterentropy library was enabled by default instead of returning a special 66 return code to hangle the case of no hwrng. This patch reverts that change and allows a user to select when to enable the jitterentropy source. The bug documents an issue of when a hwrng is enabled with jitterentropy there is a longer boot time.

Fixes:
https://bugs.busybox.net/show_bug.cgi?id=12511

---
 package/rng-tools/Config.in    | 1 -
 package/rng-tools/rng-tools.mk | 9 ++++++++-
 package/rng-tools/rngd.service | 1 +
 3 files changed, 9 insertions(+), 2 deletions(-)
package/rng-tools/Config.in +0 -1
index 71514260e6..ddcc221d06 100644
@@ -4,7 +4,6 @@ config BR2_PACKAGE_RNG_TOOLS
 	# pthread_setaffinity_np
 	depends on BR2_TOOLCHAIN_HAS_THREADS_NPTL
 	select BR2_PACKAGE_ARGP_STANDALONE if BR2_TOOLCHAIN_USES_UCLIBC || BR2_TOOLCHAIN_USES_MUSL
-	select BR2_PACKAGE_JITTERENTROPY_LIBRARY
 	# For rdrand & darn ligcrypt is required and it's not obvious to users
 	select BR2_PACKAGE_LIBGCRYPT if BR2_i386 || BR2_x86_64 || BR2_powerpc64le
 	select BR2_PACKAGE_LIBSYSFS
package/rng-tools/rng-tools.mk +8 -1
index 274079044c..e458fbb8eb 100644
@@ -8,7 +8,7 @@ RNG_TOOLS_VERSION = 6.8
 RNG_TOOLS_SITE = $(call github,nhorman,$(RNG_TOOLS_NAME),v$(RNG_TOOLS_VERSION))
 RNG_TOOLS_LICENSE = GPL-2.0
 RNG_TOOLS_LICENSE_FILES = COPYING
-RNG_TOOLS_DEPENDENCIES = libsysfs jitterentropy-library host-pkgconf
+RNG_TOOLS_DEPENDENCIES = libsysfs host-pkgconf
 # From git
 RNG_TOOLS_AUTORECONF = YES
 
@@ -29,6 +29,13 @@ else
 RNG_TOOLS_CONF_OPTS += --without-libgcrypt
 endif
 
+ifeq ($(BR2_PACKAGE_JITTERENTROPY_LIBRARY),y)
+RNG_TOOLS_DEPENDENCIES += jitterentropy-library
+RNG_TOOLS_CONF_OPTS += --enable-jitterentropy
+else
+RNG_TOOLS_CONF_OPTS += --disable-jitterentropy
+endif
+
 define RNG_TOOLS_INSTALL_INIT_SYSV
 	$(INSTALL) -D -m 755 package/rng-tools/S21rngd \
 		$(TARGET_DIR)/etc/init.d/S21rngd
package/rng-tools/rngd.service +1 -0
index 11386d1e5d..c0bcffe59e 100644
@@ -3,6 +3,7 @@ Description=Hardware RNG Entropy Gatherer Daemon
 
 [Service]
 ExecStart=/usr/sbin/rngd -f $DAEMON_ARGS
+SuccessExitStatus=66
 EnvironmentFile=-/etc/default/rngd
 
 [Install]
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 package/rng-tools: make jitterentropy conditional

Quoted 7 lines · On Wed, 5 Feb 2020 12:26:08 -0600 Matt Weber…

The update of rng-tools from 5 to 6.7 introduced a change where the jitterentropy library was enabled by default instead of returning a special 66 return code to hangle the case of no hwrng. This patch reverts that change and allows a user to select when to enable the jitterentropy source. The bug documents an issue of when a hwrng is enabled with jitterentropy there is a longer boot time.

I don't understand this story of the 66 return code. Could you explain a bit more ?

package/rng-tools/rngd.service Description=Hardware RNG Entropy Gatherer Daemon · line 6

Quoted 8 lines

index 11386d1e5d..c0bcffe59e 100644

package/rng-tools/rngd.service +1 -0
@@ -3,6 +3,7 @@ Description=Hardware RNG Entropy Gatherer Daemon
 
 [Service]
 ExecStart=/usr/sbin/rngd -f $DAEMON_ARGS
+SuccessExitStatus=66

Will this work even if jitterentropy support is enabled ?

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#2 lore raw

PATCH 1/1 package/rng-tools: make jitterentropy conditional

Thomas,

Quoted 12 lines · Thomas Petazzoni
Quoted 7 lines · On Wed, 5 Feb 2020 12:26:08 -0600 Matt Weber…

The update of rng-tools from 5 to 6.7 introduced a change where the jitterentropy library was enabled by default instead of returning a special 66 return code to hangle the case of no hwrng. This patch reverts that change and allows a user to select when to enable the jitterentropy source. The bug documents an issue of when a hwrng is enabled with jitterentropy there is a longer boot time.

Quoted 2 lines

I don't understand this story of the 66 return code. Could you explain a bit more ?

In Buildroot commit 22cb51e1 the systemd support addition included the successcode change based on the Fedora bugfix for ignoring if no hwrng is present (https://bugzilla.redhat.com/show_bug.cgi?id=892178).

Quoted 11 lines

package/rng-tools/rngd.service Description=Hardware RNG Entropy Gatherer Daemon · line 6

Quoted 9 lines

index 11386d1e5d..c0bcffe59e 100644

package/rng-tools/rngd.service +1 -0
@@ -3,6 +3,7 @@ Description=Hardware RNG Entropy Gatherer Daemon
 
 [Service]
 ExecStart=/usr/sbin/rngd -f $DAEMON_ARGS
+SuccessExitStatus=66

Will this work even if jitterentropy support is enabled ?

My understanding is that you'd never hit this return case when jitterentropy support built in as it would always init the entropy pool using that library as a source. Thus the problem of the boot delay even when hwrng is present.

Matt

#3 lore raw

PATCH 1/1 package/rng-tools: make jitterentropy conditional

Thomas,

Quoted 17 lines · Matthew Weber

Thomas,

Quoted 12 lines · Thomas Petazzoni
Quoted 7 lines · On Wed, 5 Feb 2020 12:26:08 -0600 Matt Weber…

The update of rng-tools from 5 to 6.7 introduced a change where the jitterentropy library was enabled by default instead of returning a special 66 return code to hangle the case of no hwrng. This patch reverts that change and allows a user to select when to enable the jitterentropy source. The bug documents an issue of when a hwrng is enabled with jitterentropy there is a longer boot time.

Quoted 6 lines
Quoted 2 lines

I don't understand this story of the 66 return code. Could you explain a bit more ?

In Buildroot commit 22cb51e1 the systemd support addition included the successcode change based on the Fedora bugfix for ignoring if no hwrng is present (https://bugzilla.redhat.com/show_bug.cgi?id=892178).

Ryan Barnett noticed that rng-tools dropped the special return code. I guess we could just drop support for this special case as well....
https://github.com/nhorman/rng-tools/blob/v6.8/rngd.c#L805

Quoted 19 lines
Quoted 7 lines
Quoted 7 lines

index 11386d1e5d..c0bcffe59e 100644

package/rng-tools/rngd.service +0 -0
@@ -3,6 +3,7 @@ Description=Hardware RNG Entropy Gatherer Daemon
 
Quoted 5 lines

package/rng-tools/rngd.service Description=Hardware RNG Entropy Gatherer Daemon · line 6

Quoted 3 lines
package/rng-tools/rngd.service +1 -0
 [Service]
 ExecStart=/usr/sbin/rngd -f $DAEMON_ARGS
+SuccessExitStatus=66

Will this work even if jitterentropy support is enabled ?

My understanding is that you'd never hit this return case when jitterentropy support built in as it would always init the entropy pool using that library as a source. Thus the problem of the boot delay even when hwrng is present.

Matt

Signature · 23 lines
Matthew Weber | Associate Director Software Engineer | Commercial Avionics

COLLINS AEROSPACE

400 Collins Road NE, Cedar Rapids, Iowa 52498, USA

Tel: +1 319 295 7349 | FAX: +1 319 263 6099

matthew.weber at collins.com | collinsaerospace.com



CONFIDENTIALITY WARNING: This message may contain proprietary and/or
privileged information of Collins Aerospace and its affiliated
companies. If you are not the intended recipient, please 1) Do not
disclose, copy, distribute or use this message or its contents. 2)
Advise the sender by return email. 3) Delete all copies (including all
attachments) from your computer. Your cooperation is greatly
appreciated.


Any export restricted material should be shared using my
matthew.weber at corp.rockwellcollins.com address.
#4 lore raw

PATCH 1/1 package/rng-tools: make jitterentropy conditional

Quoted 25 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Matthew" == Matthew Weber <[email protected]> writes:

Thomas,

Quoted 20 lines · Matthew Weber

Thomas,

Quoted 14 lines · Thomas Petazzoni
Quoted 7 lines · On Wed, 5 Feb 2020 12:26:08 -0600 Matt Weber…

The update of rng-tools from 5 to 6.7 introduced a change where the jitterentropy library was enabled by default instead of returning a special 66 return code to hangle the case of no hwrng. This patch reverts that change and allows a user to select when to enable the jitterentropy source. The bug documents an issue of when a hwrng is enabled with jitterentropy there is a longer boot time.

I don't understand this story of the 66 return code. Could you explain a bit more ?

Quoted 7 lines
Quoted 3 lines

In Buildroot commit 22cb51e1 the systemd support addition included the successcode change based on the Fedora bugfix for ignoring if no hwrng is present (https://bugzilla.redhat.com/show_bug.cgi?id=892178).

Ryan Barnett noticed that rng-tools dropped the special return code. I guess we could just drop support for this special case as well....
https://github.com/nhorman/rng-tools/blob/v6.8/rngd.c#L805

Has that Fedora patch ever been included upstream? I don't seem to find it in the history.

I btw see there is a 6.9 release with more bugfixes, care to send a patch bumping the version?

Signature · 1 line
Bye, Peter Korsgaard
#5 lore raw

PATCH 1/1 package/rng-tools: make jitterentropy conditional

Peter,

Quoted 30 lines · Peter Korsgaard
Quoted 29 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

"Matthew" == Matthew Weber <[email protected]> writes:

Thomas,

Quoted 23 lines · Matthew Weber

Thomas,

Quoted 12 lines · Thomas Petazzoni
Quoted 7 lines · On Wed, 5 Feb 2020 12:26:08 -0600 Matt Weber…

The update of rng-tools from 5 to 6.7 introduced a change where the jitterentropy library was enabled by default instead of returning a special 66 return code to hangle the case of no hwrng. This patch reverts that change and allows a user to select when to enable the jitterentropy source. The bug documents an issue of when a hwrng is enabled with jitterentropy there is a longer boot time.

Quoted 2 lines

I don't understand this story of the 66 return code. Could you explain a bit more ?

In Buildroot commit 22cb51e1 the systemd support addition included the successcode change based on the Fedora bugfix for ignoring if no hwrng is present (https://bugzilla.redhat.com/show_bug.cgi?id=892178).

Quoted 6 lines
Quoted 3 lines

Ryan Barnett noticed that rng-tools dropped the special return code. I guess we could just drop support for this special case as well....
https://github.com/nhorman/rng-tools/blob/v6.8/rngd.c#L805

Has that Fedora patch ever been included upstream? I don't seem to find it in the history.

It doesn't look like it. I'm wondering if we should just drop this systemd unit return behavior and put a comment in the service file about enabling an entropy package if this service fails without a hardware rng present. Seems too complicated to try and cover this special case.

Quoted 3 lines

I btw see there is a 6.9 release with more bugfixes, care to send a patch bumping the version?

I'll review the one that was just sent. I also ping'd the original bug report to see if they could test with this bump as there are a number of minor jitterentropy related fixes.
http://patchwork.ozlabs.org/patch/1235396/

Matt

#6 lore raw

PATCH 1/1 package/rng-tools: make jitterentropy conditional

Hi Matt,

Quoted 49 lines · Matthew Weber

Peter,

Quoted 30 lines · Peter Korsgaard
Quoted 29 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

"Matthew" == Matthew Weber <[email protected]> writes:

Thomas,

Quoted 23 lines · Matthew Weber

Thomas,

Quoted 12 lines · Thomas Petazzoni
Quoted 7 lines · On Wed, 5 Feb 2020 12:26:08 -0600 Matt Weber…

The update of rng-tools from 5 to 6.7 introduced a change where the jitterentropy library was enabled by default instead of returning a special 66 return code to hangle the case of no hwrng. This patch reverts that change and allows a user to select when to enable the jitterentropy source. The bug documents an issue of when a hwrng is enabled with jitterentropy there is a longer boot time.

Quoted 2 lines

I don't understand this story of the 66 return code. Could you explain a bit more ?

In Buildroot commit 22cb51e1 the systemd support addition included the successcode change based on the Fedora bugfix for ignoring if no hwrng is present (https://bugzilla.redhat.com/show_bug.cgi?id=892178).

Quoted 6 lines
Quoted 3 lines

Ryan Barnett noticed that rng-tools dropped the special return code. I guess we could just drop support for this special case as well....
https://github.com/nhorman/rng-tools/blob/v6.8/rngd.c#L805

Has that Fedora patch ever been included upstream? I don't seem to find it in the history.

It doesn't look like it. I'm wondering if we should just drop this systemd unit return behavior and put a comment in the service file about enabling an entropy package if this service fails without a hardware rng present. Seems too complicated to try and cover this special case.

Quoted 1 line
Quoted 7 lines
Quoted 2 lines

I btw see there is a 6.9 release with more bugfixes, care to send a patch bumping the version?

I'll review the one that was just sent. I also ping'd the original bug report to see if they could test with this bump as there are a number of minor jitterentropy related fixes.
http://patchwork.ozlabs.org/patch/1235396/

We had similar issue today with am335x (kernel 5.4.x). Bumping rng-tools to v6.9 helped.

The next bump will be more interesting as rng-tools moves to openssl instead of libgcrypt and this dependency is mandatory.

Yegor

#7 lore raw

PATCH 1/1 package/rng-tools: make jitterentropy conditional

Yegor,

Quoted 57 lines · Yegor Yefremov

Hi Matt,

Quoted 52 lines · Matthew Weber

Peter,

Quoted 30 lines · Peter Korsgaard
Quoted 29 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

"Matthew" == Matthew Weber <[email protected]> writes:

Thomas,

Quoted 23 lines · Matthew Weber

Thomas,

Quoted 12 lines · Thomas Petazzoni
Quoted 7 lines · On Wed, 5 Feb 2020 12:26:08 -0600 Matt Weber…

The update of rng-tools from 5 to 6.7 introduced a change where the jitterentropy library was enabled by default instead of returning a special 66 return code to hangle the case of no hwrng. This patch reverts that change and allows a user to select when to enable the jitterentropy source. The bug documents an issue of when a hwrng is enabled with jitterentropy there is a longer boot time.

Quoted 2 lines

I don't understand this story of the 66 return code. Could you explain a bit more ?

In Buildroot commit 22cb51e1 the systemd support addition included the successcode change based on the Fedora bugfix for ignoring if no hwrng is present (https://bugzilla.redhat.com/show_bug.cgi?id=892178).

Quoted 6 lines
Quoted 3 lines

Ryan Barnett noticed that rng-tools dropped the special return code. I guess we could just drop support for this special case as well....
https://github.com/nhorman/rng-tools/blob/v6.8/rngd.c#L805

Has that Fedora patch ever been included upstream? I don't seem to find it in the history.

It doesn't look like it. I'm wondering if we should just drop this systemd unit return behavior and put a comment in the service file about enabling an entropy package if this service fails without a hardware rng present. Seems too complicated to try and cover this special case.

Quoted 3 lines

I btw see there is a 6.9 release with more bugfixes, care to send a patch bumping the version?

Quoted 8 lines
Quoted 4 lines

I'll review the one that was just sent. I also ping'd the original bug report to see if they could test with this bump as there are a number of minor jitterentropy related fixes.
http://patchwork.ozlabs.org/patch/1235396/

We had similar issue today with am335x (kernel 5.4.x). Bumping rng-tools to v6.9 helped.

Thank you for that feedback, I'll make this patch is superseded as the bump resolved the bug. I'll add a note with this patchwork thread in the bug report as well.

Matt

#8 lore raw

PATCH 1/1 package/rng-tools: make jitterentropy conditional

Hello Matt,

Quoted 6 lines · On Thu, 13 Feb 2020 11:07:36 -0600 Matthew Weber…
Quoted 2 lines

We had similar issue today with am335x (kernel 5.4.x). Bumping rng-tools to v6.9 helped.

Thank you for that feedback, I'll make this patch is superseded as the bump resolved the bug. I'll add a note with this patchwork thread in the bug report as well.

As I was going through open bug reports, I looked again at
https://bugs.busybox.net/show_bug.cgi?id=12511, and I disagree with the conclusion of discarding this patch "package/rng-tools: make jitterentropy conditional".

If I understand correctly:

- If you have a hardware RNG, the jitterentropy library is not necessary.

- If you don't have a hardware RNG, rng-tools will error out, unless jitterentropy support is enabled.

So, we really want to make the jitterentropy support in rng-tools optional, and leave it up to the user to enable it if (s)he has no hardware RNG available. And if there's no hardware RNG and no jitterentropy support, rng-tools will error out, the service will fail to start, and that's good. So the trick with the special 66 return code is not necessary.

Do you agree ?

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#9 lore raw

PATCH 1/1 package/rng-tools: make jitterentropy conditional

Thomas,

Quoted 18 lines · Thomas Petazzoni

Hello Matt,

Quoted 6 lines · On Thu, 13 Feb 2020 11:07:36 -0600 Matthew Weber…
Quoted 2 lines

We had similar issue today with am335x (kernel 5.4.x). Bumping rng-tools to v6.9 helped.

Thank you for that feedback, I'll make this patch is superseded as the bump resolved the bug. I'll add a note with this patchwork thread in the bug report as well.

As I was going through open bug reports, I looked again at
https://bugs.busybox.net/show_bug.cgi?id=12511, and I disagree with the conclusion of discarding this patch "package/rng-tools: make jitterentropy conditional".

Quoted 5 lines

If I understand correctly:

- If you have a hardware RNG, the jitterentropy library is not necessary.

Right, jitterentropy is a fall back if there isn't a hardware RNG setup. The performance impacts of having it enabled when there is a hardware RNG were improved between versions and that was the motivation to drop this patch as it didn't seem to still be a bug (having it enabled when it isn't really needed).

Quoted 2 lines

- If you don't have a hardware RNG, rng-tools will error out, unless jitterentropy support is enabled.

Correct.

Quoted 9 lines

So, we really want to make the jitterentropy support in rng-tools optional, and leave it up to the user to enable it if (s)he has no hardware RNG available. And if there's no hardware RNG and no jitterentropy support, rng-tools will error out, the service will fail to start, and that's good. So the trick with the special 66 return code is not necessary.

Do you agree ?

I agree, we should drop that rngd.service change but still keep the option where a user could add the jitterentropy library if they need it.

Regards,
Matt