[PATCH v2] sched: move stack_canary to the start of the randomizable region
Valentin Schneider
vschneid at redhat.com
Fri Nov 6 07:29:07 PST 2026
On 21/08/26 13:11, Charles Mirabile wrote:
> Hi Ruidong, Valentin, (+ copying in RISC-V list/maintainers)—
>
> On Tue, May 12, 2026 at 06:16:43PM +0200, Valentin Schneider wrote:
>> On 09/05/26 11:50, Ruidong Tian wrote:
>> > 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='
>
> Thanks for this patch. We just ran into this exact issue during a CKI build
> https://datawarehouse.cki-project.org/kcidb/builds/1639782 and this seems
> like exactly the fix we need.
>
I've also been pinged about this exact failure;
Peter, Ingo, do you think you could take this?
I couldn't find anything better than to add a LUI instruction to stretch
the immediate beyond 2k, which is a bit wasteful. This looks okay for now,
until someone smarter can come with a risc-v specific improvement (or the
architecture grows scaled immediate offsets).
More information about the linux-riscv
mailing list