]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
LoongArch: Fix arch_dup_task_struct() for CONFIG_RANDSTRUCT
authorHuacai Chen <chenhuacai@loongson.cn>
Sat, 6 Dec 2025 02:39:48 +0000 (10:39 +0800)
committerHuacai Chen <chenhuacai@loongson.cn>
Sat, 6 Dec 2025 02:39:48 +0000 (10:39 +0800)
Now the optimized version of arch_dup_task_struct() for LoongArch
assumes 'thread' is the last member of 'task_struct'. But this is
not true if CONFIG_RANDSTRUCT is enabled after Linux-6.16.

So fix the arch_dup_task_struct() function for CONFIG_RANDSTRUCT by
copying the whole 'task_struct'.

Cc: stable@vger.kernel.org # 6.16+
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
arch/loongarch/kernel/process.c

index efd9edf65603ccd16408dbe5d2b71a47d08561ff..d1e04f9e0f79516dbbf286fcbe0cfeff930bd9fe 100644 (file)
@@ -130,6 +130,11 @@ int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src)
 
        preempt_enable();
 
+       if (IS_ENABLED(CONFIG_RANDSTRUCT)) {
+               memcpy(dst, src, sizeof(struct task_struct));
+               return 0;
+       }
+
        if (!used_math())
                memcpy(dst, src, offsetof(struct task_struct, thread.fpu.fpr));
        else