Please sign in to comment.
mm: try_to_unmap_cluster() should lock_page() before mlocking
A BUG_ON(!PageLocked) was triggered in mlock_vma_page() by Sasha Levin fuzzing with trinity. The call site try_to_unmap_cluster() does not lock the pages other than its check_page parameter (which is already locked). The BUG_ON in mlock_vma_page() is not documented and its purpose is somewhat unclear, but apparently it serializes against page migration, which could otherwise fail to transfer the PG_mlocked flag. This would not be fatal, as the page would be eventually encountered again, but NR_MLOCK accounting would become distorted nevertheless. This patch adds a comment to the BUG_ON in mlock_vma_page() and munlock_vma_page() to that effect. The call site try_to_unmap_cluster() is fixed so that for page != check_page, trylock_page() is attempted (to avoid possible deadlocks as we already have check_page locked) and mlock_vma_page() is performed only upon success. If the page lock cannot be obtained, the page is left without PG_mlocked, which is again not a problem in the whole unevictable memory design. Signed-off-by: Vlastimil Babka <firstname.lastname@example.org> Signed-off-by: Bob Liu <email@example.com> Reported-by: Sasha Levin <firstname.lastname@example.org> Cc: Wanpeng Li <email@example.com> Cc: Michel Lespinasse <firstname.lastname@example.org> Cc: KOSAKI Motohiro <email@example.com> Acked-by: Rik van Riel <firstname.lastname@example.org> Cc: David Rientjes <email@example.com> Cc: Mel Gorman <firstname.lastname@example.org> Cc: Hugh Dickins <email@example.com> Cc: Joonsoo Kim <firstname.lastname@example.org> Cc: <email@example.com> Signed-off-by: Andrew Morton <firstname.lastname@example.org> Signed-off-by: Linus Torvalds <email@example.com>
- Loading branch information...