Skip to content
Snippets Groups Projects
Commit 6a4157a8 authored by Kalesh Singh's avatar Kalesh Singh
Browse files

ANDROID: SPF: Fix swap faults racing with fast-mremap


pte_unmap_same() and pte_offset_map_lock() in do_swap_page()
do not check that the original faulting pmd_t is still the
same before attempting to take the ptl lock for the page table,
nor do they check the mm_struct’s sequence number.

This is problematic if a concurrent fast-mremap happens where
the pmd_t entry has been moved as now the vmf->pmd is pointing
to the wrong page table.

This incorrect page table may not be allocated which will
cause the kernel to panic when attempting to take the ptl
lock on it.

Reinstate the vma refcount trylock since this will prevent a
concurrent mremap on the VMA on which the speculative fault
is happening.

Note fast-mremap still needs to take the page table ptl lock
(pte level) to avoid SPF races due to VMA splitting.

Bug: 398054290
Bug: 400153677
Change-Id: I447f6f1b57bf1e7dd677e3aec47721702c6e6b88
Signed-off-by: default avatarKalesh Singh <kaleshsingh@google.com>
(cherry picked from commit 5a07ad10)
parent 17bea26c
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment