提交 70384dc6 编写于 作者: G Gleb Natapov 提交者: Linus Torvalds

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: NGleb Natapov <gleb@redhat.com>
Acked-by: NChristoph Lameter <cl@linux-foundation.org>
Cc: Minchan Kim <minchan.kim@gmail.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Mel Gorman <mel@csn.ul.ie>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 66d7dd51
...@@ -1037,7 +1037,7 @@ static int do_move_page_to_node_array(struct mm_struct *mm, ...@@ -1037,7 +1037,7 @@ static int do_move_page_to_node_array(struct mm_struct *mm,
err = -EFAULT; err = -EFAULT;
vma = find_vma(mm, pp->addr); vma = find_vma(mm, pp->addr);
if (!vma || !vma_migratable(vma)) if (!vma || pp->addr < vma->vm_start || !vma_migratable(vma))
goto set_status; goto set_status;
page = follow_page(vma, pp->addr, FOLL_GET); 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, ...@@ -1204,7 +1204,7 @@ static void do_pages_stat_array(struct mm_struct *mm, unsigned long nr_pages,
int err = -EFAULT; int err = -EFAULT;
vma = find_vma(mm, addr); vma = find_vma(mm, addr);
if (!vma) if (!vma || addr < vma->vm_start)
goto set_status; goto set_status;
page = follow_page(vma, addr, 0); page = follow_page(vma, addr, 0);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册