projects/linux·commit 88e7df0b

PCI: fix range check on mmapped sysfs resource files

88e7df0b · Ed Swierk <[email protected]> · 2008-11-03 14:41:16 -08:00

pci_mmap_fits() returns the wrong answer if the sysfs resource file size
is not a multiple of the page size.  vm_end and vm_start are already
page-aligned, so size - start < nr, causing mmap() to return EINVAL.

Signed-off-by: Ed Swierk <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Jesse Barnes <[email protected]>
Commit
88e7df0b7ee717f9db3333fb1248827bbdb2d4d3
Parents
f5dafca5

Changes

1 files changed · +1 −1

FileStatusAddDelContent
drivers/pci/pci-sysfs.cmodified+1−1View file

drivers/pci/pci-sysfs.c

View file
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 110022d..5d72866 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -575,7 +575,7 @@ static int pci_mmap_fits(struct pci_dev *pdev, int resno, struct vm_area_struct
nr = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
start = vma->vm_pgoff;
- size = pci_resource_len(pdev, resno) >> PAGE_SHIFT;
+ size = ((pci_resource_len(pdev, resno) - 1) >> PAGE_SHIFT) + 1;
if (start < size && size - start >= nr)
return 1;
WARN(1, "process \"%s\" tried to map 0x%08lx-0x%08lx on %s BAR %d (size 0x%08lx)\n",