Skip to content

Commit 023e1a8

Browse files
Hugh Dickinstorvalds
Hugh Dickins
authored andcommitted
mm/rmap: fix new bug: premature return from page_mlock_one()
In the unlikely race case that page_mlock_one() finds VM_LOCKED has been cleared by the time it got page table lock, page_vma_mapped_walk_done() must be called before returning, either explicitly, or by a final call to page_vma_mapped_walk() - otherwise the page table remains locked. Fixes: cd62734 ("mm/rmap: split try_to_munlock from try_to_unmap") Signed-off-by: Hugh Dickins <[email protected]> Reviewed-by: Alistair Popple <[email protected]> Reviewed-by: Shakeel Butt <[email protected]> Reported-by: kernel test robot <[email protected]> Link: https://lore.kernel.org/lkml/20210711151446.GB4070@xsang-OptiPlex-9020/ Link: https://lore.kernel.org/lkml/[email protected]/ Cc: Andrew Morton <[email protected]> Cc: Jason Gunthorpe <[email protected]> Cc: Ralph Campbell <[email protected]> Cc: Christoph Hellwig <[email protected]> Cc: Yang Shi <[email protected]> Cc: Kirill A. Shutemov <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent d9770fc commit 023e1a8

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

mm/rmap.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1990,14 +1990,13 @@ static bool page_mlock_one(struct page *page, struct vm_area_struct *vma,
19901990
* this function is never called when PageDoubleMap().
19911991
*/
19921992
mlock_vma_page(page);
1993+
/*
1994+
* No need to scan further once the page is marked
1995+
* as mlocked.
1996+
*/
19931997
page_vma_mapped_walk_done(&pvmw);
1998+
return false;
19941999
}
1995-
1996-
/*
1997-
* no need to continue scanning other vma's if the page has
1998-
* been locked.
1999-
*/
2000-
return false;
20012000
}
20022001

20032002
return true;

0 commit comments

Comments
 (0)