diff options
author | Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> | 2015-03-25 18:55:14 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-03-25 19:20:30 -0400 |
commit | f683739539e819e9b821a197d80e52258510837b (patch) | |
tree | 802b4a45c602f22691d90392fbfcafe97934eadf /mm | |
parent | 3fe89b3e2a7bbf3e97657104b9b33a9d81b950b3 (diff) |
mm/pagewalk.c: prevent positive return value of walk_page_test() from 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: fafaa4264eba ("pagewalk: improve vma handling")
Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Signed-off-by: Kazutomo Yoshii <kazutomo.yoshii@gmail.com>
Reported-by: Kazutomo Yoshii <kazutomo.yoshii@gmail.com>
Acked-by: David Rientjes <rientjes@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/pagewalk.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/mm/pagewalk.c b/mm/pagewalk.c index 75c1f2878519..29f2f8b853ae 100644 --- a/mm/pagewalk.c +++ b/mm/pagewalk.c | |||
@@ -265,8 +265,15 @@ int walk_page_range(unsigned long start, unsigned long end, | |||
265 | vma = vma->vm_next; | 265 | vma = vma->vm_next; |
266 | 266 | ||
267 | err = walk_page_test(start, next, walk); | 267 | err = walk_page_test(start, next, walk); |
268 | if (err > 0) | 268 | if (err > 0) { |
269 | /* | ||
270 | * positive return values are purely for | ||
271 | * controlling the pagewalk, so should never | ||
272 | * be passed to the callers. | ||
273 | */ | ||
274 | err = 0; | ||
269 | continue; | 275 | continue; |
276 | } | ||
270 | if (err < 0) | 277 | if (err < 0) |
271 | break; | 278 | break; |
272 | } | 279 | } |