From 193e0141415fc99a1a38dffd4b314dac2c3ffcf4 Mon Sep 17 00:00:00 2001 From: Lon Willett Date: Thu, 4 Oct 2018 23:35:44 +0200 Subject: [PATCH] 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. --- srcpkgs/rng-tools/patches/rdrand.patch | 24 ++++++++++++++++++++++++ srcpkgs/rng-tools/template | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 srcpkgs/rng-tools/patches/rdrand.patch diff --git a/srcpkgs/rng-tools/patches/rdrand.patch b/srcpkgs/rng-tools/patches/rdrand.patch new file mode 100644 index 00000000000..791cd1d698c --- /dev/null +++ b/srcpkgs/rng-tools/patches/rdrand.patch @@ -0,0 +1,24 @@ +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; + } + diff --git a/srcpkgs/rng-tools/template b/srcpkgs/rng-tools/template index d2b4772aaac..1d7d322e9ba 100644 --- a/srcpkgs/rng-tools/template +++ b/srcpkgs/rng-tools/template @@ -1,7 +1,7 @@ # Template file for 'rng-tools' pkgname=rng-tools version=6.5 -revision=1 +revision=2 wrksrc=${pkgname}-${version} build_style=gnu-configure makedepends="libgcrypt-devel libsysfs-devel libcurl-devel libxml2-devel"