riscv: misaligned: Restrict user access to kernel memory
BugLink: https://bugs.launchpad.net/bugs/2085849
commit b686ecdeacf6658e1348c1a32a08e2e72f7c0f00 upstream.
raw_copy_{to,from}_user() do not call access_ok(), so this code allowed
userspace to access any virtual memory address.
Cc: stable@vger.kernel.org
Fixes: 7c83232161 ("riscv: add support for misaligned trap handling in S-mode")
Fixes: 441381506ba7 ("riscv: misaligned: remove CONFIG_RISCV_M_MODE specific code")
Signed-off-by: Samuel Holland <samuel.holland@sifive.com>
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Link: https://lore.kernel.org/r/20240815005714.1163136-1-samuel.holland@sifive.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
CVE-2024-46792
Signed-off-by: Manuel Diewald <manuel.diewald@canonical.com>
Signed-off-by: Roxana Nicolescu <roxana.nicolescu@canonical.com>
This commit is contained in:
committed by
Mehmet Basaran
parent
d21f72aba5
commit
19237b9f98
@@ -415,7 +415,7 @@ int handle_misaligned_load(struct pt_regs *regs)
|
||||
|
||||
val.data_u64 = 0;
|
||||
if (user_mode(regs)) {
|
||||
if (raw_copy_from_user(&val, (u8 __user *)addr, len))
|
||||
if (copy_from_user(&val, (u8 __user *)addr, len))
|
||||
return -1;
|
||||
} else {
|
||||
memcpy(&val, (u8 *)addr, len);
|
||||
@@ -513,7 +513,7 @@ int handle_misaligned_store(struct pt_regs *regs)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
if (user_mode(regs)) {
|
||||
if (raw_copy_to_user((u8 __user *)addr, &val, len))
|
||||
if (copy_to_user((u8 __user *)addr, &val, len))
|
||||
return -1;
|
||||
} else {
|
||||
memcpy((u8 *)addr, &val, len);
|
||||
|
||||
Reference in New Issue
Block a user