* [PATCH] Revert "riscv: misaligned: fix sleeping function called during misaligned access handling"
@ 2025-06-20 11:09 Nam Cao
2025-06-20 11:23 ` Alexandre Ghiti
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Nam Cao @ 2025-06-20 11:09 UTC (permalink / raw)
To: Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Clément Léger, Nylon Chen, linux-riscv, linux-kernel
Cc: Nam Cao, stable
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
---
arch/riscv/kernel/traps_misaligned.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/riscv/kernel/traps_misaligned.c b/arch/riscv/kernel/traps_misaligned.c
index dd8e4af6583f4..93043924fe6c6 100644
--- a/arch/riscv/kernel/traps_misaligned.c
+++ b/arch/riscv/kernel/traps_misaligned.c
@@ -454,7 +454,7 @@ static int handle_scalar_misaligned_load(struct pt_regs *regs)
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);
@@ -555,7 +555,7 @@ static int handle_scalar_misaligned_store(struct pt_regs *regs)
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);
--
2.39.5
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Revert "riscv: misaligned: fix sleeping function called during misaligned access handling"
2025-06-20 11:09 [PATCH] Revert "riscv: misaligned: fix sleeping function called during misaligned access handling" Nam Cao
@ 2025-06-20 11:23 ` Alexandre Ghiti
2025-06-20 11:52 ` Clément Léger
2025-06-24 0:50 ` patchwork-bot+linux-riscv
2 siblings, 0 replies; 4+ messages in thread
From: Alexandre Ghiti @ 2025-06-20 11:23 UTC (permalink / raw)
To: Nam Cao, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Clément Léger, Nylon Chen, linux-riscv, linux-kernel
Cc: stable
On 6/20/25 13:09, Nam Cao wrote:
> 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
> ---
> arch/riscv/kernel/traps_misaligned.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/riscv/kernel/traps_misaligned.c b/arch/riscv/kernel/traps_misaligned.c
> index dd8e4af6583f4..93043924fe6c6 100644
> --- a/arch/riscv/kernel/traps_misaligned.c
> +++ b/arch/riscv/kernel/traps_misaligned.c
> @@ -454,7 +454,7 @@ static int handle_scalar_misaligned_load(struct pt_regs *regs)
>
> 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);
> @@ -555,7 +555,7 @@ static int handle_scalar_misaligned_store(struct pt_regs *regs)
> 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);
Of course this is a wrong fix:
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Thanks for catching this,
Alex
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Revert "riscv: misaligned: fix sleeping function called during misaligned access handling"
2025-06-20 11:09 [PATCH] Revert "riscv: misaligned: fix sleeping function called during misaligned access handling" Nam Cao
2025-06-20 11:23 ` Alexandre Ghiti
@ 2025-06-20 11:52 ` Clément Léger
2025-06-24 0:50 ` patchwork-bot+linux-riscv
2 siblings, 0 replies; 4+ messages in thread
From: Clément Léger @ 2025-06-20 11:52 UTC (permalink / raw)
To: Nam Cao, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Alexandre Ghiti, Nylon Chen, linux-riscv, linux-kernel
Cc: stable
On 20/06/2025 13:09, Nam Cao wrote:
> 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
> ---
> arch/riscv/kernel/traps_misaligned.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/riscv/kernel/traps_misaligned.c b/arch/riscv/kernel/traps_misaligned.c
> index dd8e4af6583f4..93043924fe6c6 100644
> --- a/arch/riscv/kernel/traps_misaligned.c
> +++ b/arch/riscv/kernel/traps_misaligned.c
> @@ -454,7 +454,7 @@ static int handle_scalar_misaligned_load(struct pt_regs *regs)
>
> 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);
> @@ -555,7 +555,7 @@ static int handle_scalar_misaligned_store(struct pt_regs *regs)
> 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);
Hi Nam,
Reviewed-by: Clément Léger <cleger@rivosinc.com>
Thanks for noticing that.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Revert "riscv: misaligned: fix sleeping function called during misaligned access handling"
2025-06-20 11:09 [PATCH] Revert "riscv: misaligned: fix sleeping function called during misaligned access handling" Nam Cao
2025-06-20 11:23 ` Alexandre Ghiti
2025-06-20 11:52 ` Clément Léger
@ 2025-06-24 0:50 ` patchwork-bot+linux-riscv
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+linux-riscv @ 2025-06-24 0:50 UTC (permalink / raw)
To: Nam Cao
Cc: linux-riscv, paul.walmsley, palmer, aou, alex, cleger,
nylon.chen, linux-kernel, stable
Hello:
This patch was applied to riscv/linux.git (fixes)
by Palmer Dabbelt <palmer@dabbelt.com>:
On Fri, 20 Jun 2025 13:09:39 +0200 you wrote:
> 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."
>
> [...]
Here is the summary with links:
- Revert "riscv: misaligned: fix sleeping function called during misaligned access handling"
https://git.kernel.org/riscv/c/2f73c62d4e13
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-06-24 0:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-06-20 11:09 [PATCH] Revert "riscv: misaligned: fix sleeping function called during misaligned access handling" Nam Cao
2025-06-20 11:23 ` Alexandre Ghiti
2025-06-20 11:52 ` Clément Léger
2025-06-24 0:50 ` patchwork-bot+linux-riscv
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®