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

Configure Feed

Select the types of activity you want to include in your feed.

kstack_erase: Add -mgeneral-regs-only to silence Clang warnings

Once CONFIG_KSTACK_ERASE is enabled with Clang on i386, the build warns:

kernel/kstack_erase.c:168:2: warning: function with attribute 'no_caller_saved_registers' should only call a function with attribute 'no_caller_saved_registers' or be compiled with '-mgeneral-regs-only' [-Wexcessive-regsave]

Add -mgeneral-regs-only for the kstack_erase handler, to make Clang feel
better (it is effectively a no-op flag for the kernel). No binary
changes encountered.

Build & boot tested with Clang 21 on x86_64, and i386.
Build tested with GCC 14.2.0 on x86_64, i386, arm64, and arm.

Reported-by: Nathan Chancellor <nathan@kernel.org>
Closes: https://lore.kernel.org/all/20250726004313.GA3650901@ax162
Tested-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Kees Cook <kees@kernel.org>

Kees Cook 6676fd3c 381a38ea

+1
+1
kernel/Makefile
··· 140 140 obj-$(CONFIG_SYSCTL_KUNIT_TEST) += sysctl-test.o 141 141 142 142 CFLAGS_kstack_erase.o += $(DISABLE_KSTACK_ERASE) 143 + CFLAGS_kstack_erase.o += $(call cc-option,-mgeneral-regs-only) 143 144 obj-$(CONFIG_KSTACK_ERASE) += kstack_erase.o 144 145 KASAN_SANITIZE_kstack_erase.o := n 145 146 KCSAN_SANITIZE_kstack_erase.o := n