lkml.org 
[lkml]   [2022]   [May]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] signal/ptrace: Fix the bug of ptrace attach and signal handling concurrency
Hi Shuzhi,

On 05/01, Shuzhi Zu wrote:
>
> Example 1:
> A B
> get_signal
> dequeue_signal (SIGCHLD)
> ptrace_attach ( A->ptrace |= PT_PTRACED)
>
> ptrace_signal
> ->ptrace_stop(TASK_TRACED)
> ptrace_attach ( Send SIGSTOP to A)
> ptrace_waitpid( return 0)
> ptrace_detach (A->ptrace=0, wakeup A)
> dequeue_signal(SIGSTOP)
> sig_kernel_stop(SIGSTOP)
> do_signal_stop (TASK_STOPPED)
>
> then:
> A (other threads of the process received signal)
> get_signal-> do_signal_stop(0))->TASK_STOPPED

Yes, there are a lot of known problems with send_sig_info(SIGSTOP) in
ptrace_attach(). This one of the reasons for PTRACE_SEIZE which doesn't
abuse SIGSTOP. Please use it instead of PTRACE_ATTACH, PTRACE_SEIZE has
more features.


As for your particular example, this is an application bug. Debugger (if
it uses PTRACE_ATTACH) should not detach until the tracee reports SIGSTOP
sent by PTRACE_ATTACH.

This can lead to other problems, say we can miss a "real" SIGSTOP from
another application, but again PTRACE_ATTACH is hopeless wrt SIGSTOP,
please consider PTRACE_SEIZE.

Oleg.

\
 
 \ /
  Last update: 2022-05-02 11:08    [W:0.031 / U:0.180 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site