acrn-kernel/arch/riscv/mm
Steven Price 8782fb61cc mm: pagewalk: Fix race between unmap and page walker
The mmap lock protects the page walker from changes to the page tables
during the walk.  However a read lock is insufficient to protect those
areas which don't have a VMA as munmap() detaches the VMAs before
downgrading to a read lock and actually tearing down PTEs/page tables.

For users of walk_page_range() the solution is to simply call pte_hole()
immediately without checking the actual page tables when a VMA is not
present. We now never call __walk_page_range() without a valid vma.

For walk_page_range_novma() the locking requirements are tightened to
require the mmap write lock to be taken, and then walking the pgd
directly with 'no_vma' set.

This in turn means that all page walkers either have a valid vma, or
it's that special 'novma' case for page table debugging.  As a result,
all the odd '(!walk->vma && !walk->no_vma)' tests can be removed.

Fixes: dd2283f260 ("mm: mmap: zap pages with read mmap_sem in munmap")
Reported-by: Jann Horn <jannh@google.com>
Signed-off-by: Steven Price <steven.price@arm.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Cc: Konstantin Khlebnikov <koct9i@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2022-09-03 10:13:13 -07:00
..
Makefile riscv: Add support for non-coherent devices using zicbom extension 2022-07-28 15:30:51 -07:00
cacheflush.c RISC-V: Do not use cpumask data structure for hartid bitmap 2022-01-20 09:27:22 -08:00
context.c riscv: Implement sv48 support 2022-01-19 17:54:09 -08:00
dma-noncoherent.c riscv: implement Zicbom-based CMO instructions + the t-head variant 2022-08-10 20:49:32 -07:00
extable.c riscv: extable: fix err reg writing in dedicated uaccess handler 2022-02-08 17:02:47 -08:00
fault.c mm: avoid unnecessary page fault retires on shared memory types 2022-06-16 19:48:27 -07:00
hugetlbpage.c hugetlbfs: remove hugetlb_add_hstate() warning for existing hstate 2020-06-03 20:09:46 -07:00
init.c RISC-V: fixups to work with crash tool 2022-08-11 09:04:01 -07:00
kasan_init.c RISC-V Patches for the 5.18 Merge Window, Part 1 2022-03-25 10:11:38 -07:00
pageattr.c mm: pagewalk: Fix race between unmap and page walker 2022-09-03 10:13:13 -07:00
physaddr.c riscv: Fix DEBUG_VIRTUAL false warnings 2022-03-03 15:32:04 -08:00
ptdump.c riscv: Fix PTDUMP output now BPF region moved back to module region 2021-07-06 15:21:27 -07:00
tlbflush.c RISC-V: Do not use cpumask data structure for hartid bitmap 2022-01-20 09:27:22 -08:00