From 4d7ded18bda8d0ee475cf32171401d8393ae974f Mon Sep 17 00:00:00 2001 From: langfei Date: Mon, 17 Mar 2025 08:16:32 -0400 Subject: [PATCH] Check the length of path Signed-off-by: langfei (cherry picked from commit 670ef67d4f9657a789fc8c5fde1b28cb7e50c0eb) --- ...form_device-Check-the-length-of-path.patch | 35 +++++++++++++++++++ irqbalance.spec | 9 ++++- 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 backport-check_platform_device-Check-the-length-of-path.patch diff --git a/backport-check_platform_device-Check-the-length-of-path.patch b/backport-check_platform_device-Check-the-length-of-path.patch new file mode 100644 index 0000000..ed1ed62 --- /dev/null +++ b/backport-check_platform_device-Check-the-length-of-path.patch @@ -0,0 +1,35 @@ +From d602002e1982a322d19034a4a64ca5a81bace7ef Mon Sep 17 00:00:00 2001 +From: Tao Liu +Date: Tue, 25 Feb 2025 16:35:34 +1300 +Subject: [PATCH] check_platform_device: Check the length of path + +The default length of path is 512, but the strcat() is used without +check if path is overflowed, otherwise a segfault is observed on +some aarch64 machines. This patch will use snprintf instead of strcat +for the buffer length checking. + +Signed-off-by: Tao Liu + +Reference:https://github.com/Irqbalance/irqbalance/commit/d602002e1982a322d19034a4a64ca5a81bace7ef +Conflict:NA +--- + procinterrupts.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/procinterrupts.c b/procinterrupts.c +index 4d04bf2..e82fac7 100644 +--- a/procinterrupts.c ++++ b/procinterrupts.c +@@ -72,7 +72,8 @@ static int check_platform_device(char *name, struct irq_info *info) + memset(path, 0, 512); + + strcat(path, "/sys/devices/platform/"); +- strcat(path, name); ++ snprintf(path + strlen(path), sizeof(path) - strlen(path) - 1, ++ "%s", name); + strcat(path, "/"); + dirfd = opendir(path); + +-- +2.28.0.windows.1 + diff --git a/irqbalance.spec b/irqbalance.spec index 159ff9e..ebee337 100644 --- a/irqbalance.spec +++ b/irqbalance.spec @@ -1,7 +1,7 @@ Summary: A dynamic adaptive IRQ balancing daemon Name: irqbalance Version: 1.9.2 -Release: 6 +Release: 7 Epoch: 3 License: GPLv2 Source0: https://github.com/Irqbalance/irqbalance/archive/v%{version}.tar.gz#/irqbalance-%{version}.tar.gz @@ -37,6 +37,7 @@ Patch6010: backport-Fix-socket-API-being-blocked-for-10s.patch Patch6011: backport-Flush-file-before-closing.patch Patch6012: backport-Check-fflush-return-value.patch Patch6013: backport-fix-32-bit-formats.patch +Patch6014: backport-check_platform_device-Check-the-length-of-path.patch Patch9000: feature-aarch64-add-the-regular-to-get-the-correct-i.patch Patch9001: feature-add-new-user-irq-policy-config-rule.patch @@ -133,6 +134,12 @@ fi /sbin/chkconfig --del %{name} >/dev/null 2>&1 || : %changelog +* Mon Mar 17 2025 langfei - 3:1.9.2-7 +- Type:bugfix +- ID:NA +- SUG:restart +- DESC: Check the length of path + * Fri Sep 06 2024 lvgenggeng - 3:1.9.2-6 - Type:bugfix - ID:NA