This prepares for changing the return types of
syscall_enter_from_user_mode[_work]() to bool, which in turn separates the
decision of invoking the syscall from the syscall number, which might have
been changed in the call by ptrace, seccomp, tracing.

Signed-off-by: Thomas Gleixner <[email protected]>
---
 include/linux/entry-common.h |   28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)

--- a/include/linux/entry-common.h
+++ b/include/linux/entry-common.h
@@ -71,8 +71,8 @@ static inline void syscall_enter_audit(s
        }
 }
 
-static __always_inline long syscall_trace_enter(struct pt_regs *regs, unsigned 
long work,
-                                               long syscall)
+static __always_inline bool syscall_trace_enter(struct pt_regs *regs, unsigned 
long work,
+                                               long *syscall)
 {
        /*
         * Handle Syscall User Dispatch.  This must comes first, since
@@ -81,7 +81,7 @@ static __always_inline long syscall_trac
         */
        if (work & SYSCALL_WORK_SYSCALL_USER_DISPATCH) {
                if (syscall_user_dispatch(regs))
-                       return -1L;
+                       return false;
        }
 
        /*
@@ -90,32 +90,32 @@ static __always_inline long syscall_trac
         * through hrtimer_interrupt().
         */
        if (work & SYSCALL_WORK_SYSCALL_RSEQ_SLICE)
-               rseq_syscall_enter_work(syscall);
+               rseq_syscall_enter_work(*syscall);
 
        /* Handle ptrace */
        if (work & (SYSCALL_WORK_SYSCALL_TRACE | SYSCALL_WORK_SYSCALL_EMU)) {
                if (!arch_ptrace_report_syscall_permit_entry(regs) ||
                    (work & SYSCALL_WORK_SYSCALL_EMU))
-                       return -1L;
+                       return false;
        }
 
        /* Do seccomp after ptrace, to catch any tracer changes. */
        if (work & SYSCALL_WORK_SECCOMP) {
                if (!__seccomp_permit_syscall())
-                       return -1L;
+                       return false;
        }
 
        /* Either of the above might have changed the syscall number */
-       syscall = syscall_get_nr(current, regs);
+       *syscall = syscall_get_nr(current, regs);
 
        if (unlikely(work & SYSCALL_WORK_SYSCALL_TRACEPOINT)) {
-               if (!trace_syscall_enter(regs, &syscall))
-                       return -1L;
+               if (!trace_syscall_enter(regs, syscall))
+                       return false;
        }
 
-       syscall_enter_audit(regs, syscall);
+       syscall_enter_audit(regs, *syscall);
 
-       return syscall;
+       return true;
 }
 
 /**
@@ -145,8 +145,10 @@ static __always_inline long syscall_ente
 {
        unsigned long work = READ_ONCE(current_thread_info()->syscall_work);
 
-       if (work & SYSCALL_WORK_ENTER)
-               syscall = syscall_trace_enter(regs, work, syscall);
+       if (work & SYSCALL_WORK_ENTER) {
+               if (!syscall_trace_enter(regs, work, &syscall))
+                       return -1L;
+       }
 
        return syscall;
 }


Reply via email to