]>
Commit | Line | Data |
---|---|---|
13dcf987 GKH |
1 | From 17caf56731311c9596e7d38a70c88fcb6afa6a1b Mon Sep 17 00:00:00 2001 |
2 | From: David Woodhouse <dwmw@amazon.co.uk> | |
3 | Date: Wed, 12 Apr 2017 13:25:51 +0100 | |
4 | Subject: PCI: Fix another sanity check bug in /proc/pci mmap | |
5 | ||
6 | From: David Woodhouse <dwmw@amazon.co.uk> | |
7 | ||
8 | commit 17caf56731311c9596e7d38a70c88fcb6afa6a1b upstream. | |
9 | ||
10 | Don't match MMIO maps with I/O BARs and vice versa. | |
11 | ||
12 | Signed-off-by: David Woodhouse <dwmw@amazon.co.uk> | |
13 | Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> | |
14 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
15 | ||
16 | --- | |
17 | drivers/pci/proc.c | 10 ++++++++-- | |
18 | 1 file changed, 8 insertions(+), 2 deletions(-) | |
19 | ||
20 | --- a/drivers/pci/proc.c | |
21 | +++ b/drivers/pci/proc.c | |
22 | @@ -231,14 +231,20 @@ static int proc_bus_pci_mmap(struct file | |
23 | { | |
24 | struct pci_dev *dev = PDE_DATA(file_inode(file)); | |
25 | struct pci_filp_private *fpriv = file->private_data; | |
26 | - int i, ret, write_combine; | |
27 | + int i, ret, write_combine, res_bit; | |
28 | ||
29 | if (!capable(CAP_SYS_RAWIO)) | |
30 | return -EPERM; | |
31 | ||
32 | + if (fpriv->mmap_state == pci_mmap_io) | |
33 | + res_bit = IORESOURCE_IO; | |
34 | + else | |
35 | + res_bit = IORESOURCE_MEM; | |
36 | + | |
37 | /* Make sure the caller is mapping a real resource for this device */ | |
38 | for (i = 0; i < PCI_ROM_RESOURCE; i++) { | |
39 | - if (pci_mmap_fits(dev, i, vma, PCI_MMAP_PROCFS)) | |
40 | + if (dev->resource[i].flags & res_bit && | |
41 | + pci_mmap_fits(dev, i, vma, PCI_MMAP_PROCFS)) | |
42 | break; | |
43 | } | |
44 |