Skip to content

Commit

Permalink
nios2: traced syscall does need to check the syscall number
Browse files Browse the repository at this point in the history
all checks done before letting the tracer modify the register
state are worthless...

Fixes: 82ed08d ("nios2: Exception handling")
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Dinh Nguyen <dinguyen@kernel.org>
  • Loading branch information
Al Viro authored and Dinh Nguyen committed Aug 15, 2022
1 parent 45ec746 commit 25ba820
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions arch/nios2/kernel/entry.S
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,9 @@ traced_system_call:
ldw r6, PT_R6(sp)
ldw r7, PT_R7(sp)

/* Fetch the syscall function, we don't need to check the boundaries
* since this is already done.
*/
/* Fetch the syscall function. */
movui r1, __NR_syscalls
bgeu r2, r1, traced_invsyscall
slli r1, r2, 2
movhi r11,%hiadj(sys_call_table)
add r1, r1, r11
Expand Down Expand Up @@ -287,6 +287,11 @@ end_translate_rc_and_ret2:
RESTORE_SWITCH_STACK
br ret_from_exception

/* If the syscall number was invalid return ENOSYS */
traced_invsyscall:
movi r2, -ENOSYS
br translate_rc_and_ret2

Luser_return:
GET_THREAD_INFO r11 /* get thread_info pointer */
ldw r10, TI_FLAGS(r11) /* get thread_info->flags */
Expand Down

0 comments on commit 25ba820

Please sign in to comment.