Add TIF_FD_SLOTS to the syscall exit work. The return path rereads the flags after the system call and calls syscall_trace_leave() for any of the exit work bits which commits the reservations before audit and the ptrace exit stop.
Signed-off-by: Christian Brauner (Amutable) <[email protected]> --- arch/mips/include/asm/thread_info.h | 5 ++++- arch/mips/kernel/ptrace.c | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h index 2707dad260dd..79c81696e9c1 100644 --- a/arch/mips/include/asm/thread_info.h +++ b/arch/mips/include/asm/thread_info.h @@ -114,6 +114,7 @@ register unsigned long current_stack_pointer __asm__("sp"); #define TIF_NOTIFY_RESUME 5 /* callback before returning to user */ #define TIF_UPROBE 6 /* breakpointed or singlestepping */ #define TIF_NOTIFY_SIGNAL 7 /* signal notifications exist */ +#define TIF_FD_SLOTS 8 /* syscall prepared descriptors */ #define TIF_RESTORE_SIGMASK 9 /* restore signal mask in do_signal() */ #define TIF_USEDFPU 16 /* FPU was used by this task this quantum (SMP) */ #define TIF_MEMDIE 18 /* is terminating due to OOM killer */ @@ -152,6 +153,7 @@ register unsigned long current_stack_pointer __asm__("sp"); #define _TIF_USEDMSA (1<<TIF_USEDMSA) #define _TIF_MSA_CTX_LIVE (1<<TIF_MSA_CTX_LIVE) #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT) +#define _TIF_FD_SLOTS (1<<TIF_FD_SLOTS) #define _TIF_WORK_SYSCALL_ENTRY (_TIF_NOHZ | _TIF_SYSCALL_TRACE | \ _TIF_SYSCALL_AUDIT | \ @@ -159,7 +161,8 @@ register unsigned long current_stack_pointer __asm__("sp"); /* work to do in syscall_trace_leave() */ #define _TIF_WORK_SYSCALL_EXIT (_TIF_NOHZ | _TIF_SYSCALL_TRACE | \ - _TIF_SYSCALL_AUDIT | _TIF_SYSCALL_TRACEPOINT) + _TIF_SYSCALL_AUDIT | _TIF_SYSCALL_TRACEPOINT | \ + _TIF_FD_SLOTS) /* work to do on interrupt/exception return */ #define _TIF_WORK_MASK \ diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c index 17dc7249b8ca..d68eab59bcc2 100644 --- a/arch/mips/kernel/ptrace.c +++ b/arch/mips/kernel/ptrace.c @@ -17,6 +17,7 @@ #include <linux/compiler.h> #include <linux/context_tracking.h> #include <linux/elf.h> +#include <linux/file.h> #include <linux/kernel.h> #include <linux/sched.h> #include <linux/sched/task_stack.h> @@ -1364,6 +1365,9 @@ asmlinkage void syscall_trace_leave(struct pt_regs *regs) */ 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))) -- 2.53.0
