From: Bob Liu <lliubbo@gmail.com>
To: <akpm@linux-foundation.org>
Cc: <linux-kernel@vger.kernel.org>, <dhowells@redhat.com>,
<gerg@snapgear.com>, <lethal@linux-sh.org>, <gerg@uclinux.org>,
<geert@linux-m68k.org>, Bob Liu <lliubbo@gmail.com>
Subject: [PATCH] romfs: fix romfs_get_unmapped_area() param check
Date: Tue, 14 Jun 2011 13:36:10 +0800 [thread overview]
Message-ID: <1308029770-6176-1-git-send-email-lliubbo@gmail.com> (raw)
romfs_get_unmapped_area() check param len without considering PAGE_ALIGN which
will cause do_mmap_pgoff() return -EINVAL error after commit f67d9b1576c
nommu: add page_align to mmap.
This patch fix the param check by changing it to the same way which function
ramfs_nommu_get_unmapped_area() did in ramfs/file-nommu.c.
Signed-off-by: Bob Liu <lliubbo@gmail.com>
---
fs/romfs/mmap-nommu.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/fs/romfs/mmap-nommu.c b/fs/romfs/mmap-nommu.c
index f0511e8..eed9942 100644
--- a/fs/romfs/mmap-nommu.c
+++ b/fs/romfs/mmap-nommu.c
@@ -27,14 +27,18 @@ static unsigned long romfs_get_unmapped_area(struct file *file,
{
struct inode *inode = file->f_mapping->host;
struct mtd_info *mtd = inode->i_sb->s_mtd;
- unsigned long isize, offset;
+ unsigned long isize, offset, maxpages, lpages;
if (!mtd)
goto cant_map_directly;
+ /* the mapping mustn't extend beyond the EOF */
+ lpages = (len + PAGE_SIZE - 1) >> PAGE_SHIFT;
isize = i_size_read(inode);
offset = pgoff << PAGE_SHIFT;
- if (offset > isize || len > isize || offset > isize - len)
+
+ maxpages = (isize + PAGE_SIZE - 1) >> PAGE_SHIFT;
+ if ((pgoff >= maxpages) || (maxpages - pgoff < lpages))
return (unsigned long) -EINVAL;
/* we need to call down to the MTD layer to do the actual mapping */
--
1.6.3.3
reply other threads:[~2011-06-14 5:26 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1308029770-6176-1-git-send-email-lliubbo@gmail.com \
--to=lliubbo@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=dhowells@redhat.com \
--cc=geert@linux-m68k.org \
--cc=gerg@snapgear.com \
--cc=gerg@uclinux.org \
--cc=lethal@linux-sh.org \
--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®