WSL2-Linux-Kernel/arch/arm64/mm
Jianyong Wu c17eb1586c arm64/mm: avoid fixmap race condition when create pud mapping
[ Upstream commit ee017ee353 ]

The 'fixmap' is a global resource and is used recursively by
create pud mapping(), leading to a potential race condition in the
presence of a concurrent call to alloc_init_pud():

kernel_init thread                          virtio-mem workqueue thread
==================                          ===========================

  alloc_init_pud(...)                       alloc_init_pud(...)
  pudp = pud_set_fixmap_offset(...)         pudp = pud_set_fixmap_offset(...)
  READ_ONCE(*pudp)
  pud_clear_fixmap(...)
                                            READ_ONCE(*pudp) // CRASH!

As kernel may sleep during creating pud mapping, introduce a mutex lock to
serialise use of the fixmap entries by alloc_init_pud(). However, there is
no need for locking in early boot stage and it doesn't work well with
KASLR enabled when early boot. So, enable lock when system_state doesn't
equal to "SYSTEM_BOOTING".

Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Fixes: f471044545 ("arm64: mm: use fixmap when creating page tables")
Link: https://lore.kernel.org/r/20220201114400.56885-1-jianyong.wu@arm.com
Signed-off-by: Will Deacon <will@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-04-08 14:23:06 +02:00
..
Makefile RISC-V Patches for the 5.12 Merge Window 2021-02-26 10:28:35 -08:00
cache.S arm64: Rename arm64-internal cache maintenance functions 2021-05-25 19:27:49 +01:00
context.c arm64: mm: Use better bitmap_zalloc() 2021-06-01 18:52:05 +01:00
copypage.c arm64: mte: reset the page tag in page->flags 2020-12-22 12:55:07 -08:00
dma-mapping.c iommu/dma: Pass address limit rather than size to iommu_setup_dma_ops() 2021-06-25 15:02:43 +02:00
extable.c arm64/bpf: Remove 128MB limit for BPF JIT programs 2022-01-29 10:58:25 +01:00
fault.c arm64: kasan: mte: remove redundant mte_report_once logic 2021-08-02 18:15:28 +01:00
flush.c arm64: Rename arm64-internal cache maintenance functions 2021-05-25 19:27:49 +01:00
hugetlbpage.c arm64/hugetlb: fix CMA gigantic page order for non-4K PAGE_SIZE 2021-10-11 18:45:19 +01:00
init.c arm64: Do not defer reserve_crashkernel() for platforms with no DMA memory zones 2022-04-08 14:22:57 +02:00
ioremap.c arm64: decouple check whether pfn is in linear map from pfn_valid() 2021-06-30 20:47:29 -07:00
kasan_init.c Merge branches 'for-next/misc', 'for-next/kselftest', 'for-next/xntable', 'for-next/vdso', 'for-next/fiq', 'for-next/epan', 'for-next/kasan-vmalloc', 'for-next/fgt-boot-init', 'for-next/vhe-only' and 'for-next/neon-softirqs-disabled', remote-tracking branch 'arm64/for-next/perf' into for-next/core 2021-04-15 14:00:38 +01:00
mmap.c arm64: Ensure execute-only permissions are not allowed without EPAN 2022-03-16 14:23:43 +01:00
mmu.c arm64/mm: avoid fixmap race condition when create pud mapping 2022-04-08 14:23:06 +02:00
mteswap.c arm64: mte: reset the page tag in page->flags 2020-12-22 12:55:07 -08:00
pageattr.c set_memory: allow querying whether set_direct_map_*() is actually enabled 2021-07-08 11:48:20 -07:00
pgd.c mm: consolidate pgtable_cache_init() and pgd_cache_init() 2019-09-24 15:54:09 -07:00
physaddr.c arm64: Do not pass tagged addresses to __is_lm_address() 2021-02-02 17:44:47 +00:00
proc.S arm64: kasan: mte: use a constant kernel GCR_EL1 value 2021-08-02 18:14:21 +01:00
ptdump.c arm64/bpf: Remove 128MB limit for BPF JIT programs 2022-01-29 10:58:25 +01:00
ptdump_debugfs.c arm64: Add __init section marker to some functions 2021-04-08 17:45:10 +01:00
trans_pgd.c arm64: trans_pgd: hibernate: idmap the single page that holds the copy page routines 2021-01-27 15:41:12 +00:00