lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210219113101.967508-3-vkuznets@redhat.com>
Date:   Fri, 19 Feb 2021 12:31:01 +0100
From:   Vitaly Kuznetsov <vkuznets@...hat.com>
To:     Thomas Gleixner <tglx@...utronix.de>, x86@...nel.org
Cc:     Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        "H. Peter Anvin" <hpa@...or.com>, linux-kernel@...r.kernel.org
Subject: [PATCH RFC 2/2] genirq/matrix: WARN_ON_ONCE() when cm->allocated/m->total_allocated go negative

When irq_matrix_assign()/irq_matrix_free() calls get unsynced, weird
effects are possible, e.g. when cm->allocated goes negative CPU hotplug
may get blocked. Add WARN_ON_ONCE() to simplify detecting such situations.

Signed-off-by: Vitaly Kuznetsov <vkuznets@...hat.com>
---
 kernel/irq/matrix.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/kernel/irq/matrix.c b/kernel/irq/matrix.c
index 651a4ad6d711..2438a4f9d726 100644
--- a/kernel/irq/matrix.c
+++ b/kernel/irq/matrix.c
@@ -189,7 +189,9 @@ void irq_matrix_assign_system(struct irq_matrix *m, unsigned int bit,
 	set_bit(bit, m->system_map);
 	if (replace) {
 		BUG_ON(!test_and_clear_bit(bit, cm->alloc_map));
+		WARN_ON_ONCE(!cm->allocated);
 		cm->allocated--;
+		WARN_ON_ONCE(!m->total_allocated);
 		m->total_allocated--;
 	}
 	if (bit >= m->alloc_start && bit < m->alloc_end)
@@ -424,12 +426,17 @@ void irq_matrix_free(struct irq_matrix *m, unsigned int cpu,
 		return;
 
 	clear_bit(bit, cm->alloc_map);
+	WARN_ON_ONCE(!cm->allocated);
 	cm->allocated--;
-	if(managed)
+	if (managed) {
+		WARN_ON_ONCE(!cm->managed_allocated);
 		cm->managed_allocated--;
+	}
 
-	if (cm->online)
+	if (cm->online) {
+		WARN_ON_ONCE(!m->total_allocated);
 		m->total_allocated--;
+	}
 
 	if (!managed) {
 		cm->available++;
-- 
2.29.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ