x86/PCI: Prevent mmconfig memory corruption
commit8a2b4a7256502aa84485eca49b74d64eb4d7ba16
authorThomas Gleixner <tglx@linutronix.de>
Thu, 25 Feb 2010 15:42:11 +0000 (25 16:42 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 15 Mar 2010 16:06:00 +0000 (15 09:06 -0700)
tree7c03d7144f4e865183d65e9698dc75dcd607b257
parent4d57ebd581a5dc9e1fdb6b59c34ddec72013f5b8
x86/PCI: Prevent mmconfig memory corruption

commit bb8d41330ce27edb91adb6922d3f8e1a8923f727 upstream.

commit ff097ddd4 (x86/PCI: MMCONFIG: manage pci_mmcfg_region as a
list, not a table) introduced a nasty memory corruption when
pci_mmcfg_list is empty.

pci_mmcfg_check_end_bus_number() dereferences pci_mmcfg_list.prev even
when the list is empty. The following write hits some variable near to
pci_mmcfg_list.

Further down a similar problem exists, where cfg->list.next is
dereferenced unconditionally and a comparison with some variable near
to pci_mmcfg_list happens.

Add a check for the last element into the for_each_entry() loop and
remove all the other crappy logic which is just a leftover of the old
array based code which was replaced by the list conversion.

Reported-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Bjorn Helgaas <bjorn.helgaas@hp.com>
Cc: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
arch/x86/pci/mmconfig-shared.c