* [PATCH] LoongArch: Fix build errors for CONFIG_RANDSTRUCT
@ 2025-11-25 8:25 Huacai Chen
2025-11-25 13:49 ` Jiaxun Yang
0 siblings, 1 reply; 3+ messages in thread
From: Huacai Chen @ 2025-11-25 8:25 UTC (permalink / raw)
To: Huacai Chen
Cc: loongarch, Xuefeng Li, Guo Ren, Xuerui Wang, Jiaxun Yang,
linux-kernel, Huacai Chen, stable, kernel test robot, Rui Wang
When CONFIG_RANDSTRUCT enabled, members of task_struct are randomized.
There is a chance that TASK_STACK_CANARY be out of 12bit immediate's
range and causes build errors. TASK_STACK_CANARY is naturally aligned,
so fix it by replacing ld.d/st.d with ldptr.d/stptr.d which have 14bit
immediates.
Cc: stable@vger.kernel.org
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202511240656.0NaPcJs1-lkp@intel.com/
Suggested-by: Rui Wang <wangrui@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
---
arch/loongarch/kernel/switch.S | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/loongarch/kernel/switch.S b/arch/loongarch/kernel/switch.S
index 9c23cb7e432f..3007e909e0d8 100644
--- a/arch/loongarch/kernel/switch.S
+++ b/arch/loongarch/kernel/switch.S
@@ -25,8 +25,8 @@ SYM_FUNC_START(__switch_to)
stptr.d a4, a0, THREAD_SCHED_CFA
#if defined(CONFIG_STACKPROTECTOR) && !defined(CONFIG_SMP)
la t7, __stack_chk_guard
- LONG_L t8, a1, TASK_STACK_CANARY
- LONG_S t8, t7, 0
+ ldptr.d t8, a1, TASK_STACK_CANARY
+ stptr.d t8, t7, 0
#endif
move tp, a2
cpu_restore_nonscratch a1
--
2.47.3
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] LoongArch: Fix build errors for CONFIG_RANDSTRUCT
2025-11-25 8:25 [PATCH] LoongArch: Fix build errors for CONFIG_RANDSTRUCT Huacai Chen
@ 2025-11-25 13:49 ` Jiaxun Yang
2025-11-26 7:09 ` Huacai Chen
0 siblings, 1 reply; 3+ messages in thread
From: Jiaxun Yang @ 2025-11-25 13:49 UTC (permalink / raw)
To: Huacai Chen, Huacai Chen
Cc: loongarch, Xuefeng Li, Guo Ren, Xuerui Wang, linux-kernel,
stable, kernel test robot, Rui Wang
On Tue, 25 Nov 2025, at 4:25 PM, Huacai Chen wrote:
> When CONFIG_RANDSTRUCT enabled, members of task_struct are randomized.
> There is a chance that TASK_STACK_CANARY be out of 12bit immediate's
> range and causes build errors. TASK_STACK_CANARY is naturally aligned,
> so fix it by replacing ld.d/st.d with ldptr.d/stptr.d which have 14bit
> immediates.
Hi Huacai,
What about 32bit build in this case?
Thanks
Jiaxun
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] LoongArch: Fix build errors for CONFIG_RANDSTRUCT
2025-11-25 13:49 ` Jiaxun Yang
@ 2025-11-26 7:09 ` Huacai Chen
0 siblings, 0 replies; 3+ messages in thread
From: Huacai Chen @ 2025-11-26 7:09 UTC (permalink / raw)
To: Jiaxun Yang
Cc: Huacai Chen, loongarch, Xuefeng Li, Guo Ren, Xuerui Wang,
linux-kernel, stable, kernel test robot, Rui Wang
On Tue, Nov 25, 2025 at 9:49 PM Jiaxun Yang <jiaxun.yang@flygoat.com> wrote:
>
>
>
> On Tue, 25 Nov 2025, at 4:25 PM, Huacai Chen wrote:
> > When CONFIG_RANDSTRUCT enabled, members of task_struct are randomized.
> > There is a chance that TASK_STACK_CANARY be out of 12bit immediate's
> > range and causes build errors. TASK_STACK_CANARY is naturally aligned,
> > so fix it by replacing ld.d/st.d with ldptr.d/stptr.d which have 14bit
> > immediates.
>
> Hi Huacai,
>
> What about 32bit build in this case?
Use the same solution as other registers, please see:
https://lore.kernel.org/loongarch/20251122043634.3447854-7-chenhuacai@loongson.cn/T/#u
Huacai
>
> Thanks
> Jiaxun
>
> >
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-11-26 7:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-11-25 8:25 [PATCH] LoongArch: Fix build errors for CONFIG_RANDSTRUCT Huacai Chen
2025-11-25 13:49 ` Jiaxun Yang
2025-11-26 7:09 ` Huacai Chen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®