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/hugetlb.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/hugetlb.c')
-rw-r--r-- | mm/hugetlb.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/mm/hugetlb.c b/mm/hugetlb.c index e14a8c79a1eb..cdb64e4d238a 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c | |||
@@ -2920,14 +2920,14 @@ follow_huge_pud(struct mm_struct *mm, unsigned long address, | |||
2920 | return NULL; | 2920 | return NULL; |
2921 | } | 2921 | } |
2922 | 2922 | ||
2923 | int follow_hugetlb_page(struct mm_struct *mm, struct vm_area_struct *vma, | 2923 | long follow_hugetlb_page(struct mm_struct *mm, struct vm_area_struct *vma, |
2924 | struct page **pages, struct vm_area_struct **vmas, | 2924 | struct page **pages, struct vm_area_struct **vmas, |
2925 | unsigned long *position, int *length, int i, | 2925 | unsigned long *position, unsigned long *nr_pages, |
2926 | unsigned int flags) | 2926 | long i, unsigned int flags) |
2927 | { | 2927 | { |
2928 | unsigned long pfn_offset; | 2928 | unsigned long pfn_offset; |
2929 | unsigned long vaddr = *position; | 2929 | unsigned long vaddr = *position; |
2930 | int remainder = *length; | 2930 | unsigned long remainder = *nr_pages; |
2931 | struct hstate *h = hstate_vma(vma); | 2931 | struct hstate *h = hstate_vma(vma); |
2932 | 2932 | ||
2933 | spin_lock(&mm->page_table_lock); | 2933 | spin_lock(&mm->page_table_lock); |
@@ -2997,7 +2997,7 @@ same_page: | |||
2997 | } | 2997 | } |
2998 | } | 2998 | } |
2999 | spin_unlock(&mm->page_table_lock); | 2999 | spin_unlock(&mm->page_table_lock); |
3000 | *length = remainder; | 3000 | *nr_pages = remainder; |
3001 | *position = vaddr; | 3001 | *position = vaddr; |
3002 | 3002 | ||
3003 | return i ? i : -EFAULT; | 3003 | return i ? i : -EFAULT; |