(cc Sami, Masahiro) On Wed, 19 Mar 2025 at 06:10, Aleksandr Nogikh <nogikh@xxxxxxxxxx> wrote: > > On Sat, Feb 22, 2025 at 10:02 PM syzbot > <syzbot+06fd1a3613c50d36129e@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote: > > > > Hello, > > > > syzbot found the following issue on: > > > > HEAD commit: d4b0fd87ff0d Add linux-next specific files for 20250221 > > git tree: linux-next > > console output: https://syzkaller.appspot.com/x/log.txt?x=17a5bae4580000 > > kernel config: https://syzkaller.appspot.com/x/.config?x=76d7299d72819017 > > dashboard link: https://syzkaller.appspot.com/bug?extid=06fd1a3613c50d36129e > > compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40 > > > > IMPORTANT: if you fix the issue, please add the following tag to the commit: > > Reported-by: syzbot+06fd1a3613c50d36129e@xxxxxxxxxxxxxxxxxxxxxxxxx > > > > <stdin>:4:15: error: use of undeclared identifier '__ref_stack_chk_guard' > > Manual bisection pointed to the commits from this patch series: > > [PATCH v5 00/16] x86-64: Stack protector and percpu improvements > https://lore.kernel.org/lkml/20241105155801.1779119-1-brgerst@xxxxxxxxx/ > > Brian, could you please take a look at this syzbot report? > > The latest build log (for next-20250318) is here: > https://syzkaller.appspot.com/text?tag=CrashLog&x=10a745e4580000 > > It failed with the following error: > > <stdin>:4:15: error: use of undeclared identifier '__ref_stack_chk_guard' > EXPORT_SYMBOL(__ref_stack_chk_guard); > ^ > 1 error generated. > make[4]: *** [scripts/Makefile.build:335: arch/x86/entry/entry.o] Error 1 > make[4]: *** Deleting file 'arch/x86/entry/entry.o' > make[4]: *** Waiting for unfinished jobs.... > This appears to be an interaction with gendwarfksyms: # AS arch/x86/entry/entry.o clang-15 -Wp,-MMD,arch/x86/entry/.entry.o.d -nostdinc -I/usr/local/google/home/ardb/linux/arch/x86/include -I./arch/x86/include/generated -I/usr/local/google/home/ardb/linux/include -I./include -I/usr/local/google/home/ardb/linux/arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I/usr/local/google/home/ardb/linux/include/uapi -I./include/generated/uapi -include /usr/local/google/home/ardb/linux/include/linux/compiler-version.h -include /usr/local/google/home/ardb/linux/include/linux/kconfig.h -D__KERNEL__ --target=x86_64-linux-gnu -fintegrated-as -Werror=unknown-warning-option -Werror=ignored-optimization-argument -Werror=option-ignored -Werror=unused-command-line-argument -fmacro-prefix-map=/usr/local/google/home/ardb/linux/= -D__ASSEMBLY__ -fno-PIE -m64 -g -gdwarf-4 -I/usr/local/google/home/ardb/linux/arch/x86/entry -Iarch/x86/entry -DKBUILD_MODFILE='"arch/x86/entry/entry"' -DKBUILD_MODNAME='"entry"' -D__KBUILD_MODNAME=kmod_entry -c -o arch/x86/entry/entry.o /usr/local/google/home/ardb/linux/arch/x86/entry/entry.S # cmd_gen_symversions_S arch/x86/entry/entry.o if llvm-nm-15 arch/x86/entry/entry.o 2>/dev/null | grep -q ' __export_symbol_'; then { echo "#include <linux/kernel.h>" ; echo "#include <linux/string.h>" ; echo "#include <asm/asm-prototypes.h>" ; llvm-nm-15 arch/x86/entry/entry.o | sed -n 's/.* __export_symbol_\(.*\)/EXPORT_SYMBOL(\1);/p' ; } | clang-15 ... -c -o arch/x86/entry/entry.gendwarfksyms.o -xc -; llvm-nm-15 arch/x86/entry/entry.o | sed -n 's/.* __export_symbol_\(.*\)/\1/p' | ./scripts/gendwarfksyms/gendwarfksyms arch/x86/entry/entry.gendwarfksyms.o >> arch/x86/entry/.entry.o.cmd; fi <stdin>:4:15: error: use of undeclared identifier '__ref_stack_chk_guard' EXPORT_SYMBOL(__ref_stack_chk_guard); ^ 1 error generated. The issue here is that we deliberately hide __ref_stack_chk_guard from the compiler, because Clang will otherwise generate incorrect code. [0] I managed to work around this issue using the hack below, but I'm not too familiar with the gendwarfksyms code, so I'll leave it up to Sami and Masahiro to decide whether this is the right approach before sending out a patch. --- a/arch/x86/include/asm/asm-prototypes.h +++ b/arch/x86/include/asm/asm-prototypes.h @@ -20,6 +20,7 @@ extern void cmpxchg8b_emu(void); #endif -#if defined(__GENKSYMS__) && defined(CONFIG_STACKPROTECTOR) +#if (defined(__GENKSYMS__) || defined(__GENDWARFKSYMS__)) \ + && defined(CONFIG_STACKPROTECTOR) extern unsigned long __ref_stack_chk_guard; #endif --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -311,7 +311,8 @@ ifdef CONFIG_GENDWARFKSYMS cmd_gensymtypes_S = \ $(getasmexports) | \ - $(CC) $(c_flags) -c -o $(@:.o=.gendwarfksyms.o) -xc -; \ + $(CC) -D__GENDWARFKSYMS__ \ + $(c_flags) -c -o $(@:.o=.gendwarfksyms.o) -xc -; \ $(call getexportsymbols,\1) | \ $(gendwarfksyms) $(@:.o=.gendwarfksyms.o) else (Note that simply #define'ing __GENKSYMS__ here and relying on that in asm-prototypes.h doesn't work.) [0] 577c134d311b ("x86/stackprotector: Work around strict Clang TLS symbol requirements")