aboutsummaryrefslogtreecommitdiffstats
path: root/mm/mempolicy.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/mempolicy.c')
-rw-r--r--mm/mempolicy.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index 8b57173c1dd5..9c51f9f58cac 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -636,7 +636,6 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
636 struct vm_area_struct *prev; 636 struct vm_area_struct *prev;
637 struct vm_area_struct *vma; 637 struct vm_area_struct *vma;
638 int err = 0; 638 int err = 0;
639 pgoff_t pgoff;
640 unsigned long vmstart; 639 unsigned long vmstart;
641 unsigned long vmend; 640 unsigned long vmend;
642 641
@@ -649,9 +648,9 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
649 vmstart = max(start, vma->vm_start); 648 vmstart = max(start, vma->vm_start);
650 vmend = min(end, vma->vm_end); 649 vmend = min(end, vma->vm_end);
651 650
652 pgoff = vma->vm_pgoff + ((start - vma->vm_start) >> PAGE_SHIFT);
653 prev = vma_merge(mm, prev, vmstart, vmend, vma->vm_flags, 651 prev = vma_merge(mm, prev, vmstart, vmend, vma->vm_flags,
654 vma->anon_vma, vma->vm_file, pgoff, new_pol); 652 vma->anon_vma, vma->vm_file, vma->vm_pgoff,
653 new_pol);
655 if (prev) { 654 if (prev) {
656 vma = prev; 655 vma = prev;
657 next = vma->vm_next; 656 next = vma->vm_next;
@@ -1412,7 +1411,9 @@ asmlinkage long compat_sys_get_mempolicy(int __user *policy,
1412 err = sys_get_mempolicy(policy, nm, nr_bits+1, addr, flags); 1411 err = sys_get_mempolicy(policy, nm, nr_bits+1, addr, flags);
1413 1412
1414 if (!err && nmask) { 1413 if (!err && nmask) {
1415 err = copy_from_user(bm, nm, alloc_size); 1414 unsigned long copy_size;
1415 copy_size = min_t(unsigned long, sizeof(bm), alloc_size);
1416 err = copy_from_user(bm, nm, copy_size);
1416 /* ensure entire bitmap is zeroed */ 1417 /* ensure entire bitmap is zeroed */
1417 err |= clear_user(nmask, ALIGN(maxnode-1, 8) / 8); 1418 err |= clear_user(nmask, ALIGN(maxnode-1, 8) / 8);
1418 err |= compat_put_bitmap(nmask, bm, nr_bits); 1419 err |= compat_put_bitmap(nmask, bm, nr_bits);