Package: rng-tools5
Version: 5-1
Severity: normal
Tags: patch

Dear Maintainer,

rngd can hang at shutdown when busy, as it will loop without checking
for the termination condition.

The inlined patch has been merged upstream [1] and was originally
posted by Leonardo Chiquitto on Sourceforge [2].

I attached a version of the patch for v5, so please consider it for
Debian until the next release is available and uploaded, to avoid this
annoying problem.

Thank you!

-- 
Kind regards,
Luca Boccassi

[1] https://github.com/nhorman/rng-tools/pull/14
[2] https://sourceforge.net/p/gkernel/bugs/135/
Description: Check for signals in update_kernel_random()
 When running as a daemon, a signal handler is installed to catch
 SIGINT/SIGTERM. This handler sets a flag that's tested in the main
 loop. However, rngd loops in update_kernel_random() as well, where
 the flag was not tested.
 This patch adds the check to update_kernel_random() so that the
 daemon exits properly after receiving a SIGINT/SIGTERM signal.
Author: Leonardo Chiquitto <[email protected]>
Origin: https://sourceforge.net/p/gkernel/bugs/135/
Applied-Upstream: https://github.com/nhorman/rng-tools/pull/14
--- a/rngd.c
+++ b/rngd.c
@@ -218,6 +218,8 @@ static int update_kernel_random(int random_step,
 
 	for (p = buf; p + random_step <= &buf[FIPS_RNG_BUFFER_SIZE];
 		 p += random_step) {
+		if (!server_running)
+			return 0;
 		random_add_entropy(p, random_step);
 		random_sleep();
 	}
@@ -239,10 +241,10 @@ static void do_loop(int random_step)
 		{
 			int rc;
 
+		retry_same:
 			if (!server_running)
 				return;
 
-		retry_same:
 			if (iter->disabled)
 				continue;	/* failed, no work */
 

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to