Skip to contentSkip to conversation

x86/purgatory: undefined symbol __stack_chk_fail

DISCUSSION Arvind Sankar 2 participants 2 messages Sep 28, 2019 – Sep 29, 2019

lore
Share & tools
lore
#0 lore raw
Quoted 35 lines · Ingo Molnar
Quoted 19 lines · Randy Dunlap
Quoted 18 lines · Andreas Smas

Hi,

For me, kernels built including this commit
b059f801a937 (x86/purgatory: Use CFLAGS_REMOVE rather than reset KBUILD_CFLAGS)

results in kexec() failing to load the kernel:

kexec: Undefined symbol: __stack_chk_fail
kexec-bzImage64: Loading purgatory failed

Can be seen:

$ readelf -a arch/x86/purgatory/purgatory.ro | grep UND
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
    51: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND __stack_chk_fail

Using: gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1)

Quoted 8 lines
Quoted 4 lines

Adding -ffreestanding or -fno-stack-protector to ccflags-y in arch/x86/purgatory/Makefile
fixes the problem. Not sure which would be preferred.

Hi,
Do you have a kernel .config file that causes this? I can't seem to reproduce it.

Does it go away with this fix in x86/urgent:

ca14c996afe7: ("x86/purgatory: Disable the stackleak GCC plugin for the purgatory")

Quoted 7 lines

git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86/urgent

?

Thanks,

Ing

This one was fixed by [1] e16c2983fba0f ("x86/purgatory: Change compiler flags from -mcmodel=kernel to -mcmodel=large to fix kexec relocation errors") from Steve Wahl, which in addition to changing mcmodel also added back -ffreestanding (and -fno-zero-initialized-in-bss). It was merged on the 12th. The stackleak one is a different undefined symbol error.

[1] https://marc.info/?l=git-commits-head&m=156829711224800

#1 lore raw
Quoted 43 lines · Arvind Sankar
Quoted 35 lines · Ingo Molnar
Quoted 19 lines · Randy Dunlap
Quoted 18 lines · Andreas Smas

Hi,

For me, kernels built including this commit
b059f801a937 (x86/purgatory: Use CFLAGS_REMOVE rather than reset KBUILD_CFLAGS)

results in kexec() failing to load the kernel:

kexec: Undefined symbol: __stack_chk_fail
kexec-bzImage64: Loading purgatory failed

Can be seen:

$ readelf -a arch/x86/purgatory/purgatory.ro | grep UND
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
    51: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND __stack_chk_fail

Using: gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1)

Quoted 8 lines
Quoted 4 lines

Adding -ffreestanding or -fno-stack-protector to ccflags-y in arch/x86/purgatory/Makefile
fixes the problem. Not sure which would be preferred.

Hi,
Do you have a kernel .config file that causes this? I can't seem to reproduce it.

Does it go away with this fix in x86/urgent:

ca14c996afe7: ("x86/purgatory: Disable the stackleak GCC plugin for the purgatory")

Quoted 7 lines

git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86/urgent

?

Thanks,

Ing

Quoted 8 lines

This one was fixed by [1] e16c2983fba0f ("x86/purgatory: Change compiler flags from -mcmodel=kernel to -mcmodel=large to fix kexec relocation errors") from Steve Wahl, which in addition to changing mcmodel also added back -ffreestanding (and -fno-zero-initialized-in-bss). It was merged on the 12th. The stackleak one is a different undefined symbol error.

[1] https://marc.info/?l=git-commits-head&m=156829711224800

Great, so all known kexec bugs should be fixed for now in Linus's latest kernel, right?

Thanks,

Ingo