Add TIF_FD_SLOTS to the syscall work mask. syscall_exit rereads the flags after the system call and goes to syscall_exit_work for any bit in the all-work mask, but hands over a copy shifted right by eight when the bit was in the upper byte. Reload the flags there and test the full mask, so that the bit reaches do_syscall_trace_leave(). Signed-off-by: Christian Brauner (Amutable) --- arch/sh/include/asm/thread_info.h | 10 +++++++--- arch/sh/kernel/entry-common.S | 8 ++++++-- arch/sh/kernel/ptrace_32.c | 4 ++++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/arch/sh/include/asm/thread_info.h b/arch/sh/include/asm/thread_info.h index 471db5173036..d976cf21f346 100644 --- a/arch/sh/include/asm/thread_info.h +++ b/arch/sh/include/asm/thread_info.h @@ -106,6 +106,7 @@ extern void init_thread_xstate(void); #define TIF_SECCOMP 6 /* secure computing */ #define TIF_NOTIFY_RESUME 7 /* callback before returning to user */ #define TIF_SYSCALL_TRACEPOINT 8 /* for ftrace syscall instrumentation */ +#define TIF_FD_SLOTS 9 /* syscall prepared descriptors */ #define TIF_POLLING_NRFLAG 17 /* true if poll_idle() is polling TIF_NEED_RESCHED */ #define TIF_MEMDIE 18 /* is terminating due to OOM killer */ @@ -118,22 +119,25 @@ extern void init_thread_xstate(void); #define _TIF_SECCOMP (1 << TIF_SECCOMP) #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME) #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT) +#define _TIF_FD_SLOTS (1 << TIF_FD_SLOTS) #define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG) /* work to do in syscall trace */ #define _TIF_WORK_SYSCALL_MASK (_TIF_SYSCALL_TRACE | _TIF_SINGLESTEP | \ _TIF_SYSCALL_AUDIT | _TIF_SECCOMP | \ - _TIF_SYSCALL_TRACEPOINT) + _TIF_SYSCALL_TRACEPOINT | _TIF_FD_SLOTS) /* work to do on any return to u-space */ #define _TIF_ALLWORK_MASK (_TIF_SYSCALL_TRACE | _TIF_SIGPENDING | \ _TIF_NEED_RESCHED | _TIF_SYSCALL_AUDIT | \ _TIF_SINGLESTEP | _TIF_NOTIFY_RESUME | \ - _TIF_SYSCALL_TRACEPOINT | _TIF_NOTIFY_SIGNAL) + _TIF_SYSCALL_TRACEPOINT | _TIF_NOTIFY_SIGNAL | \ + _TIF_FD_SLOTS) /* work to do on interrupt/exception return */ #define _TIF_WORK_MASK (_TIF_ALLWORK_MASK & ~(_TIF_SYSCALL_TRACE | \ - _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP)) + _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \ + _TIF_FD_SLOTS)) /* * Thread-synchronous status. diff --git a/arch/sh/kernel/entry-common.S b/arch/sh/kernel/entry-common.S index 91ab2607a1ff..593a482e85f5 100644 --- a/arch/sh/kernel/entry-common.S +++ b/arch/sh/kernel/entry-common.S @@ -164,9 +164,13 @@ work_resched: .align 2 syscall_exit_work: - ! r0: current_thread_info->flags ! r8: current_thread_info - tst #(_TIF_WORK_SYSCALL_MASK & 0xff), r0 + mov.l @(TI_FLAGS,r8), r0 ! current_thread_info->flags + mov #(_TIF_WORK_SYSCALL_MASK & 0xff), r1 + mov #(_TIF_WORK_SYSCALL_MASK >> 8), r2 + shll8 r2 + or r2, r1 + tst r1, r0 bt/s work_pending tst #_TIF_NEED_RESCHED, r0 TRACE_IRQS_ON diff --git a/arch/sh/kernel/ptrace_32.c b/arch/sh/kernel/ptrace_32.c index 8794081483fb..3deadd71f464 100644 --- a/arch/sh/kernel/ptrace_32.c +++ b/arch/sh/kernel/ptrace_32.c @@ -8,6 +8,7 @@ * Audit support by Yuichi Nakamura */ #include +#include #include #include #include @@ -476,6 +477,9 @@ asmlinkage void do_syscall_trace_leave(struct pt_regs *regs) { int step; + if (test_thread_flag(TIF_FD_SLOTS)) + fd_slots_commit(regs); + audit_syscall_exit(regs); if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT))) -- 2.53.0