Skip to content

Commit

Permalink
mm/pagewalk.c: prevent positive return value of walk_page_test() from…
Browse files Browse the repository at this point in the history
… being passed to callers

walk_page_test() is purely pagewalk's internal stuff, and its positive
return values are not intended to be passed to the callers of pagewalk.

However, in the current code if the last vma in the do-while loop in
walk_page_range() happens to return a positive value, it leaks outside
walk_page_range().  So the user visible effect is invalid/unexpected
return value (according to the reporter, mbind() causes it.)

This patch fixes it simply by reinitializing the return value after
checked.

Another exposed interface, walk_page_vma(), already returns 0 for such
cases so no problem.

Fixes: fafaa42 ("pagewalk: improve vma handling")
Signed-off-by: Naoya Horiguchi <[email protected]>
Signed-off-by: Kazutomo Yoshii <[email protected]>
Reported-by: Kazutomo Yoshii <[email protected]>
Acked-by: David Rientjes <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Naoya Horiguchi authored and torvalds committed Mar 25, 2015
1 parent 3fe89b3 commit f683739
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion mm/pagewalk.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,15 @@ int walk_page_range(unsigned long start, unsigned long end,
vma = vma->vm_next;

err = walk_page_test(start, next, walk);
if (err > 0)
if (err > 0) {
/*
* positive return values are purely for
* controlling the pagewalk, so should never
* be passed to the callers.
*/
err = 0;
continue;
}
if (err < 0)
break;
}
Expand Down

0 comments on commit f683739

Please sign in to comment.