linux-stable/arch
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
..
alpha
arc signal: Replace force_sigsegv(SIGSEGV) with force_fatal_sig(SIGSEGV) 2021-11-25 09:49:06 +01:00
arm ARM: dts: exynos: add missing HDMI supplies on SMDK5420 2022-04-08 14:23:00 +02:00
arm64 arm64/mm: avoid fixmap race condition when create pud mapping 2022-04-08 14:23:06 +02:00
csky uaccess: fix integer overflow on access_ok() 2022-03-28 09:58:45 +02:00
h8300
hexagon uaccess: fix integer overflow on access_ok() 2022-03-28 09:58:45 +02:00
ia64 PCI/sysfs: Find shadow ROM before static attribute initialization 2022-02-01 17:27:05 +01:00
m68k m68k: fix access_ok for coldfire 2022-03-28 09:58:46 +02:00
microblaze uaccess: fix integer overflow on access_ok() 2022-03-28 09:58:45 +02:00
mips DEC: Limit PMAX memory probing to R3k systems 2022-04-08 14:23:02 +02:00
nds32 nds32: fix access_ok() checks in get/put_user 2022-03-28 09:58:46 +02:00
nios2
openrisc openrisc: Add clone3 ABI wrapper 2022-01-27 11:04:10 +01:00
parisc parisc/unaligned: Fix ldw() and stw() unalignment handlers 2022-03-02 11:47:49 +01:00
powerpc powerpc/kvm: Fix kvm_use_magic_page 2022-04-08 14:22:57 +02:00
riscv riscv: Increase stack size under KASAN 2022-04-08 14:22:55 +02:00
s390 s390/extable: fix exception table sorting 2022-03-08 19:12:48 +01:00
sh Documentation, arch: Remove leftovers from CIFS_WEAK_PW_HASH 2022-01-27 11:05:21 +01:00
sparc signal: Replace force_fatal_sig with force_exit_sig when in doubt 2021-11-25 09:49:07 +01:00
um block: drop unused includes in <linux/genhd.h> 2022-03-16 14:23:46 +01:00
x86 ACPI / x86: Work around broken XSDT on Advantech DAC-BJ01 board 2022-03-28 09:58:44 +02:00
xtensa xtensa: fix xtensa_wsr always writing 0 2022-04-08 14:23:03 +02:00
.gitignore
Kconfig stack: Constrain and fix stack offset randomization with Clang builds 2022-04-08 14:23:06 +02:00