Add TIF_FD_SLOTS and test it together with the other syscall exit work on the way out of a system call. A task that reserved descriptors calls syscall_trace() on sparc32 and syscall_trace_leave() on sparc64. Signed-off-by: Christian Brauner (Amutable) --- arch/sparc/include/asm/thread_info_32.h | 2 ++ arch/sparc/include/asm/thread_info_64.h | 9 ++++++++- arch/sparc/kernel/entry.S | 2 +- arch/sparc/kernel/ptrace_32.c | 4 ++++ arch/sparc/kernel/ptrace_64.c | 4 ++++ arch/sparc/kernel/syscalls.S | 4 +++- 6 files changed, 22 insertions(+), 3 deletions(-) diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h index fdaf7b171e0a..fbd7af6bb427 100644 --- a/arch/sparc/include/asm/thread_info_32.h +++ b/arch/sparc/include/asm/thread_info_32.h @@ -105,6 +105,7 @@ register struct thread_info *current_thread_info_reg asm("g6"); #define TIF_NEED_RESCHED 3 /* rescheduling necessary */ #define TIF_RESTORE_SIGMASK 4 /* restore signal mask in do_signal() */ #define TIF_NOTIFY_SIGNAL 5 /* signal notifications exist */ +#define TIF_FD_SLOTS 6 /* syscall prepared descriptors */ #define TIF_USEDFPU 8 /* FPU was used by this task * this quantum (SMP) */ #define TIF_POLLING_NRFLAG 9 /* true if poll_idle() is polling @@ -117,6 +118,7 @@ register struct thread_info *current_thread_info_reg asm("g6"); #define _TIF_SIGPENDING (1< +#include #include #include #include @@ -437,6 +438,9 @@ asmlinkage int syscall_trace(struct pt_regs *regs, int syscall_exit_p) { int ret = 0; + if (syscall_exit_p && test_thread_flag(TIF_FD_SLOTS)) + fd_slots_commit(regs); + if (test_thread_flag(TIF_SYSCALL_TRACE)) { if (syscall_exit_p) ptrace_report_syscall_exit(regs, 0); diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c index 825ddf55fece..499b30c505fd 100644 --- a/arch/sparc/kernel/ptrace_64.c +++ b/arch/sparc/kernel/ptrace_64.c @@ -12,6 +12,7 @@ */ #include +#include #include #include #include @@ -1110,6 +1111,9 @@ asmlinkage void syscall_trace_leave(struct pt_regs *regs) if (test_thread_flag(TIF_NOHZ)) user_exit(); + if (test_thread_flag(TIF_FD_SLOTS)) + fd_slots_commit(regs); + audit_syscall_exit(regs); if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT))) diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S index 96fe8763d70c..086fb8eaf133 100644 --- a/arch/sparc/kernel/syscalls.S +++ b/arch/sparc/kernel/syscalls.S @@ -269,10 +269,12 @@ ret_sys_call: ldx [%sp + PTREGS_OFF + PT_V9_TSTATE], %g3 mov %ulo(TSTATE_XCARRY | TSTATE_ICARRY), %g2 sllx %g2, 32, %g2 + /* Reload the flags, the syscall may have set TIF_FD_SLOTS. */ + ldx [%g6 + TI_FLAGS], %l0 cmp %o0, -ERESTART_RESTARTBLOCK bgeu,pn %xcc, 1f - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT|_TIF_NOHZ), %g0 + andcc %l0, _TIF_SYSCALL_EXIT_WORK, %g0 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc 2: -- 2.53.0