kernel-ark/drivers/pci
Martin Wilck 3b519e4ea6 PCI: fix size checks for mmap() on /proc/bus/pci files
The checks for valid mmaps of PCI resources made through /proc/bus/pci files
that were introduced in 9eff02e204 have several
problems:

1. mmap() calls on /proc/bus/pci files are made with real file offsets > 0,
whereas under /sys/bus/pci/devices, the start of the resource corresponds
to offset 0. This may lead to false negatives in pci_mmap_fits(), which
implicitly assumes the /sys/bus/pci/devices layout.

2. The loop in proc_bus_pci_mmap doesn't skip empty resouces. This leads
to false positives, because pci_mmap_fits() doesn't treat empty resources
correctly (the calculated size is 1 << (8*sizeof(resource_size_t)-PAGE_SHIFT)
in this case!).

3. If a user maps resources with BAR > 0, pci_mmap_fits will emit bogus
WARNINGS for the first resources that don't fit until the correct one is found.

On many controllers the first 2-4 BARs are used, and the others are empty.
In this case, an mmap attempt will first fail on the non-empty BARs
(including the "right" BAR because of 1.) and emit bogus WARNINGS because
of 3., and finally succeed on the first empty BAR because of 2.
This is certainly not the intended behaviour.

This patch addresses all 3 issues.
Updated with an enum type for the additional parameter for pci_mmap_fits().

Cc: stable@kernel.org
Signed-off-by: Martin Wilck <martin.wilck@ts.fujitsu.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
2010-11-11 09:34:32 -08:00
..
hotplug PCI hotplug: ibmphp: Add check to prevent reading beyond mapped area 2010-11-11 09:34:31 -08:00
pcie Merge branch 'linux-next' of git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes/pci-2.6 2010-10-28 11:59:52 -07:00
.gitignore
access.c PCI: output FW warning in pci_read/write_vpd 2010-05-18 15:00:25 -07:00
bus.c Merge branch 'stable/xen-pcifront-0.8.2' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen 2010-10-28 17:11:17 -07:00
dmar.c Merge branch 'x86-iommu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip 2010-10-21 14:23:48 -07:00
hotplug-pci.c
hotplug.c
htirq.c ht: Convert to new irq_chip functions 2010-10-12 16:53:37 +02:00
intel-iommu.c Merge git://git.infradead.org/iommu-2.6 2010-09-27 12:25:10 -07:00
intr_remapping.c x86: Speed up the irq_remapped check in hot pathes 2010-10-12 16:53:42 +02:00
intr_remapping.h
ioapic.c
iov.c PCI: fix pci_resource_alignment prototype 2010-09-09 13:41:25 -07:00
iova.c
irq.c
Kconfig xen-pcifront: Xen PCI frontend driver. 2010-10-18 10:49:37 -04:00
Makefile Merge branch 'stable/xen-pcifront-0.8.2' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen 2010-10-28 17:11:17 -07:00
msi.c msi: Introduce default_[teardown|setup]_msi_irqs with fallback. 2010-10-18 10:49:33 -04:00
msi.h PCI: add PCI_MSIX_TABLE/PBA defines 2010-10-17 20:03:03 -07:00
pci-acpi.c Merge branch 'acpica' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6 2010-08-07 17:08:30 -07:00
pci-driver.c PCI: change device runtime PM settings for probe and remove 2010-07-30 09:29:09 -07:00
pci-label.c PCI: update for owner removal from struct device_attribute 2010-08-04 14:23:55 -07:00
pci-stub.c
pci-sysfs.c PCI: fix size checks for mmap() on /proc/bus/pci files 2010-11-11 09:34:32 -08:00
pci.c PCI: Add support for polling PME state on suspended legacy PCI devices 2010-10-17 20:03:06 -07:00
pci.h PCI: fix size checks for mmap() on /proc/bus/pci files 2010-11-11 09:34:32 -08:00
probe.c PCI: log vendor/device ID always 2010-10-17 20:03:05 -07:00
proc.c PCI: fix size checks for mmap() on /proc/bus/pci files 2010-11-11 09:34:32 -08:00
quirks.c Merge branch 'linux-next' of git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes/pci-2.6 2010-10-28 11:59:52 -07:00
remove.c
rom.c
search.c PCI: use for_each_pci_dev() 2010-07-30 09:47:22 -07:00
setup-bus.c PCI hotplug: make sure child bridges are enabled at hotplug time 2010-07-30 09:29:16 -07:00
setup-irq.c PCI: use for_each_pci_dev() 2010-07-30 09:47:22 -07:00
setup-res.c PCI: fix message typo 2010-10-17 20:03:05 -07:00
slot.c PCI: bus speed strings should be const 2010-08-31 15:28:00 -07:00
syscall.c
vpd.c
xen-pcifront.c xen-pcifront: Xen PCI frontend driver. 2010-10-18 10:49:37 -04:00