summaryrefslogtreecommitdiffstats
path: root/arch/riscv
diff options
context:
space:
mode:
authorAndy Chiu <andy.chiu@sifive.com>2023-06-27 01:55:54 +0000
committerPalmer Dabbelt <palmer@rivosinc.com>2023-07-01 07:38:21 -0700
commit75b59f2a90aa7ccac62e3dcb680dfb967b341431 (patch)
tree45489bc1ac989f47e2cb742c163f5d04943aefaf /arch/riscv
parent26c38cd802c947401cfbcc285b7d841256b5f17f (diff)
downloadlinux-stable-75b59f2a90aa7ccac62e3dcb680dfb967b341431.tar.gz
linux-stable-75b59f2a90aa7ccac62e3dcb680dfb967b341431.tar.bz2
linux-stable-75b59f2a90aa7ccac62e3dcb680dfb967b341431.zip
riscv: vector: clear V-reg in the first-use trap
If there is no context switch happens after we enable V for a process, then we return to user space with whatever left on the CPU's V registers accessible to the process. The leaked data could belong to another process's V-context saved from last context switch, impacting process's confidentiality on the system. To prevent this from happening, we clear V registers by restoring zero'd V context after turining on V. Fixes: cd054837243b ("riscv: Allocate user's vector context in the first-use trap") Signed-off-by: Andy Chiu <andy.chiu@sifive.com> Reviewed-by: Björn Töpel <bjorn@rivosinc.com> Link: https://lore.kernel.org/r/20230627015556.12329-2-andy.chiu@sifive.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Diffstat (limited to 'arch/riscv')
-rw-r--r--arch/riscv/kernel/vector.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/arch/riscv/kernel/vector.c b/arch/riscv/kernel/vector.c
index f9c8e19ab301..8d92fb6c522c 100644
--- a/arch/riscv/kernel/vector.c
+++ b/arch/riscv/kernel/vector.c
@@ -167,6 +167,7 @@ bool riscv_v_first_use_handler(struct pt_regs *regs)
return true;
}
riscv_v_vstate_on(regs);
+ riscv_v_vstate_restore(current, regs);
return true;
}