diff --git a/0001-irqbalance-ui-skip-in-parse_setup-to-avoid-coredump.patch b/0001-irqbalance-ui-skip-in-parse_setup-to-avoid-coredump.patch new file mode 100644 index 0000000..3ed91e4 --- /dev/null +++ b/0001-irqbalance-ui-skip-in-parse_setup-to-avoid-coredump.patch @@ -0,0 +1,64 @@ +From c8d1fff0f16ad906cca153a22faac11516ccc0dd Mon Sep 17 00:00:00 2001 +From: Liu Chao +Date: Mon, 18 Jul 2022 16:54:53 +0800 +Subject: [PATCH] irqbalance-ui: skip ',' in parse_setup to avoid coredump + +When processing the ',' in hex_to_bitmap, it returns '0000\ 0' directly. +The return value will be freed in parse_setup, but it is not requested +through malloc. + +Fixes: 85d37098a551 ("Fix several memleak problems found by covscan") + +And it treat ',' as "0000", which cause irqbalance-ui will display wrong +Banned CPU numbers. + +For example: +# IRQBALANCE_BANNED_CPUS="00000002,00000000,00000000" ./irqbalance +or +# IRQBALANCE_BANNED_CPULIST="65" ./irqbalance + +# ./irqbalance-ui +Banned CPU numbers: 73 + +Fixes: 76d1c9d73935 ("Add main user interface files") + +Signed-off-by: Liu Chao +--- + ui/irqbalance-ui.c | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +diff --git a/ui/irqbalance-ui.c b/ui/irqbalance-ui.c +index 47b6c88..b7f9b62 100644 +--- a/ui/irqbalance-ui.c ++++ b/ui/irqbalance-ui.c +@@ -142,7 +142,7 @@ try_again: + void parse_setup(char *setup_data) + { + char *token, *ptr; +- int i,j; ++ int i,j, cpu = 0; + char *copy; + irq_t *new_irq = NULL; + if((setup_data == NULL) || (strlen(setup_data) == 0)) return; +@@ -179,14 +179,17 @@ void parse_setup(char *setup_data) + if(strncmp(token, "BANNED", strlen("BANNED"))) goto out; + token = strtok_r(NULL, " ", &ptr); + for(i = strlen(token) - 1; i >= 0; i--) { ++ if (token[i] == ',') ++ continue; + char *map = hex_to_bitmap(token[i]); + for(j = 3; j >= 0; j--) { + if(map[j] == '1') { + uint64_t *banned_cpu = malloc(sizeof(uint64_t)); +- *banned_cpu = (4 * (strlen(token) - (i + 1)) + (4 - (j + 1))); ++ *banned_cpu = cpu; + setup.banned_cpus = g_list_append(setup.banned_cpus, + banned_cpu); + } ++ cpu++; + } + free(map); + +-- +2.33.1 + diff --git a/irqbalance.spec b/irqbalance.spec index 4dc5aba..3b6a469 100644 --- a/irqbalance.spec +++ b/irqbalance.spec @@ -1,6 +1,6 @@ Name: irqbalance Version: 1.9.0 -Release: 2%{?dist} +Release: 3%{?dist} Epoch: 2 Summary: IRQ balancing daemon @@ -38,6 +38,7 @@ Patch12: 0011-fix-memory-leak-in-ui-ui.c.patch Patch13: 0012-irqbalance-ui-support-scroll-under-tui-mode-of-irqba.patch Patch14: 0013-irqbalance-ui-print-cpulist-in-SETUP-IRQS.patch Patch15: 0014-Improve-documentation-and-logging-for-banned-cpus.patch +Patch16: 0001-irqbalance-ui-skip-in-parse_setup-to-avoid-coredump.patch %description irqbalance is a daemon that evenly distributes IRQ load across @@ -60,6 +61,7 @@ multiple CPUs for enhanced performance. %patch13 -p1 %patch14 -p1 %patch15 -p1 +%patch16 -p1 %build ./autogen.sh @@ -102,6 +104,9 @@ fi /sbin/chkconfig --del irqbalance >/dev/null 2>&1 || : %changelog +* Tue Jul 19 2022 Tao Liu - 2:1.9.0-3 +- Rebase to latest upstream commit (c8d1fff0f1) + * Thu Jul 14 2022 Tao Liu - 2:1.9.0-2 - Rebase to latest upstream commit (167580790c)