Skip to contentSkip to conversation

rng-tools: modify 'read error' message

PATCH In review Joe Slater 2 participants 2 messages Jan 25, 2018

lore
Share & tools
lore

Joe Slater

author
#0 lore raw

PATCH 1/1 rng-tools: modify 'read error' message

Expand messages output if entropy data cannot
be read.

---
 .../rng-tools/rng-tools/read_error_msg.patch       | 98 ++++++++++++++++++++++
 meta/recipes-support/rng-tools/rng-tools_5.bb      |  1 +
 2 files changed, 99 insertions(+)
 create mode 100644 meta/recipes-support/rng-tools/rng-tools/read_error_msg.patch
meta/recipes-support/rng-tools/rng-tools/read_error_msg.patch new file +98 -0
new file mode 100644
index 0000000..8aa13bf
@@ -0,0 +1,98 @@
+rng-tools: modify 'read error' message
+
+Make the 'read error' message more descriptive.
+
+Copied from https://bugzilla.redhat.com/attachment.cgi?id=1295857
+and modified in one place to apply successfully.  Error message during
+bootstrap modified to show device name.
+
+Upstream-Status: pending
+
+Signed-off-by: Joe Slater <[email protected]>
+
+
+--- a/rngd.c
++++ b/rngd.c
+@@ -247,8 +247,11 @@ static void do_loop(int random_step)
+ 				continue;	/* failed, no work */
+ 
+ 			retval = iter->xread(buf, sizeof buf, iter);
+-			if (retval)
++			if (retval) {
++				message(LOG_DAEMON|LOG_ERR,
++					"Error reading from entropy source\n");
+ 				continue;	/* failed, no work */
++			}
+ 
+ 			work_done = true;
+ 
+--- a/rngd_entsource.c
++++ b/rngd_entsource.c
+@@ -63,10 +63,8 @@ int xread(void *buf, size_t size, struct
+ 		size -= r;
+ 	}
+ 
+-	if (size) {
+-		message(LOG_DAEMON|LOG_ERR, "read error\n");
++	if (size)
+ 		return -1;
+-	}
+ 	return 0;
+ }
+ 
+@@ -152,7 +150,7 @@ error_out:
+ }
+ 
+ /* Initialize entropy source */
+-static int discard_initial_data(struct rng *ent_src)
++static int discard_initial_data(struct rng *ent_src, int *buf)
+ {
+ 	/* Trash 32 bits of what is probably stale (non-random)
+ 	 * initial state from the RNG.  For Intel's, 8 bits would
+@@ -164,10 +162,12 @@ static int discard_initial_data(struct r
+ 	xread(tempbuf, sizeof(tempbuf), ent_src);
+ 
+ 	/* Return 32 bits of bootstrap data */
+-	xread(tempbuf, sizeof(tempbuf), ent_src);
++	if (xread(tempbuf, sizeof(tempbuf), ent_src) != 0)
++		return -1;
+ 
+-	return tempbuf[0] | (tempbuf[1] << 8) |
++	*buf = tempbuf[0] | (tempbuf[1] << 8) |
+ 		(tempbuf[2] << 16) | (tempbuf[3] << 24);
++	return 0;
+ }
+ 
+ /*
+@@ -175,6 +175,8 @@ static int discard_initial_data(struct r
+  */
+ int init_entropy_source(struct rng *ent_src)
+ {
++	int bootstrap;
++
+ 	ent_src->rng_fd = open(ent_src->rng_name, O_RDONLY);
+ 	if (ent_src->rng_fd == -1) {
+ 		return 1;
+@@ -182,7 +184,11 @@ int init_entropy_source(struct rng *ent_
+ 	src_list_add(ent_src);
+ 	/* Bootstrap FIPS tests */
+ 	ent_src->fipsctx = malloc(sizeof(fips_ctx_t));
+-	fips_init(ent_src->fipsctx, discard_initial_data(ent_src));
++	if (discard_initial_data(ent_src, &bootstrap) != 0) {
++		message(LOG_ERR|LOG_INFO, "Read failure in %s during bootstrap\n",ent_src->rng_name);
++		return 1;
++	}
++	fips_init(ent_src->fipsctx, bootstrap);
+ 	return 0;
+ }
+ 
+--- a/rngtest.c
++++ b/rngtest.c
+@@ -335,6 +335,7 @@ static int discard_initial_data(void)
+ 
+ 	return tempbuf[0] | (tempbuf[1] << 8) |
+ 		(tempbuf[2] << 16) | (tempbuf[3] << 24);
++
+ }
+ 
+ static void do_rng_fips_test_loop( void )
meta/recipes-support/rng-tools/rng-tools_5.bb +1 -0
index 4a66bed..b3c9fd9 100644
@@ -7,6 +7,7 @@ SRC_URI = "${SOURCEFORGE_MIRROR}/gkernel/${BP}.tar.gz \
            file://0002-Add-argument-to-control-the-libargp-dependency.patch \
            file://underquote.patch \
            file://rng-tools-5-fix-textrels-on-PIC-x86.patch \
+           file://read_error_msg.patch \
            file://init \
            file://default \
            file://rngd.service \
Signature · 1 line
2.7.4
#1 lore raw

✗ patchtest: failure for rng-tools: modify 'read error' message

== Series Details ==

Series: rng-tools: modify 'read error' message
Revision: 1
URL : https://patchwork.openembedded.org/series/10705/
State : failure

== Summary ==

Thank you for submitting this patch series to OpenEmbedded Core. This is an automated response. Several tests have been executed on the proposed series by patchtest resulting in the following failures:

* Issue Upstream-Status is in incorrect format [test_upstream_status_presence_format]

  Suggested fix    Fix Upstream-Status format in read_error_msg.patch
  Current          Upstream-Status: pending
  Standard format  Upstream-Status: <Valid status>
  Valid status     Pending, Accepted, Backport, Denied, Inappropriate [reason], Submitted [where]

If you believe any of these test results are incorrect, please reply to the mailing list ([email protected]) raising your concerns. Otherwise we would appreciate you correcting the issues and submitting a new version of the patchset if applicable. Please ensure you add/increment the version number when sending the new version (i.e. [PATCH] -> [PATCH v2] -> [PATCH v3] -> ...).

---

Guidelines:     https://www.openembedded.org/wiki/Commit_Patch_Message_Guidelines
Test framework: http://git.yoctoproject.org/cgit/cgit.cgi/patchtest
Test suite:     http://git.yoctoproject.org/cgit/cgit.cgi/patchtest-oe