Re: gcc-10: kernel stack is corrupted and fails to boot

From: Arnd Bergmann
Date: Wed May 13 2020 - 12:02:43 EST


On Wed, May 13, 2020 at 5:31 PM Kalle Valo <kvalo@xxxxxxxxxxxxxx> wrote:
> Arnd Bergmann <arnd@xxxxxxxx> writes:
> > On Wed, May 13, 2020 at 2:57 PM Kalle Valo <kvalo@xxxxxxxxxxxxxx> wrote:
> >>
> >> Arnd Bergmann <arnd@xxxxxxxx> writes:
> >>
> >> > If you share your .config, I can try reproducing with that as well.
> >> > Once there is a reproducer in qemu, it should be trivial to step
> >> > through it using gdb.
> >>
> >> I have attached the .config I used with GCC 10.1. If you are able to
> >> test it please do let me know how it went.
> >
> > Yes, I see the same problem now, but have not investigated
> > any further.
>
> Great, so it's not a problem due to my setup.

I investigated a little more: This does happen with 'defconfig'
after all, in my first try I must have missed the '-smp 2' argument
to qemu, and it ended up working correctly with just one CPU
but fails now.

Stepping through the boot process, I see where it crashes
in start_secondary:

| /* to prevent fake stack check failure in clock setup */
| boot_init_stack_canary();
|
| x86_cpuinit.setup_percpu_clockev();
|
| wmb();
| cpu_startup_entry(CPUHP_AP_ONLINE_IDLE);

The call to cpu_startup_entry() does not succeed, instead
it jumps to __stack_chk_fail() from there.

Arnd