Skip to content

Commit

Permalink
HWPOISON: Use get_user_page_fast in hwpoison madvise
Browse files Browse the repository at this point in the history
The previous version didn't take the mmap_sem before calling gup(),
which is racy.

Use get_user_pages_fast() instead which doesn't need any locks.
This is also faster of course, but then it doesn't really matter
because this is just a testing path.

Based on report from Nick Piggin.
Cc: [email protected]

Signed-off-by: Andi Kleen <[email protected]>
  • Loading branch information
Andi Kleen authored and Andi Kleen committed Dec 16, 2009
1 parent 1bfe5fe commit d15f107
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions mm/madvise.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,7 @@ static int madvise_hwpoison(unsigned long start, unsigned long end)
return -EPERM;
for (; start < end; start += PAGE_SIZE) {
struct page *p;
int ret = get_user_pages(current, current->mm, start, 1,
0, 0, &p, NULL);
int ret = get_user_pages_fast(start, 1, 0, &p);
if (ret != 1)
return ret;
printk(KERN_INFO "Injecting memory failure for page %lx at %lx\n",
Expand Down

0 comments on commit d15f107

Please sign in to comment.