]> Git Repo - J-linux.git/commitdiff
riscv: lib: uaccess: fix CSR_STATUS SR_SUM bit
authorChen Lifu <[email protected]>
Wed, 15 Jun 2022 01:47:14 +0000 (09:47 +0800)
committerPalmer Dabbelt <[email protected]>
Wed, 10 Aug 2022 21:06:31 +0000 (14:06 -0700)
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 <[email protected]>
Reviewed-by: Ben Dooks <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Cc: [email protected]
Signed-off-by: Palmer Dabbelt <[email protected]>
arch/riscv/lib/uaccess.S

index 8c475f4da3084f2457f372b52ee0094bd3597003..ec486e5369d9bf5b274bcd73b242666d2b216322 100644 (file)
@@ -175,7 +175,7 @@ ENTRY(__asm_copy_from_user)
        /* Exception fixup code */
 10:
        /* Disable access to user memory */
-       csrs CSR_STATUS, t6
+       csrc CSR_STATUS, t6
        mv a0, t5
        ret
 ENDPROC(__asm_copy_to_user)
@@ -227,7 +227,7 @@ ENTRY(__clear_user)
        /* Exception fixup code */
 11:
        /* Disable access to user memory */
-       csrs CSR_STATUS, t6
+       csrc CSR_STATUS, t6
        mv a0, a1
        ret
 ENDPROC(__clear_user)
This page took 0.0563 seconds and 4 git commands to generate.