summaryrefslogtreecommitdiff
path: root/arch/x86/kernel/head32.c
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2023-10-02 13:59:36 +0200
committerBorislav Petkov (AMD) <bp@alien8.de>2023-10-18 11:11:43 +0200
commit242db7589460ca94e28c51ffbddd621756f97e11 (patch)
tree89105c0f7e694e54c7a9cd15fa0b7a66c7751169 /arch/x86/kernel/head32.c
parent2e9064faccd1a5b9de8c6f4b23d9f4948901cbe9 (diff)
x86/boot/32: Disable stackprotector and tracing for mk_early_pgtbl_32()
Stackprotector cannot work before paging is enabled. The read from the per CPU variable __stack_chk_guard is always accessing the virtual address either directly on UP or via FS on SMP. In physical address mode this results in an access to memory above 3GB. So this works by chance as the hardware returns the same value when there is no RAM at this physical address. When there is RAM populated above 3G then the read is by chance the same as nothing changes that memory during the very early boot stage. Stop relying on pure luck and disable the stack protector for the only C function which is called during early boot before paging is enabled. Remove function tracing from the whole source file as there is no way to trace this at all, but in case of CONFIG_DYNAMIC_FTRACE=n mk_early_pgtbl_32() would access global function tracer variables in physical address mode which again might work by chance. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Link: https://lore.kernel.org/r/20231002115902.156063939@linutronix.de
Diffstat (limited to 'arch/x86/kernel/head32.c')
-rw-r--r--arch/x86/kernel/head32.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/arch/x86/kernel/head32.c b/arch/x86/kernel/head32.c
index 246a609f889b..bf678d6f4359 100644
--- a/arch/x86/kernel/head32.c
+++ b/arch/x86/kernel/head32.c
@@ -70,7 +70,8 @@ asmlinkage __visible void __init __noreturn i386_start_kernel(void)
* always zero at this stage.
*/
void __init mk_early_pgtbl_32(void);
-void __init mk_early_pgtbl_32(void)
+
+void __init __no_stack_protector mk_early_pgtbl_32(void)
{
#ifdef __pa
#undef __pa