Skip to content

Commit 53406ed

Browse files
Hugh Dickinstorvalds
authored andcommitted
mm: delete historical BUG from zap_pmd_range()
Delete the old VM_BUG_ON_VMA() from zap_pmd_range(), which asserted that mmap_sem must be held when splitting an "anonymous" vma there. Whether that's still strictly true nowadays is not entirely clear, but the danger of sometimes crashing on the BUG is now fairly clear. Even with the new stricter rules for anonymous vma marking, the condition it checks for can possible trigger. Commit 44960f2 ("staging: ashmem: Fix SIGBUS crash when traversing mmaped ashmem pages") is good, and originally I thought it was safe from that VM_BUG_ON_VMA(), because the /dev/ashmem fd exposed to the user is disconnected from the vm_file in the vma, and madvise(,,MADV_REMOVE) insists on VM_SHARED. But after I read John's earlier mail, drawing attention to the vfs_fallocate() in there: I may be wrong, and I don't know if Android has THP in the config anyway, but it looks to me like an unmap_mapping_range() from ashmem's vfs_fallocate() could hit precisely the VM_BUG_ON_VMA(), once it's vma_is_anonymous(). Signed-off-by: Hugh Dickins <hughd@google.com> Cc: John Stultz <john.stultz@linaro.org> Cc: Kirill Shutemov <kirill.shutemov@linux.intel.com> Cc: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 9a97ebf commit 53406ed

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

mm/memory.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,11 +1417,9 @@ static inline unsigned long zap_pmd_range(struct mmu_gather *tlb,
14171417
do {
14181418
next = pmd_addr_end(addr, end);
14191419
if (is_swap_pmd(*pmd) || pmd_trans_huge(*pmd) || pmd_devmap(*pmd)) {
1420-
if (next - addr != HPAGE_PMD_SIZE) {
1421-
VM_BUG_ON_VMA(vma_is_anonymous(vma) &&
1422-
!rwsem_is_locked(&tlb->mm->mmap_sem), vma);
1420+
if (next - addr != HPAGE_PMD_SIZE)
14231421
__split_huge_pmd(vma, pmd, addr, false, NULL);
1424-
} else if (zap_huge_pmd(tlb, vma, pmd, addr))
1422+
else if (zap_huge_pmd(tlb, vma, pmd, addr))
14251423
goto next;
14261424
/* fall through */
14271425
}

0 commit comments

Comments
 (0)