diff options
author | Michel Lespinasse <walken@google.com> | 2013-02-22 19:35:55 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-23 20:50:22 -0500 |
commit | 28a35716d317980ae9bc2ff2f84c33a3cda9e884 (patch) | |
tree | a69307192d34334c6869cfe33b6fea4e358de718 /mm/mlock.c | |
parent | e0fb58152955142f48ed31c8c0541b53e094da6b (diff) |
mm: use long type for page counts in mm_populate() and get_user_pages()
Use long type for page counts in mm_populate() so as to avoid integer
overflow when running the following test code:
int main(void) {
void *p = mmap(NULL, 0x100000000000, PROT_READ,
MAP_PRIVATE | MAP_ANON, -1, 0);
printf("p: %p\n", p);
mlockall(MCL_CURRENT);
printf("done\n");
return 0;
}
Signed-off-by: Michel Lespinasse <walken@google.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Hugh Dickins <hughd@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/mlock.c')
-rw-r--r-- | mm/mlock.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/mm/mlock.c b/mm/mlock.c index 38db3b094105..e6638f565d42 100644 --- a/mm/mlock.c +++ b/mm/mlock.c | |||
@@ -160,7 +160,7 @@ long __mlock_vma_pages_range(struct vm_area_struct *vma, | |||
160 | { | 160 | { |
161 | struct mm_struct *mm = vma->vm_mm; | 161 | struct mm_struct *mm = vma->vm_mm; |
162 | unsigned long addr = start; | 162 | unsigned long addr = start; |
163 | int nr_pages = (end - start) / PAGE_SIZE; | 163 | unsigned long nr_pages = (end - start) / PAGE_SIZE; |
164 | int gup_flags; | 164 | int gup_flags; |
165 | 165 | ||
166 | VM_BUG_ON(start & ~PAGE_MASK); | 166 | VM_BUG_ON(start & ~PAGE_MASK); |
@@ -382,7 +382,7 @@ int __mm_populate(unsigned long start, unsigned long len, int ignore_errors) | |||
382 | unsigned long end, nstart, nend; | 382 | unsigned long end, nstart, nend; |
383 | struct vm_area_struct *vma = NULL; | 383 | struct vm_area_struct *vma = NULL; |
384 | int locked = 0; | 384 | int locked = 0; |
385 | int ret = 0; | 385 | long ret = 0; |
386 | 386 | ||
387 | VM_BUG_ON(start & ~PAGE_MASK); | 387 | VM_BUG_ON(start & ~PAGE_MASK); |
388 | VM_BUG_ON(len != PAGE_ALIGN(len)); | 388 | VM_BUG_ON(len != PAGE_ALIGN(len)); |