summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw@amazon.co.uk>2017-04-12 15:25:51 +0300
committerBen Hutchings <ben@decadent.org.uk>2017-08-26 04:14:00 +0300
commit077b04d600f7518251770ef697d24389db8570d7 (patch)
tree9fe76af63a95d1af70d09fb3831d844f9742840e /drivers
parent727867eeddf50c1b94eb9e817e7185837cc1711c (diff)
downloadlinux-077b04d600f7518251770ef697d24389db8570d7.tar.xz
PCI: Fix another sanity check bug in /proc/pci mmap
commit 17caf56731311c9596e7d38a70c88fcb6afa6a1b upstream. Don't match MMIO maps with I/O BARs and vice versa. Signed-off-by: David Woodhouse <dwmw@amazon.co.uk> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/pci/proc.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
index 3db123dd2034..d0319ddae9f4 100644
--- a/drivers/pci/proc.c
+++ b/drivers/pci/proc.c
@@ -249,14 +249,20 @@ static int proc_bus_pci_mmap(struct file *file, struct vm_area_struct *vma)
const struct proc_dir_entry *dp = PDE(inode);
struct pci_dev *dev = dp->data;
struct pci_filp_private *fpriv = file->private_data;
- int i, ret, write_combine;
+ int i, ret, write_combine, res_bit;
if (!capable(CAP_SYS_RAWIO))
return -EPERM;
+ if (fpriv->mmap_state == pci_mmap_io)
+ res_bit = IORESOURCE_IO;
+ else
+ res_bit = IORESOURCE_MEM;
+
/* Make sure the caller is mapping a real resource for this device */
for (i = 0; i < PCI_ROM_RESOURCE; i++) {
- if (pci_mmap_fits(dev, i, vma, PCI_MMAP_PROCFS))
+ if (dev->resource[i].flags & res_bit &&
+ pci_mmap_fits(dev, i, vma, PCI_MMAP_PROCFS))
break;
}