From a5d957ea86c2ec7d30a8879e6af47d4e8a32dce5 Mon Sep 17 00:00:00 2001 From: yang_zhuang_zhuang <1162011203@qq.com> Date: Thu, 10 Dec 2020 19:12:22 +0800 Subject: [PATCH] fic rngd.service coredump --- ...hread-if-getaffinity-returns-an-erro.patch | 34 +++++++++++++++++++ rng-tools.spec | 6 +++- 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 backport-Default-to-one-thread-if-getaffinity-returns-an-erro.patch diff --git a/backport-Default-to-one-thread-if-getaffinity-returns-an-erro.patch b/backport-Default-to-one-thread-if-getaffinity-returns-an-erro.patch new file mode 100644 index 0000000..1cf5f07 --- /dev/null +++ b/backport-Default-to-one-thread-if-getaffinity-returns-an-erro.patch @@ -0,0 +1,34 @@ +From d2b4876231ac9c2e26880ebe428bfb41e60e098e Mon Sep 17 00:00:00 2001 +From: Neil Horman +Date: Wed, 19 Dec 2018 10:10:44 -0500 +Subject: [PATCH] Default to one thread if getaffinity returns an error + +Its possible on virt systems, for sched_getaffinity to return an error +if the vm has cpus, but cgroup placement restricts that set to 0 +physical processors. In that event, just default to 1 thread on cpu 0 + +Signed-off-by: Neil Horman +--- + rngd_jitter.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/rngd_jitter.c b/rngd_jitter.c +index 4e4b348..d14a3ba 100644 +--- a/rngd_jitter.c ++++ b/rngd_jitter.c +@@ -421,7 +421,11 @@ int init_jitter_entropy_source(struct rng *ent_src) + cpus = CPU_ALLOC(i); + cpusize = CPU_ALLOC_SIZE(i); + CPU_ZERO_S(cpusize, cpus); +- sched_getaffinity(0, cpusize, cpus); ++ if (sched_getaffinity(0, cpusize, cpus) < 0) { ++ message(LOG_DAEMON|LOG_DEBUG, "Can not determine affinity of process, defaulting to 1 thread\n"); ++ CPU_SET(0,cpus); ++ } ++ + num_threads = CPU_COUNT_S(cpusize, cpus); + + if (num_threads >= ent_src->rng_options[JITTER_OPT_THREADS].int_val) +-- +2.17.2 + diff --git a/rng-tools.spec b/rng-tools.spec index 8da8fbf..9e29f71 100644 --- a/rng-tools.spec +++ b/rng-tools.spec @@ -1,6 +1,6 @@ Name: rng-tools Version: 6.5 -Release: 1 +Release: 2 Summary: Random number generator daemon License: GPLv2+ URL: https://github.com/nhorman/rng-tools @@ -9,6 +9,7 @@ Source1: rngd.service Source2: jitterentropy-library-2.2.0.tar.gz Patch0: jitterentropy-remove-install.patch +Patch1: backport-Default-to-one-thread-if-getaffinity-returns-an-erro.patch #Dependency BuildRequires: gcc make gettext systemd autoconf automake @@ -59,6 +60,9 @@ install -D -t $RPM_BUILD_ROOT%{_unitdir} -m 0644 %{SOURCE1} %{_mandir}/man8/rngd.8.* %changelog +* Thu Dec 10 2020 yangzhuangzhuang - 6.5-2 +- fix rngd.service coredump + * Sat Aug 29 2020 Yeqing Peng - 6.5-1 - since 6.6, jitterentropy-library is independed from rng-tools, no any entropy source will lead to rng-tools service fail. -- Gitee