aboutsummaryrefslogtreecommitdiffstats
path: root/queue-6.15/revert-riscv-misaligned-fix-sleeping-function-called-during-misaligned-access-handling.patch
diff options
Diffstat (limited to 'queue-6.15/revert-riscv-misaligned-fix-sleeping-function-called-during-misaligned-access-handling.patch')
-rw-r--r--queue-6.15/revert-riscv-misaligned-fix-sleeping-function-called-during-misaligned-access-handling.patch59
1 files changed, 59 insertions, 0 deletions
diff --git a/queue-6.15/revert-riscv-misaligned-fix-sleeping-function-called-during-misaligned-access-handling.patch b/queue-6.15/revert-riscv-misaligned-fix-sleeping-function-called-during-misaligned-access-handling.patch
new file mode 100644
index 0000000000..0be8343214
--- /dev/null
+++ b/queue-6.15/revert-riscv-misaligned-fix-sleeping-function-called-during-misaligned-access-handling.patch
@@ -0,0 +1,59 @@
+From 2f73c62d4e13df67380ff6faca39eec2bf08dd93 Mon Sep 17 00:00:00 2001
+From: Nam Cao <namcao@linutronix.de>
+Date: Fri, 20 Jun 2025 13:09:39 +0200
+Subject: Revert "riscv: misaligned: fix sleeping function called during misaligned access handling"
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Nam Cao <namcao@linutronix.de>
+
+commit 2f73c62d4e13df67380ff6faca39eec2bf08dd93 upstream.
+
+This reverts commit 61a74ad25462 ("riscv: misaligned: fix sleeping function
+called during misaligned access handling"). The commit addresses a sleeping
+in atomic context problem, but it is not the correct fix as explained by
+Clément:
+
+"Using nofault would lead to failure to read from user memory that is paged
+out for instance. This is not really acceptable, we should handle user
+misaligned access even at an address that would generate a page fault."
+
+This bug has been properly fixed by commit 453805f0a28f ("riscv:
+misaligned: enable IRQs while handling misaligned accesses").
+
+Revert this improper fix.
+
+Link: https://lore.kernel.org/linux-riscv/b779beed-e44e-4a5e-9551-4647682b0d21@rivosinc.com/
+Signed-off-by: Nam Cao <namcao@linutronix.de>
+Cc: stable@vger.kernel.org
+Reviewed-by: Clément Léger <cleger@rivosinc.com>
+Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>
+Fixes: 61a74ad25462 ("riscv: misaligned: fix sleeping function called during misaligned access handling")
+Link: https://lore.kernel.org/r/20250620110939.1642735-1-namcao@linutronix.de
+Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/riscv/kernel/traps_misaligned.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/arch/riscv/kernel/traps_misaligned.c
++++ b/arch/riscv/kernel/traps_misaligned.c
+@@ -453,7 +453,7 @@ static int handle_scalar_misaligned_load
+
+ val.data_u64 = 0;
+ if (user_mode(regs)) {
+- if (copy_from_user_nofault(&val, (u8 __user *)addr, len))
++ if (copy_from_user(&val, (u8 __user *)addr, len))
+ return -1;
+ } else {
+ memcpy(&val, (u8 *)addr, len);
+@@ -554,7 +554,7 @@ static int handle_scalar_misaligned_stor
+ return -EOPNOTSUPP;
+
+ if (user_mode(regs)) {
+- if (copy_to_user_nofault((u8 __user *)addr, &val, len))
++ if (copy_to_user((u8 __user *)addr, &val, len))
+ return -1;
+ } else {
+ memcpy((u8 *)addr, &val, len);