PTRACE_SEIZE can set ptrace options immediately, use this feature
This eliminates some rare bugs, such as post-execve SIGTRAP generation when we attach to a process, and it manages to finish execve'ing before we set TRACEEXEC option to suppress that. Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
This commit is contained in:
parent
7c41ce2878
commit
c169d94718
10
strace.c
10
strace.c
@ -335,11 +335,11 @@ ptrace_attach_or_seize(int pid)
|
||||
{
|
||||
int r;
|
||||
if (!use_seize)
|
||||
return ptrace(PTRACE_ATTACH, pid, 0, 0);
|
||||
r = ptrace(PTRACE_SEIZE, pid, 0, 0);
|
||||
return ptrace(PTRACE_ATTACH, pid, 0L, 0L);
|
||||
r = ptrace(PTRACE_SEIZE, pid, 0L, (unsigned long)ptrace_setoptions);
|
||||
if (r)
|
||||
return r;
|
||||
r = ptrace(PTRACE_INTERRUPT, pid, 0, 0);
|
||||
r = ptrace(PTRACE_INTERRUPT, pid, 0L, 0L);
|
||||
return r;
|
||||
}
|
||||
#else
|
||||
@ -2224,9 +2224,9 @@ trace(void)
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (ptrace_setoptions) {
|
||||
if (!use_seize && ptrace_setoptions) {
|
||||
if (debug_flag)
|
||||
fprintf(stderr, "setting opts %x on pid %d\n", ptrace_setoptions, tcp->pid);
|
||||
fprintf(stderr, "setting opts 0x%x on pid %d\n", ptrace_setoptions, tcp->pid);
|
||||
if (ptrace(PTRACE_SETOPTIONS, tcp->pid, NULL, ptrace_setoptions) < 0) {
|
||||
if (errno != ESRCH) {
|
||||
/* Should never happen, really */
|
||||
|
Loading…
x
Reference in New Issue
Block a user