fix unsignedinteger subtraction sign overflow

This commit is contained in:
SuperSix173 2021-08-25 10:33:17 +08:00
parent fc1ac67f3d
commit 447738fc06
3 changed files with 43 additions and 6 deletions

View File

@ -0,0 +1,26 @@
From 2a66a666d3e202dec5b1a4309447e32d5f292871 Mon Sep 17 00:00:00 2001
From: liuchao173 <55137861+liuchao173@users.noreply.github.com>
Date: Tue, 24 Aug 2021 20:50:18 +0800
Subject: [PATCH] fix unsigned integer subtraction sign overflow
Min_load, adjustment_load and load are unsigned integers, so it overflows when (lb_info->min_load + info->load) < (lb_info->adjustment_load - info->load). The result will be greater than zero. Therefore the irq cannot be selected to rebalanced.
---
irqlist.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/irqlist.c b/irqlist.c
index 9ab321a..4dd4a83 100644
--- a/irqlist.c
+++ b/irqlist.c
@@ -97,7 +97,7 @@ static void move_candidate_irqs(struct irq_info *info, void *data)
}
/* If we can migrate an irq without swapping the imbalance do it. */
- if ((lb_info->min_load + info->load) - (lb_info->adjustment_load - info->load) < delta_load) {
+ if ((lb_info->min_load + info->load) < delta_load + (lb_info->adjustment_load - info->load)) {
lb_info->adjustment_load -= info->load;
lb_info->min_load += info->load;
if (lb_info->min_load > lb_info->adjustment_load) {
--
1.8.3.1

View File

@ -8,7 +8,7 @@ the min_load after moving irq. However, we can accept that the delta load become
---
irqbalance.c | 8 +++++++-
irqbalance.h | 1 +
irqlist.c | 3 ++-
irqlist.c | 6 ++++-
3 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/irqbalance.c b/irqbalance.c
@ -74,13 +74,16 @@ diff --git a/irqlist.c b/irqlist.c
index 9ab321a..98a4224 100644
--- a/irqlist.c
+++ b/irqlist.c
@@ -97,7 +97,8 @@ static void move_candidate_irqs(struct irq_info *info, void *data)
@@ -97,7 +97,11 @@ static void move_candidate_irqs(struct irq_info *info, void *data)
}
/* If we can migrate an irq without swapping the imbalance do it. */
- if ((lb_info->min_load + info->load) - (lb_info->adjustment_load - info->load) < delta_load) {
+ if ((lb_info->min_load + info->load) - (lb_info->adjustment_load - info->load) < delta_load &&
+ lb_info->adjustment_load > load_limit) {
- if ((lb_info->min_load + info->load) < delta_load + (lb_info->adjustment_load - info->load)) {
+ if ((lb_info->adjustment_load - info->load) > (lb_info->min_load + info->load)) {
+ lb_info->adjustment_load -= info->load;
+ lb_info->min_load += info->load;
+ } else if (delta_load && load_limit && (lb_info->adjustment_load > load_limit) &&
+ (lb_info->min_load + info->load) < (lb_info->adjustment_load - info->load) + delta_load) {
lb_info->adjustment_load -= info->load;
lb_info->min_load += info->load;
if (lb_info->min_load > lb_info->adjustment_load) {

View File

@ -1,7 +1,7 @@
Summary: A dynamic adaptive IRQ balancing daemon
Name: irqbalance
Version: 1.8.0
Release: 2
Release: 3
Epoch: 3
License: GPLv2
Source0: https://github.com/Irqbalance/irqbalance/archive/v%{version}.tar.gz#/irqbalance-%{version}.tar.gz
@ -23,6 +23,8 @@ Requires: numactl-libs
%define _hardened_build 1
Patch6000: bugfix-fix-unsigned-integer-subtraction-sign-overflow.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 +121,12 @@ fi
/sbin/chkconfig --del %{name} >/dev/null 2>&1 || :
%changelog
* Wed Aug 25 2021 Liu Chao <liuchao173@huawei.com> - 3:1.8.0-3
- Type:bugfix
- ID:NA
- SUG:restart
- DESC:fix unsigned integer subtraction sign overflow
* Tue Aug 24 2021 Liu Chao <liuchao173@huawei.com> - 3:1.8.0-2
- Type:bugfix
- ID:NA