Re: [PREEMPT] Kernel panic - not syncing: stack-protector: Kernel stack is corrupted

From: Damien Stewart

Date: Sun Dec 06 2026 - 01:25:22 EST


On 25/11/26 3:28 pm, Christian Zigotzky wrote:

It is very difficult to figure out what the issue is because it occurs sporadically.

Cheers,
Christian


So after reading info I've found I'm sure it's due to the same issue that has plagued PPC64 before. I've examined ASM code and found the compiler is caching register r13 into r10 in the 7.3.0 kernel build which I found corrupted the canary. So it's reading off a stale PACA pointer, yes, that old canard again.

The cause looks to be no static TLS register on PPC64 so the volatile PACA is used instead. The problem being the compiler doesn't seem to be aware the PACA is volatile so any preemptive move switching a task can change it. In that case I wonder if the current PACA should contain an extra pointer that is always guaranteed to hold current task context for that CPU.


So GCC version 9.4.0 and GCC version 10.4.0 are known to cause it in compiled code. The bug is rather annoying as the source code looks fine but machine code generated by certain compilers producing unstable code. The GCC option "-mstack-protector-guard-reg=r13" should solve it. Which option CONFIG_STACKPROTECTOR should enable. But, only for later compilers. If an earlier compiler must be used, to circumvent any other build or code issues, then a clean patch to tell the compiler r13 is volatile looks like one solution.

--
My regards,

Damien Stewart.