csky/syscall_trace: Fixup return processing flow
authorGuo Ren <ren_guo@c-sky.com>
Mon, 22 Apr 2019 06:46:44 +0000 (14:46 +0800)
committerGuo Ren <ren_guo@c-sky.com>
Mon, 22 Apr 2019 07:55:28 +0000 (15:55 +0800)
The function tracehook_report_syscall_entry's return value is
__must_check attribute. We should add return processing flow in
ptrace.c and set the syscall number to -1 when failed just like
riscv's.

Signed-off-by: Guo Ren <ren_guo@c-sky.com>
Cc: Arnd Bergmann <arnd@arndb.de>
arch/csky/include/asm/syscall.h
arch/csky/kernel/ptrace.c

index 850b694a463ee36f3f899412ceb0b6da8dd13675..8278658e74f940304f6cf143f23e74e7e580f8da 100644 (file)
@@ -16,6 +16,13 @@ syscall_get_nr(struct task_struct *task, struct pt_regs *regs)
        return regs_syscallid(regs);
 }
 
+static inline void
+syscall_set_nr(struct task_struct *task, struct pt_regs *regs,
+              int sysno)
+{
+       regs_syscallid(regs) = sysno;
+}
+
 static inline void
 syscall_rollback(struct task_struct *task, struct pt_regs *regs)
 {
index 91bc74bb569f29e153ba96c80db867c90bc99dce..313623a19ecbf6bd3c0e05ca870af9672c6039ea 100644 (file)
@@ -215,7 +215,8 @@ long arch_ptrace(struct task_struct *child, long request,
 asmlinkage void syscall_trace_enter(struct pt_regs *regs)
 {
        if (test_thread_flag(TIF_SYSCALL_TRACE))
-               tracehook_report_syscall_entry(regs);
+               if (tracehook_report_syscall_entry(regs))
+                       syscall_set_nr(current, regs, -1);
 
        if (test_thread_flag(TIF_SYSCALL_TRACEPOINT))
                trace_sys_enter(regs, syscall_get_nr(current, regs));