kernel_samsung_a53x/arch/x86/kernel
Kirill A. Shutemov 6041cc2f42 x86/alternatives: Disable KASAN in apply_alternatives()
commit d35652a5fc9944784f6f50a5c979518ff8dacf61 upstream.

Fei has reported that KASAN triggers during apply_alternatives() on
a 5-level paging machine:

	BUG: KASAN: out-of-bounds in rcu_is_watching()
	Read of size 4 at addr ff110003ee6419a0 by task swapper/0/0
	...
	__asan_load4()
	rcu_is_watching()
	trace_hardirqs_on()
	text_poke_early()
	apply_alternatives()
	...

On machines with 5-level paging, cpu_feature_enabled(X86_FEATURE_LA57)
gets patched. It includes KASAN code, where KASAN_SHADOW_START depends on
__VIRTUAL_MASK_SHIFT, which is defined with cpu_feature_enabled().

KASAN gets confused when apply_alternatives() patches the
KASAN_SHADOW_START users. A test patch that makes KASAN_SHADOW_START
static, by replacing __VIRTUAL_MASK_SHIFT with 56, works around the issue.

Fix it for real by disabling KASAN while the kernel is patching alternatives.

[ mingo: updated the changelog ]

Fixes: 6657fca06e3f ("x86/mm: Allow to boot without LA57 if CONFIG_X86_5LEVEL=y")
Reported-by: Fei Yang <fei.yang@intel.com>
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20231012100424.1456-1-kirill.shutemov@linux.intel.com
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-11-08 11:25:53 +01:00
..
acpi Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
apic Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cpu x86/cpu: Fix AMD erratum #1485 on Zen4-based CPUs 2024-11-08 11:25:49 +01:00
fpu Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
kprobes Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
alternative.c x86/alternatives: Disable KASAN in apply_alternatives() 2024-11-08 11:25:53 +01:00
amd_gart_64.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
amd_nb.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
apb_timer.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
aperture_64.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
apm_32.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
asm-offsets.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
asm-offsets_32.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
asm-offsets_64.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
audit_64.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
bootflag.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cc_platform.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
check.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cpuid.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
crash.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
crash_core_32.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
crash_core_64.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
crash_dump_32.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
crash_dump_64.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
devicetree.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
doublefault_32.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
dumpstack.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
dumpstack_32.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
dumpstack_64.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
e820.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
early-quirks.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
early_printk.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ebda.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
eisa.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
espfix_64.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ftrace.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ftrace_32.S Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ftrace_64.S Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
head32.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
head64.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
head_32.S Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
head_64.S Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
hpet.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
hw_breakpoint.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
i8237.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
i8253.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
i8259.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
idt.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ima_arch.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
io_delay.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ioport.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
irq.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
irq_32.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
irq_64.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
irq_work.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
irqflags.S Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
irqinit.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
itmt.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
jailhouse.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
jump_label.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
kdebugfs.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
kexec-bzimage64.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
kgdb.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ksysfs.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
kvm.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
kvmclock.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ldt.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
machine_kexec_32.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
machine_kexec_64.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Makefile Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mmconf-fam10h_64.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
module.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mpparse.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
msr.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
nmi.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
nmi_selftest.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
paravirt-spinlocks.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
paravirt.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
paravirt_patch.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
pci-dma.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
pci-iommu_table.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
pci-swiotlb.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
pcspeaker.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
perf_regs.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
platform-quirks.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
pmem.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
probe_roms.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
process.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
process.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
process_32.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
process_64.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ptrace.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
pvclock.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
quirks.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
reboot.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
reboot_fixups_32.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
relocate_kernel_32.S Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
relocate_kernel_64.S Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
resource.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
rtc.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
setup.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
setup_percpu.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sev-es-shared.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sev-es.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sev_verify_cbit.S Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
signal.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
signal_compat.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
smp.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
smpboot.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
stacktrace.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
static_call.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
step.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sys_ia32.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sys_x86_64.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sysfb.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sysfb_efi.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sysfb_simplefb.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
tboot.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
time.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
tls.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
tls.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
topology.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
trace_clock.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
tracepoint.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
traps.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
tsc.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
tsc_msr.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
tsc_sync.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
umip.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
unwind_frame.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
unwind_guess.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
unwind_orc.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
uprobes.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
verify_cpu.S Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
vm86_32.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
vmlinux.lds.S Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
vsmp_64.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
x86_init.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00