Patch "riscv: entry: always initialize regs->a0 to -ENOSYS" has been added to the 6.6-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    riscv: entry: always initialize regs->a0 to -ENOSYS

to the 6.6-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     riscv-entry-always-initialize-regs-a0-to-enosys.patch
and it can be found in the queue-6.6 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 2655116dd112d497ae6c72bc4916b575a491880a
Author: Celeste Liu <coelacanthushex@xxxxxxxxx>
Date:   Thu Jun 27 22:23:39 2024 +0800

    riscv: entry: always initialize regs->a0 to -ENOSYS
    
    [ Upstream commit 61119394631f219e23ce98bcc3eb993a64a8ea64 ]
    
    Otherwise when the tracer changes syscall number to -1, the kernel fails
    to initialize a0 with -ENOSYS and subsequently fails to return the error
    code of the failed syscall to userspace. For example, it will break
    strace syscall tampering.
    
    Fixes: 52449c17bdd1 ("riscv: entry: set a0 = -ENOSYS only when syscall != -1")
    Reported-by: "Dmitry V. Levin" <ldv@xxxxxxxxx>
    Reviewed-by: Björn Töpel <bjorn@xxxxxxxxxxxx>
    Cc: stable@xxxxxxxxxxxxxxx
    Signed-off-by: Celeste Liu <CoelacanthusHex@xxxxxxxxx>
    Link: https://lore.kernel.org/r/20240627142338.5114-2-CoelacanthusHex@xxxxxxxxx
    Signed-off-by: Palmer Dabbelt <palmer@xxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c
index 67d0073fb624d..2158b7a65d74f 100644
--- a/arch/riscv/kernel/traps.c
+++ b/arch/riscv/kernel/traps.c
@@ -311,6 +311,7 @@ asmlinkage __visible __trap_section void do_trap_ecall_u(struct pt_regs *regs)
 
 		regs->epc += 4;
 		regs->orig_a0 = regs->a0;
+		regs->a0 = -ENOSYS;
 
 		riscv_v_vstate_discard(regs);
 
@@ -318,8 +319,6 @@ asmlinkage __visible __trap_section void do_trap_ecall_u(struct pt_regs *regs)
 
 		if (syscall >= 0 && syscall < NR_syscalls)
 			syscall_handler(regs, syscall);
-		else if (syscall != -1)
-			regs->a0 = -ENOSYS;
 
 		syscall_exit_to_user_mode(regs);
 	} else {




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux