Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/kasan: Disable address sanitization in kexec paths

The kexec code paths involve code that necessarily run in real mode, as
CPUs are disabled and control is transferred to the new kernel. Disable
address sanitization for the kexec code and the functions called in real
mode on CPUs being disabled.

[paulus@ozlabs.org: combined a few work-in-progress commits of
Daniel's and wrote the commit message.]

Signed-off-by: Daniel Axtens <dja@axtens.net>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
[mpe: Move pseries_machine_kexec() into kexec.c so setup.c can be instrumented]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/YoTFSQ2TUSEaDdVC@cleo

authored by

Daniel Axtens and committed by
Michael Ellerman
2ab2d579 5352090a

+18 -15
+2
arch/powerpc/kexec/Makefile
··· 13 13 GCOV_PROFILE_core_$(BITS).o := n 14 14 KCOV_INSTRUMENT_core_$(BITS).o := n 15 15 UBSAN_SANITIZE_core_$(BITS).o := n 16 + KASAN_SANITIZE_core.o := n 17 + KASAN_SANITIZE_core_$(BITS) := n
+2
arch/powerpc/platforms/pseries/Makefile
··· 33 33 obj-$(CONFIG_PPC_VAS) += vas.o vas-sysfs.o 34 34 35 35 obj-$(CONFIG_ARCH_HAS_CC_PLATFORM) += cc_platform.o 36 + 37 + KASAN_SANITIZE_kexec.o := n
+8
arch/powerpc/platforms/pseries/kexec.c
··· 61 61 } else 62 62 xics_kexec_teardown_cpu(secondary); 63 63 } 64 + 65 + void pseries_machine_kexec(struct kimage *image) 66 + { 67 + if (firmware_has_feature(FW_FEATURE_SET_MODE)) 68 + pseries_disable_reloc_on_exc(); 69 + 70 + default_machine_kexec(image); 71 + }
+1
arch/powerpc/platforms/pseries/pseries.h
··· 38 38 #endif 39 39 40 40 extern void pseries_kexec_cpu_down(int crash_shutdown, int secondary); 41 + void pseries_machine_kexec(struct kimage *image); 41 42 42 43 extern void pSeries_final_fixup(void); 43 44
+1 -11
arch/powerpc/platforms/pseries/setup.c
··· 421 421 } 422 422 EXPORT_SYMBOL(pseries_disable_reloc_on_exc); 423 423 424 - #ifdef CONFIG_KEXEC_CORE 425 - static void pSeries_machine_kexec(struct kimage *image) 426 - { 427 - if (firmware_has_feature(FW_FEATURE_SET_MODE)) 428 - pseries_disable_reloc_on_exc(); 429 - 430 - default_machine_kexec(image); 431 - } 432 - #endif 433 - 434 424 #ifdef __LITTLE_ENDIAN__ 435 425 void pseries_big_endian_exceptions(void) 436 426 { ··· 1089 1099 .machine_check_exception = pSeries_machine_check_exception, 1090 1100 .machine_check_log_err = pSeries_machine_check_log_err, 1091 1101 #ifdef CONFIG_KEXEC_CORE 1092 - .machine_kexec = pSeries_machine_kexec, 1102 + .machine_kexec = pseries_machine_kexec, 1093 1103 .kexec_cpu_down = pseries_kexec_cpu_down, 1094 1104 #endif 1095 1105 #ifdef CONFIG_MEMORY_HOTPLUG
+2 -2
arch/powerpc/sysdev/xics/xics-common.c
··· 146 146 147 147 #endif /* CONFIG_SMP */ 148 148 149 - void xics_teardown_cpu(void) 149 + noinstr void xics_teardown_cpu(void) 150 150 { 151 151 struct xics_cppr *os_cppr = this_cpu_ptr(&xics_cppr); 152 152 ··· 159 159 icp_ops->teardown_cpu(); 160 160 } 161 161 162 - void xics_kexec_teardown_cpu(int secondary) 162 + noinstr void xics_kexec_teardown_cpu(int secondary) 163 163 { 164 164 xics_teardown_cpu(); 165 165
+2 -2
arch/powerpc/sysdev/xive/common.c
··· 1241 1241 return 0; 1242 1242 } 1243 1243 1244 - static void xive_cleanup_cpu_ipi(unsigned int cpu, struct xive_cpu *xc) 1244 + noinstr static void xive_cleanup_cpu_ipi(unsigned int cpu, struct xive_cpu *xc) 1245 1245 { 1246 1246 unsigned int xive_ipi_irq = xive_ipi_cpu_to_irq(cpu); 1247 1247 ··· 1634 1634 1635 1635 #endif /* CONFIG_SMP */ 1636 1636 1637 - void xive_teardown_cpu(void) 1637 + noinstr void xive_teardown_cpu(void) 1638 1638 { 1639 1639 struct xive_cpu *xc = __this_cpu_read(xive_cpu); 1640 1640 unsigned int cpu = smp_processor_id();