lkml.org 
[lkml]   [2008]   [Oct]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
SubjectRe: [PATCH] Fix range check on mmaped sysfs resource files
From
Date
On Tue, 2008-10-28 at 22:24 -0700, Ed Swierk wrote:
> pci_mmap_fits() in 2.6.27.4 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 <eswierk@aristanetworks.com>

...and here is the patch in a hopefully more readable form.

Index: linux-2.6.27.4/drivers/pci/pci-sysfs.c
===================================================================
--- linux-2.6.27.4.orig/drivers/pci/pci-sysfs.c
+++ linux-2.6.27.4/drivers/pci/pci-sysfs.c
@@ -492,7 +492,7 @@ static int pci_mmap_fits(struct pci_dev

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",
\
 
 \ /
  Last update: 2008-10-29 06:39    [W:0.024 / U:3.072 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site