From: Ed Swierk <eswierk@aristanetworks.com>
To: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Fix range check on mmaped sysfs resource files
Date: Tue, 28 Oct 2008 22:36:35 -0700 [thread overview]
Message-ID: <1225258595.3865.1.camel@eswierk-laptop.arastra.com> (raw)
In-Reply-To: <9ae48b020810282224x31706492mdbaae102909ba63b@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 403 bytes --]
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.
[-- Attachment #2: linux-2.6.27-pci-sysfs-mmap-bug.patch --]
[-- Type: text/x-patch, Size: 607 bytes --]
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",
prev parent reply other threads:[~2008-10-29 5:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-29 5:24 Ed Swierk
2008-10-29 5:36 ` Ed Swierk [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1225258595.3865.1.camel@eswierk-laptop.arastra.com \
--to=eswierk@aristanetworks.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®