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-2-vkuznets@redhat.com>
Date:   Fri, 19 Feb 2021 12:31:00 +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 1/2] x86/apic: Do not make an exception for PIC_CASCADE_IR when marking legacy irqs in irq_matrix

Trying to offline/online CPU0 seems to work only once:

 # echo 0 > /sys/devices/system/cpu/cpu0/online
 # echo 1 > /sys/devices/system/cpu/cpu0/online
 # echo 0 > /sys/devices/system/cpu/cpu0/online
 -bash: echo: write error: No space left on device

with the following in dmesg:

 [ ... ] CPU 0 has 4294967295 vectors, 589 available. Cannot disable CPU

Clearly, we went negative with cm->allocated in irq_matrix and think that
there are too many vectors require re-assigning.

The problem turns to be: lapic_assign_system_vectors() called from
native_init_IRQ() makes an exception for PIC_CASCADE_IR and doesn't
mark it in irq_matrix. Later, when x86_vector_alloc_irqs() called
from setup_IO_APIC() does clear_irq_vector() for all legacy entries,
it doesn't make an exception so we go negative.

CPU0 offlining still works for the first time because some other vectors
get assigned and the overall balance remains positive (it's off-by-one, but
the check passes). When we online CPU0 back, no vectors get assigned and
the overall balance remains '-1'.

The simplest solution seems to be to not make an exception for
PIC_CASCADE_IR. Nothing seems to blow up immediately.

Signed-off-by: Vitaly Kuznetsov <vkuznets@...hat.com>
---
 arch/x86/kernel/apic/vector.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/x86/kernel/apic/vector.c b/arch/x86/kernel/apic/vector.c
index 3c9c7492252f..f3aa02ced929 100644
--- a/arch/x86/kernel/apic/vector.c
+++ b/arch/x86/kernel/apic/vector.c
@@ -745,8 +745,7 @@ void __init lapic_assign_system_vectors(void)
 
 	/* Mark the preallocated legacy interrupts */
 	for (i = 0; i < nr_legacy_irqs(); i++) {
-		if (i != PIC_CASCADE_IR)
-			irq_matrix_assign(vector_matrix, ISA_IRQ_VECTOR(i));
+		irq_matrix_assign(vector_matrix, ISA_IRQ_VECTOR(i));
 	}
 }
 
-- 
2.29.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ