Skip to content

Commit c08b484

Browse files
Chen Lifupalmer-dabbelt
authored andcommitted
riscv: lib: uaccess: fix CSR_STATUS SR_SUM bit
Since commit 5d8544e ("RISC-V: Generic library routines and assembly") and commit ebcbd75 ("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: 5d8544e ("RISC-V: Generic library routines and assembly") Fixes: ebcbd75 ("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]>
1 parent 4d1044f commit c08b484

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

arch/riscv/lib/uaccess.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ ENTRY(__asm_copy_from_user)
175175
/* Exception fixup code */
176176
10:
177177
/* Disable access to user memory */
178-
csrs CSR_STATUS, t6
178+
csrc CSR_STATUS, t6
179179
mv a0, t5
180180
ret
181181
ENDPROC(__asm_copy_to_user)
@@ -227,7 +227,7 @@ ENTRY(__clear_user)
227227
/* Exception fixup code */
228228
11:
229229
/* Disable access to user memory */
230-
csrs CSR_STATUS, t6
230+
csrc CSR_STATUS, t6
231231
mv a0, a1
232232
ret
233233
ENDPROC(__clear_user)

0 commit comments

Comments
 (0)