1 From 2f73c62d4e13df67380ff6faca39eec2bf08dd93 Mon Sep 17 00:00:00 2001
2 From: Nam Cao <namcao@linutronix.de>
3 Date: Fri, 20 Jun 2025 13:09:39 +0200
4 Subject: Revert "riscv: misaligned: fix sleeping function called during misaligned access handling"
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 From: Nam Cao <namcao@linutronix.de>
11 commit 2f73c62d4e13df67380ff6faca39eec2bf08dd93 upstream.
13 This reverts commit 61a74ad25462 ("riscv: misaligned: fix sleeping function
14 called during misaligned access handling"). The commit addresses a sleeping
15 in atomic context problem, but it is not the correct fix as explained by
18 "Using nofault would lead to failure to read from user memory that is paged
19 out for instance. This is not really acceptable, we should handle user
20 misaligned access even at an address that would generate a page fault."
22 This bug has been properly fixed by commit 453805f0a28f ("riscv:
23 misaligned: enable IRQs while handling misaligned accesses").
25 Revert this improper fix.
27 Link: https://lore.kernel.org/linux-riscv/b779beed-e44e-4a5e-9551-4647682b0d21@rivosinc.com/
28 Signed-off-by: Nam Cao <namcao@linutronix.de>
29 Cc: stable@vger.kernel.org
30 Reviewed-by: Clément Léger <cleger@rivosinc.com>
31 Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>
32 Fixes: 61a74ad25462 ("riscv: misaligned: fix sleeping function called during misaligned access handling")
33 Link: https://lore.kernel.org/r/20250620110939.1642735-1-namcao@linutronix.de
34 Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com>
35 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
37 arch/riscv/kernel/traps_misaligned.c | 4 ++--
38 1 file changed, 2 insertions(+), 2 deletions(-)
40 --- a/arch/riscv/kernel/traps_misaligned.c
41 +++ b/arch/riscv/kernel/traps_misaligned.c
42 @@ -429,7 +429,7 @@ int handle_misaligned_load(struct pt_reg
45 if (user_mode(regs)) {
46 - if (copy_from_user_nofault(&val, (u8 __user *)addr, len))
47 + if (copy_from_user(&val, (u8 __user *)addr, len))
50 memcpy(&val, (u8 *)addr, len);
51 @@ -530,7 +530,7 @@ int handle_misaligned_store(struct pt_re
54 if (user_mode(regs)) {
55 - if (copy_to_user_nofault((u8 __user *)addr, &val, len))
56 + if (copy_to_user((u8 __user *)addr, &val, len))
59 memcpy((u8 *)addr, &val, len);