From 9ba312d482b3a6023b22eb95b9dd6ac7749a73b5 Mon Sep 17 00:00:00 2001 From: qinyu Date: Tue, 12 Jul 2022 10:04:35 +0800 Subject: [PATCH] bugfix:fix potential dead loop when parsing interrupts when parsing /proc/interrupts and if a chip name start with numbers, current procedure would consider those numbers as interrupt count thus lead to miscount. Failed parsing would trigger new parsing and cause dead loop which can't be stopped by SIGINT and SIGTERM. So fix this by adding signal checks in loop. Signed-off-by: qinyu --- ...e-from-failing-to-exit-after-SIGTERM.patch | 26 +++++++++++++++++++ ...errupts-fix-parsing-interrupt-counts.patch | 25 ++++++++++++++++++ irqbalance.spec | 11 +++++++- 3 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 bugfix-add-keep_going-check-to-prevent-irqbalance-from-failing-to-exit-after-SIGTERM.patch create mode 100644 bugfix-parse_proc_interrupts-fix-parsing-interrupt-counts.patch diff --git a/bugfix-add-keep_going-check-to-prevent-irqbalance-from-failing-to-exit-after-SIGTERM.patch b/bugfix-add-keep_going-check-to-prevent-irqbalance-from-failing-to-exit-after-SIGTERM.patch new file mode 100644 index 0000000..b53cca0 --- /dev/null +++ b/bugfix-add-keep_going-check-to-prevent-irqbalance-from-failing-to-exit-after-SIGTERM.patch @@ -0,0 +1,26 @@ +From 028082a6a1ff650d5cdf796ac55ac26a3874372a Mon Sep 17 00:00:00 2001 +From: Liu Chao +Date: Sat, 25 Jun 2022 14:13:10 +0800 +Subject: [PATCH] add keep_going check to prevent irqbalance from failing to + exit after SIGTERM + +Signed-off-by: Liu Chao +--- + irqbalance.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/irqbalance.c b/irqbalance.c +index c520c11..5eae5b6 100644 +--- a/irqbalance.c ++++ b/irqbalance.c +@@ -290,7 +290,7 @@ gboolean scan(gpointer data __attribute__((unused))) + + + /* cope with cpu hotplug -- detected during /proc/interrupts parsing */ +- while (need_rescan || need_rebuild) { ++ while (keep_going && (need_rescan || need_rebuild)) { + int try_times = 0; + + need_rescan = 0; +-- +2.23.0 \ No newline at end of file diff --git a/bugfix-parse_proc_interrupts-fix-parsing-interrupt-counts.patch b/bugfix-parse_proc_interrupts-fix-parsing-interrupt-counts.patch new file mode 100644 index 0000000..2fb971f --- /dev/null +++ b/bugfix-parse_proc_interrupts-fix-parsing-interrupt-counts.patch @@ -0,0 +1,25 @@ +From 0a82dddbaf5702caded0d0d83a6eafaca743254d Mon Sep 17 00:00:00 2001 +From: Andreas Schwab +Date: Mon, 27 Jun 2022 13:43:04 +0200 +Subject: [PATCH] parse_proc_interrupts: fix parsing interrupt counts + +The name of an interrupt chip can start with a number, stop before it. +--- + procinterrupts.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/procinterrupts.c b/procinterrupts.c +index 57c8801..d90bf6d 100644 +--- a/procinterrupts.c ++++ b/procinterrupts.c +@@ -331,7 +331,7 @@ void parse_proc_interrupts(void) + while (1) { + uint64_t C; + C = strtoull(c, &c2, 10); +- if (c==c2) /* end of numbers */ ++ if (c==c2 || !strchr(" \t", *c2)) /* end of numbers */ + break; + count += C; + c=c2; +-- +2.23.0 \ No newline at end of file diff --git a/irqbalance.spec b/irqbalance.spec index 68cf3da..be63af0 100644 --- a/irqbalance.spec +++ b/irqbalance.spec @@ -1,7 +1,7 @@ Summary: A dynamic adaptive IRQ balancing daemon Name: irqbalance Version: 1.9.0 -Release: 1 +Release: 2 Epoch: 3 License: GPLv2 Source0: https://github.com/Irqbalance/irqbalance/archive/v%{version}.tar.gz#/irqbalance-%{version}.tar.gz @@ -23,6 +23,9 @@ Requires: numactl-libs %define _hardened_build 1 +Patch6000: bugfix-parse_proc_interrupts-fix-parsing-interrupt-counts.patch +Patch6001: bugfix-add-keep_going-check-to-prevent-irqbalance-from-failing-to-exit-after-SIGTERM.patch + Patch9000: feature-aarch64-add-the-regular-to-get-the-correct-i.patch Patch9001: feature-add-new-user-irq-policy-config-rule.patch Patch9002: feature-add-the-switch-of-printing-log.patch @@ -119,6 +122,12 @@ fi /sbin/chkconfig --del %{name} >/dev/null 2>&1 || : %changelog +* Tue Jul 12 2022 qinyu - 3:1.9.0-2 +- Type:bugfix +- ID:NA +- SUG:restart +- DESC: fix potential dead loop when parsing interrupts + * Thu Jul 7 2022 Liu Chao - 3:1.9.0-1 - Type:enhanced - ID:NA