Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ptrace: Remove the unnecessary arguments from arch_ptrace_stop

Both arch_ptrace_stop_needed and arch_ptrace_stop are called with an
exit_code and a siginfo structure. Neither argument is used by any of
the implementations so just remove the unneeded arguments.

The two arechitectures that implement arch_ptrace_stop are ia64 and
sparc. Both architectures flush their register stacks before a
ptrace_stack so that all of the register information can be accessed
by debuggers.

As the question of if a register stack needs to be flushed is
independent of why ptrace is stopping not needing arguments make sense.

Cc: David Miller <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org
Link: https://lkml.kernel.org/r/87lf3mx290.fsf@disp2133
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>

+17 -21
+2 -2
arch/ia64/include/asm/ptrace.h
··· 129 129 extern void ia64_decrement_ip (struct pt_regs *pt); 130 130 131 131 extern void ia64_ptrace_stop(void); 132 - #define arch_ptrace_stop(code, info) \ 132 + #define arch_ptrace_stop() \ 133 133 ia64_ptrace_stop() 134 - #define arch_ptrace_stop_needed(code, info) \ 134 + #define arch_ptrace_stop_needed() \ 135 135 (!test_thread_flag(TIF_RESTORE_RSE)) 136 136 137 137 extern void ptrace_attach_sync_user_rbs (struct task_struct *);
+4 -4
arch/sparc/include/asm/ptrace.h
··· 26 26 return (regs->tstate &= ~TSTATE_SYSCALL); 27 27 } 28 28 29 - #define arch_ptrace_stop_needed(exit_code, info) \ 29 + #define arch_ptrace_stop_needed() \ 30 30 ({ flush_user_windows(); \ 31 31 get_thread_wsaved() != 0; \ 32 32 }) 33 33 34 - #define arch_ptrace_stop(exit_code, info) \ 34 + #define arch_ptrace_stop() \ 35 35 synchronize_user_stack() 36 36 37 37 #define current_pt_regs() \ ··· 129 129 return (regs->psr &= ~PSR_SYSCALL); 130 130 } 131 131 132 - #define arch_ptrace_stop_needed(exit_code, info) \ 132 + #define arch_ptrace_stop_needed() \ 133 133 ({ flush_user_windows(); \ 134 134 current_thread_info()->w_saved != 0; \ 135 135 }) 136 136 137 - #define arch_ptrace_stop(exit_code, info) \ 137 + #define arch_ptrace_stop() \ 138 138 synchronize_user_stack() 139 139 140 140 #define current_pt_regs() \
+9 -13
include/linux/ptrace.h
··· 362 362 #ifndef arch_ptrace_stop_needed 363 363 /** 364 364 * arch_ptrace_stop_needed - Decide whether arch_ptrace_stop() should be called 365 - * @code: current->exit_code value ptrace will stop with 366 - * @info: siginfo_t pointer (or %NULL) for signal ptrace will stop with 367 365 * 368 366 * This is called with the siglock held, to decide whether or not it's 369 - * necessary to release the siglock and call arch_ptrace_stop() with the 370 - * same @code and @info arguments. It can be defined to a constant if 371 - * arch_ptrace_stop() is never required, or always is. On machines where 372 - * this makes sense, it should be defined to a quick test to optimize out 373 - * calling arch_ptrace_stop() when it would be superfluous. For example, 374 - * if the thread has not been back to user mode since the last stop, the 375 - * thread state might indicate that nothing needs to be done. 367 + * necessary to release the siglock and call arch_ptrace_stop(). It can be 368 + * defined to a constant if arch_ptrace_stop() is never required, or always 369 + * is. On machines where this makes sense, it should be defined to a quick 370 + * test to optimize out calling arch_ptrace_stop() when it would be 371 + * superfluous. For example, if the thread has not been back to user mode 372 + * since the last stop, the thread state might indicate that nothing needs 373 + * to be done. 376 374 * 377 375 * This is guaranteed to be invoked once before a task stops for ptrace and 378 376 * may include arch-specific operations necessary prior to a ptrace stop. 379 377 */ 380 - #define arch_ptrace_stop_needed(code, info) (0) 378 + #define arch_ptrace_stop_needed() (0) 381 379 #endif 382 380 383 381 #ifndef arch_ptrace_stop 384 382 /** 385 383 * arch_ptrace_stop - Do machine-specific work before stopping for ptrace 386 - * @code: current->exit_code value ptrace will stop with 387 - * @info: siginfo_t pointer (or %NULL) for signal ptrace will stop with 388 384 * 389 385 * This is called with no locks held when arch_ptrace_stop_needed() has 390 386 * just returned nonzero. It is allowed to block, e.g. for user memory ··· 390 394 * we only do it when the arch requires it for this particular stop, as 391 395 * indicated by arch_ptrace_stop_needed(). 392 396 */ 393 - #define arch_ptrace_stop(code, info) do { } while (0) 397 + #define arch_ptrace_stop() do { } while (0) 394 398 #endif 395 399 396 400 #ifndef current_pt_regs
+2 -2
kernel/signal.c
··· 2200 2200 { 2201 2201 bool gstop_done = false; 2202 2202 2203 - if (arch_ptrace_stop_needed(exit_code, info)) { 2203 + if (arch_ptrace_stop_needed()) { 2204 2204 /* 2205 2205 * The arch code has something special to do before a 2206 2206 * ptrace stop. This is allowed to block, e.g. for faults ··· 2210 2210 * any signal bookkeeping like checking group_stop_count. 2211 2211 */ 2212 2212 spin_unlock_irq(&current->sighand->siglock); 2213 - arch_ptrace_stop(exit_code, info); 2213 + arch_ptrace_stop(); 2214 2214 spin_lock_irq(&current->sighand->siglock); 2215 2215 } 2216 2216