lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20260205055342.572379-1-minachou@andestech.com>
Date: Thu, 5 Feb 2026 13:53:42 +0800
From: Hui Min Mina Chou <minachou@...estech.com>
To: <pjw@...nel.org>, <palmer@...belt.com>, <aou@...s.berkeley.edu>,
        <alex@...ti.fr>, <linux-riscv@...ts.infradead.org>,
        <linux-kernel@...r.kernel.org>
CC: <tim609@...estech.com>, <ben717@...estech.com>, <minachou@...estech.com>,
        <az70021@...il.com>, Charles Ci-Jyun Wu <dminus@...estech.com>
Subject: [PATCH] riscv: fpu: refine FPU save flow

From: Charles Ci-Jyun Wu <dminus@...estech.com>

When Kernel first time run to arch_dup_task_struct(),
it will check if sstatus.FS is dirty. If it is dirty,
then it will do FPU save flow. But this field is
floating currently. Meanwhile if the combination between
platform(HW) and Kernel(SW) about FPU configuration
is mismatch. eq: The platform is without FPU and Kernel
is with FPU. Then Kernel may trigger illegal instruction
here.

Hence it shall check by has_fpu before do FPU save flow
in arch_dup_task_struct().

Signed-off-by: Rick Chen <rick@...estech.com>
Signed-off-by: Charles Ci-Jyun Wu <dminus@...estech.com>
---
 arch/riscv/kernel/process.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/riscv/kernel/process.c b/arch/riscv/kernel/process.c
index 31a392993cb4..a27c21c7d9c6 100644
--- a/arch/riscv/kernel/process.c
+++ b/arch/riscv/kernel/process.c
@@ -199,7 +199,8 @@ void arch_release_task_struct(struct task_struct *tsk)
 
 int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src)
 {
-	fstate_save(src, task_pt_regs(src));
+	if (has_fpu())
+		fstate_save(src, task_pt_regs(src));
 	*dst = *src;
 	/* clear entire V context, including datap for a new task */
 	memset(&dst->thread.vstate, 0, sizeof(struct __riscv_v_ext_state));
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ