void-packages/srcpkgs/rng-tools/patches/rdrand.patch
Lon Willett 193e014141 rng-tools: add patch from upstream to fix rngd (#3442)
"rngd" currently crashes (smashed stack) on 64-bit machines that
support the RDRAND instruction, unless you expicitly disable its use.
This fixes the problem.
2018-10-04 23:35:44 +02:00

24 lines
900 B
Diff

This patch from upstream (https://github.com/nhorman/rng-tools/commit/f12a80185a4bbf65fbc860f2d2e25af67c70ad6b)
will allow rngd to run. It can safely be deleted as soon as there is another upstream release.
Without this patch, rngd will die with a "smashed stack" on 64-bit machines that support the RDRAND instruction.
--- rngd_rdrand.c.orig 2018-09-25 19:54:05.000000000 +0200
+++ rngd_rdrand.c 2018-10-01 05:42:38.655982555 +0200
@@ -246,7 +246,14 @@
if (ent_src->rng_options[DRNG_OPT_AES].int_val)
return xread_drng_with_aes(buf, size, ent_src);
- x86_rdrand_bytes(buf, size);
+ /* NB: x86_rdrand_bytes might overrun end of buffer, if not a multiple of 8 */
+ if (size > 7)
+ x86_rdrand_bytes(buf, (size&~7));
+ if ((size&7) != 0) {
+ unsigned char tempbuf[8];
+ x86_rdrand_bytes(tempbuf, (size&7));
+ memcpy((unsigned char *)buf+(size&~7), tempbuf, (size&7));
+ }
return 0;
}