riscv: lib: uaccess: fix CSR_STATUS SR_SUM bit
authorChen Lifu <chenlifu@huawei.com>
Wed, 15 Jun 2022 01:47:14 +0000 (09:47 +0800)
committerPalmer Dabbelt <palmer@rivosinc.com>
Wed, 10 Aug 2022 21:06:31 +0000 (14:06 -0700)
commitc08b4848f596fd95543197463b5162bd7bab2442
tree2646264133159290bbcf4fda50a370fa37ff0d29
parent4d1044fcb996e8de9b9ab392f4a767890e45202d
riscv: lib: uaccess: fix CSR_STATUS SR_SUM bit

Since commit 5d8544e2d007 ("RISC-V: Generic library routines and assembly")
and commit ebcbd75e3962 ("riscv: Fix the bug in memory access fixup code"),
if __clear_user and __copy_user return from an fixup branch,
CSR_STATUS SR_SUM bit will be set, it is a vulnerability, so that
S-mode memory accesses to pages that are accessible by U-mode will success.
Disable S-mode access to U-mode memory should clear SR_SUM bit.

Fixes: 5d8544e2d007 ("RISC-V: Generic library routines and assembly")
Fixes: ebcbd75e3962 ("riscv: Fix the bug in memory access fixup code")
Signed-off-by: Chen Lifu <chenlifu@huawei.com>
Reviewed-by: Ben Dooks <ben.dooks@codethink.co.uk>
Link: https://lore.kernel.org/r/20220615014714.1650349-1-chenlifu@huawei.com
Cc: stable@vger.kernel.org
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
arch/riscv/lib/uaccess.S