From 0dab8736c59c0b6e33afdfe7918fce3c7ea124e8 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Thu, 26 Jun 2014 10:42:46 +1000 Subject: [PATCH] do_shared_fault(): check that mmap_sem is held mmap_sem() is required to protect the vma, which holds ->vm_file, which pins fault_page->mapping. Cc: Andi Kleen Cc: Bob Liu Cc: Dave Hansen Cc: Kirill A. Shutemov Cc: Matthew Wilcox Cc: Mel Gorman Cc: Naoya Horiguchi Cc: Rik van Riel Cc: Sasha Levin Signed-off-by: Andrew Morton --- mm/memory.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/memory.c b/mm/memory.c index e119a8bf7b05..09e2cd0d7fee 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -2970,6 +2970,8 @@ static int do_shared_fault(struct mm_struct *mm, struct vm_area_struct *vma, int dirtied = 0; int ret, tmp; + WARN_ON_ONCE(!rwsem_is_locked(&mm->mmap_sem)); + ret = __do_fault(vma, address, pgoff, flags, &fault_page); if (unlikely(ret & (VM_FAULT_ERROR | VM_FAULT_NOPAGE | VM_FAULT_RETRY))) return ret; -- 2.39.5