Re: [PATCH v2] sched: move stack_canary to the start of the randomizable region

From: Ron Economos

Date: Fri Nov 13 2026 - 08:57:41 EST


On 11/12/26 07:34, Peter Zijlstra wrote:
On Thu, Nov 12, 2026 at 05:33:16AM -0800, Ron Economos wrote:

---
From: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Date: Fri, 6 Nov 2026 17:07:30 +0100
Subject: [PATCH] riscv, sched: move stack_canary to thread_info

task_struct keeps growing over time. On architectures that compute the
per-task stack canary offset from asm-offsets.h and pass it to the
compiler via -mstack-protector-guard-offset=, this growth eventually
pushes stack_canary beyond what the target ISA can encode.

On RISC-V, canary loads are emitted as

ld t0, TSK_STACK_CANARY(tp)

where TSK_STACK_CANARY must fit into a 12-bit signed immediate, i.e.
[-2048, 2047]. Once stack_canary sits past byte 2047 of task_struct,
the build fails with

cc1: error: '<N>' is not a valid offset in
'-mstack-protector-guard-offset='

On RISC-V, CONFIG_STACKPROTECTOR_PER_TASK depends on !RANDSTRUCT, thus
stack_canary does not benefit from being in the task_struct randomized
region.

Move the RISC-V stack_canary to thread_info, and introduce an access macro
to point to the right stack_canary location. Other archs are unaffected.

Not-signed-off-by: Ruidong Tian <tianruidong@xxxxxxxxxxxxxxxxx>
Signed-off-by: Peter Zijlstra <peterz@xxxxxxxxxxxxx>

Signed-off-by: Valentin Schneider <vschneid@xxxxxxxxxx>
---
I'm seeing this build failure on RISC-V with gcc 16 and
CONFIG_SCHED_CLASS_EXT=y. The build does not fail with gcc 14. I've tested
the proposed patch with gcc 16 and it builds and boots (on real hardware)
just fine. So for what it's worth:

Tested-by: Ron Economos <re@xxxxxxxx>

Also re-adding the RISC-V folks.
Hmm, they went walk-about? Do they need a re-sent? I'm thinking this out
to perhaps go through their tree, given they're actually seeing the
problem.

Yes, a re-send with the new subject line would be good. That way, the patch at least gets queued in the RISC-V patchwork.

https://patchwork.kernel.org/project/linux-riscv/list/