diff options
author | Bob Liu <lliubbo@gmail.com> | 2011-06-27 19:18:06 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-06-27 21:00:12 -0400 |
commit | 2b4b2482e70eba10dd98653a3a5ac68126565e24 (patch) | |
tree | 81f933ce6291135529cda6581c59c55386d2832e /fs/romfs | |
parent | 8c95aa60d2ae3c4e63705ee0f18e155898b09662 (diff) |
romfs: fix romfs_get_unmapped_area() argument check
romfs_get_unmapped_area() checks argument `len' without considering
PAGE_ALIGN which will cause do_mmap_pgoff() return -EINVAL error after
commit f67d9b1576c ("nommu: add page_align to mmap").
Fix the check by changing it in same way ramfs_nommu_get_unmapped_area()
was changed in ramfs/file-nommu.c.
Signed-off-by: Bob Liu <lliubbo@gmail.com>
Cc: David Howells <dhowells@redhat.com>
Cc: Paul Mundt <lethal@linux-sh.org>
Acked-by: Greg Ungerer <gerg@snapgear.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/romfs')
-rw-r--r-- | 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 f0511e816967..eed99428f104 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, | |||
27 | { | 27 | { |
28 | struct inode *inode = file->f_mapping->host; | 28 | struct inode *inode = file->f_mapping->host; |
29 | struct mtd_info *mtd = inode->i_sb->s_mtd; | 29 | struct mtd_info *mtd = inode->i_sb->s_mtd; |
30 | unsigned long isize, offset; | 30 | unsigned long isize, offset, maxpages, lpages; |
31 | 31 | ||
32 | if (!mtd) | 32 | if (!mtd) |
33 | goto cant_map_directly; | 33 | goto cant_map_directly; |
34 | 34 | ||
35 | /* the mapping mustn't extend beyond the EOF */ | ||
36 | lpages = (len + PAGE_SIZE - 1) >> PAGE_SHIFT; | ||
35 | isize = i_size_read(inode); | 37 | isize = i_size_read(inode); |
36 | offset = pgoff << PAGE_SHIFT; | 38 | offset = pgoff << PAGE_SHIFT; |
37 | if (offset > isize || len > isize || offset > isize - len) | 39 | |
40 | maxpages = (isize + PAGE_SIZE - 1) >> PAGE_SHIFT; | ||
41 | if ((pgoff >= maxpages) || (maxpages - pgoff < lpages)) | ||
38 | return (unsigned long) -EINVAL; | 42 | return (unsigned long) -EINVAL; |
39 | 43 | ||
40 | /* we need to call down to the MTD layer to do the actual mapping */ | 44 | /* we need to call down to the MTD layer to do the actual mapping */ |