Skip to content

Commit

Permalink
mm: rmap: call page_check_address() with sync enabled to avoid racy c…
Browse files Browse the repository at this point in the history
…heck

The previous patch addresses the race between split_huge_pmd_address()
and someone changing the pmd.  The fix is only for splitting of normal
thp (i.e.  pmd-mapped thp,) and for splitting of pte-mapped thp there
still is the similar race.

For splitting pte-mapped thp, the pte's conversion is done by
try_to_unmap_one(TTU_MIGRATION).  This function checks
page_check_address() to get the target pte, but it can return NULL under
some race, leading to VM_BUG_ON() in freeze_page().  Fortunately,
page_check_address() already has an argument to decide whether we do a
quick/racy check or not, so let's flip it when called from
freeze_page().

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Naoya Horiguchi <[email protected]>
Cc: Kirill A. Shutemov <[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 Jul 15, 2016
1 parent 33f4751 commit 55bda43
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion mm/rmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1427,7 +1427,8 @@ static int try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
goto out;
}

pte = page_check_address(page, mm, address, &ptl, 0);
pte = page_check_address(page, mm, address, &ptl,
PageTransCompound(page));
if (!pte)
goto out;

Expand Down

0 comments on commit 55bda43

Please sign in to comment.