Add TIF_FD_SLOTS and test it where the syscall return path decides between the syscall work and the plain work pending slow path. A task that reserved descriptors goes through __sys_trace_return_nosave where syscall_trace_exit() commits them before audit and the ptrace exit stop. The traced path already ends up there.
Signed-off-by: Christian Brauner (Amutable) <[email protected]> --- arch/arm/include/asm/thread_info.h | 2 ++ arch/arm/kernel/entry-common.S | 2 ++ arch/arm/kernel/ptrace.c | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h index 943ffcf069d2..5337449e8409 100644 --- a/arch/arm/include/asm/thread_info.h +++ b/arch/arm/include/asm/thread_info.h @@ -144,6 +144,7 @@ extern int vfp_restore_user_hwstate(struct user_vfp *, #define TIF_NOTIFY_RESUME 2 /* callback before returning to user */ #define TIF_UPROBE 3 /* breakpointed or singlestepping */ #define TIF_NOTIFY_SIGNAL 4 /* signal notifications exist */ +#define TIF_FD_SLOTS 5 /* syscall prepared descriptors, entry-common.S needs it below 16 */ #define TIF_USING_IWMMXT 17 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */ @@ -163,6 +164,7 @@ extern int vfp_restore_user_hwstate(struct user_vfp *, #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT) #define _TIF_SECCOMP (1 << TIF_SECCOMP) #define _TIF_NOTIFY_SIGNAL (1 << TIF_NOTIFY_SIGNAL) +#define _TIF_FD_SLOTS (1 << TIF_FD_SLOTS) #define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT) /* Checks for any syscall work in entry-common.S */ diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S index 88336a1292bb..59a70d90b0b6 100644 --- a/arch/arm/kernel/entry-common.S +++ b/arch/arm/kernel/entry-common.S @@ -83,6 +83,8 @@ ENDPROC(ret_fast_syscall) tst r1, #_TIF_SYSCALL_WORK bne __sys_trace_return_nosave + tst r1, #(_TIF_FD_SLOTS << 16) @ r1 holds TI_FLAGS << 16 + bne __sys_trace_return_nosave slow_work_pending: mov r0, sp @ 'regs' mov r2, why @ 'syscall' diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c index ed7a2a87a670..75fe26012fcb 100644 --- a/arch/arm/kernel/ptrace.c +++ b/arch/arm/kernel/ptrace.c @@ -11,6 +11,7 @@ #include <linux/sched/task_stack.h> #include <linux/mm.h> #include <linux/elf.h> +#include <linux/file.h> #include <linux/smp.h> #include <linux/ptrace.h> #include <linux/user.h> @@ -876,6 +877,9 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs) asmlinkage void syscall_trace_exit(struct pt_regs *regs) { + if (test_thread_flag(TIF_FD_SLOTS)) + fd_slots_commit(regs); + /* * Audit the syscall before anything else, as a debugger may * come in and change the current registers. -- 2.53.0
