mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 19:51:31 -04:00
mm: fix swapin race condition
The pte_same check is reliable only if the swap entry remains pinned (by the page lock on swapcache). We've also to ensure the swapcache isn't removed before we take the lock as try_to_free_swap won't care about the page pin. One of the possible impacts of this patch is that a KSM-shared page can point to the anon_vma of another process, which could exit before the page is freed. This can leave a page with a pointer to a recycled anon_vma object, or worse, a pointer to something that is no longer an anon_vma. [[email protected]: changelog help] Signed-off-by: Andrea Arcangeli <[email protected]> Acked-by: Hugh Dickins <[email protected]> Reviewed-by: Rik van Riel <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
7c5367f205
commit
4969c1192d
3 changed files with 43 additions and 19 deletions
3
mm/ksm.c
3
mm/ksm.c
|
|
@ -1504,8 +1504,6 @@ struct page *ksm_does_need_to_copy(struct page *page,
|
|||
{
|
||||
struct page *new_page;
|
||||
|
||||
unlock_page(page); /* any racers will COW it, not modify it */
|
||||
|
||||
new_page = alloc_page_vma(GFP_HIGHUSER_MOVABLE, vma, address);
|
||||
if (new_page) {
|
||||
copy_user_highpage(new_page, page, address, vma);
|
||||
|
|
@ -1521,7 +1519,6 @@ struct page *ksm_does_need_to_copy(struct page *page,
|
|||
add_page_to_unevictable_list(new_page);
|
||||
}
|
||||
|
||||
page_cache_release(page);
|
||||
return new_page;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue