Skip to content

Commit fa7ddee

Browse files
kkamaguigregkh
authored andcommitted
x86/acpi: Prevent out of bound access caused by broken ACPI tables
commit dad5ab0db8deac535d03e3fe3d8f2892173fa6a4 upstream. The bus_irq argument of mp_override_legacy_irq() is used as the index into the isa_irq_to_gsi[] array. The bus_irq argument originates from ACPI_MADT_TYPE_IO_APIC and ACPI_MADT_TYPE_INTERRUPT items in the ACPI tables, but is nowhere sanity checked. That allows broken or malicious ACPI tables to overwrite memory, which might cause malfunction, panic or arbitrary code execution. Add a sanity check and emit a warning when that triggers. [ tglx: Added warning and rewrote changelog ] Signed-off-by: Seunghun Han <kkamagui@gmail.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: security@kernel.org Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net> Signed-off-by: Ingo Molnar <mingo@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 62d131e commit fa7ddee

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

arch/x86/kernel/acpi/boot.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,14 @@ static void __init mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger,
328328
int pin;
329329
struct mpc_intsrc mp_irq;
330330

331+
/*
332+
* Check bus_irq boundary.
333+
*/
334+
if (bus_irq >= NR_IRQS_LEGACY) {
335+
pr_warn("Invalid bus_irq %u for legacy override\n", bus_irq);
336+
return;
337+
}
338+
331339
/*
332340
* Convert 'gsi' to 'ioapic.pin'.
333341
*/

0 commit comments

Comments
 (0)