linux/arch/arm64
Will Deacon 36639013b3 arm64: mm: Fix lockless walks with static and dynamic page-table folding
Lina reports random oopsen originating from the fast GUP code when
16K pages are used with 4-level page-tables, the fourth level being
folded at runtime due to lack of LPA2.

In this configuration, the generic implementation of
p4d_offset_lockless() will return a 'p4d_t *' corresponding to the
'pgd_t' allocated on the stack of the caller, gup_fast_pgd_range().
This is normally fine, but when the fourth level of page-table is folded
at runtime, pud_offset_lockless() will offset from the address of the
'p4d_t' to calculate the address of the PUD in the same page-table page.
This results in a stray stack read when the 'p4d_t' has been allocated
on the stack and can send the walker into the weeds.

Fix the problem by providing our own definition of p4d_offset_lockless()
when CONFIG_PGTABLE_LEVELS <= 4 which returns the real page-table
pointer rather than the address of the local stack variable.

Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/50360968-13fb-4e6f-8f52-1725b3177215@asahilina.net
Fixes: 0dd4f60a2c ("arm64: mm: Add support for folding PUDs at runtime")
Reported-by: Asahi Lina <lina@asahilina.net>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Link: https://lore.kernel.org/r/20240725090345.28461-1-will@kernel.org
Signed-off-by: Will Deacon <will@kernel.org>
2024-07-25 13:20:55 +01:00
..
boot TTY/Serial changes for 6.10-rc1 2024-05-22 11:53:02 -07:00
configs USB / Thunderbolt changes for 6.10-rc1 2024-05-22 11:40:09 -07:00
crypto crypto: arm64/aes-ce - Simplify round key load sequence 2024-04-26 17:26:09 +08:00
hyperv x86/hyperv: Use Hyper-V entropy to seed guest random number generator 2024-03-18 22:01:52 +00:00
include arm64: mm: Fix lockless walks with static and dynamic page-table folding 2024-07-25 13:20:55 +01:00
kernel arm64/vdso: Remove --hash-style=sysv 2024-07-23 15:28:23 +01:00
kvm Merge branches 'for-next/cpufeature', 'for-next/misc', 'for-next/kselftest', 'for-next/mte', 'for-next/errata', 'for-next/acpi', 'for-next/gic-v3-pmr' and 'for-next/doc', remote-tracking branch 'arm64/for-next/perf' into for-next/core 2024-07-11 19:09:35 +01:00
lib arm64: crypto: use CC_FLAGS_FPU for NEON CFLAGS 2024-05-19 14:36:18 -07:00
mm mm: arm64: fix the out-of-bounds issue in contpte_clear_young_dirty_ptes 2024-06-05 19:19:24 -07:00
net Modules changes for v6.10-rc1 2024-05-15 14:05:08 -07:00
tools arm64/sysreg: Correct the values for GICv4.1 2024-07-23 15:29:20 +01:00
xen
Kbuild
Kconfig arm64/Kconfig: Remove redundant 'if HAVE_FUNCTION_GRAPH_TRACER' 2024-07-23 15:24:02 +01:00
Kconfig.debug
Kconfig.platforms Updates for the interrupt subsystem: 2024-05-14 09:47:14 -07:00
Makefile arm64: implement ARCH_HAS_KERNEL_FPU_SUPPORT 2024-05-19 14:36:18 -07:00