From d5f40f0b4bd185bf477c4a579774d2eafd302da7 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Wed, 23 Sep 2026 17:34:31 +0200 Subject: [PATCH] um: make stub compilation more robust With clang, stub compilation could result in getting stack frames where none are allowed, or ways of making it be not relocatable. Set -ftrivial-auto-var-init=uninitialized for more code, and -fomit-frame-pointer as well to avoid these issues. Link: https://patch.msgid.link/20260923173523.9cb03214335b.Ie1487657bc0f464f4911e95f532ab010b32864b8@changeid Signed-off-by: Johannes Berg --- arch/um/kernel/skas/Makefile | 10 ++++++++-- arch/x86/um/Makefile | 3 +++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/arch/um/kernel/skas/Makefile b/arch/um/kernel/skas/Makefile index c098d087c3f2..2cf82eba52f8 100644 --- a/arch/um/kernel/skas/Makefile +++ b/arch/um/kernel/skas/Makefile @@ -44,8 +44,14 @@ targets += stub_exe.dbg stub_exe $(stub_exe_objs-y) CFLAGS_stub.o := $(CFLAGS_NO_HARDENING) CFLAGS_stub_exe.o := $(CFLAGS_NO_HARDENING) -# Clang will call memset() from __builtin_alloca() when stack variable -# initialization is enabled, which is used in stub_exe.c. +# stub_signal_restorer() must not touch stack pointer, clang doesn't +# always omit the frame pointer automatically +CFLAGS_stub.o += -fomit-frame-pointer +CFLAGS_stub_exe.o += -fomit-frame-pointer + +# Clang's stack var initialisation can use memset() or similar and that +# cannot be done for this code since we embed/move the stub +CFLAGS_stub.o += $(call cc-option, -ftrivial-auto-var-init=uninitialized) CFLAGS_stub_exe.o += $(call cc-option, -ftrivial-auto-var-init=uninitialized) UNPROFILE_OBJS := stub.o stub_exe.o diff --git a/arch/x86/um/Makefile b/arch/x86/um/Makefile index f9ea75bf43ac..100b68f601f9 100644 --- a/arch/x86/um/Makefile +++ b/arch/x86/um/Makefile @@ -47,4 +47,7 @@ include/generated/user_constants.h: $(obj)/user-offsets.s FORCE UNPROFILE_OBJS := stub_segv.o CFLAGS_stub_segv.o := $(CFLAGS_NO_HARDENING) +# see arch/um/kernel/skas/Makefile - this goes into the stub +CFLAGS_stub_segv.o += $(call cc-option, -ftrivial-auto-var-init=uninitialized) + include $(srctree)/arch/um/scripts/Makefile.rules