From: Gleb Natapov Date: Tue, 26 Oct 2010 21:22:07 +0000 (-0700) Subject: mm: fix error reporting in move_pages() syscall X-Git-Tag: v2.6.37-rc1~105^2~106 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=70384dc6dcc6aa76762200262820bdb8b724ecd5;p=profile%2Fivi%2Fkernel-adaptation-intel-automotive.git mm: fix error reporting in move_pages() syscall The vma returned by find_vma does not necessarily include the target address. If this happens the code tries to follow a page outside of any vma and returns ENOENT instead of EFAULT. Signed-off-by: Gleb Natapov Acked-by: Christoph Lameter Cc: Minchan Kim Cc: KAMEZAWA Hiroyuki Cc: Mel Gorman Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/migrate.c b/mm/migrate.c index 35e4541..fe5a3c6 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1037,7 +1037,7 @@ static int do_move_page_to_node_array(struct mm_struct *mm, err = -EFAULT; vma = find_vma(mm, pp->addr); - if (!vma || !vma_migratable(vma)) + if (!vma || pp->addr < vma->vm_start || !vma_migratable(vma)) goto set_status; page = follow_page(vma, pp->addr, FOLL_GET); @@ -1204,7 +1204,7 @@ static void do_pages_stat_array(struct mm_struct *mm, unsigned long nr_pages, int err = -EFAULT; vma = find_vma(mm, addr); - if (!vma) + if (!vma || addr < vma->vm_start) goto set_status; page = follow_page(vma, addr, 0);