Pass addr=0 instead of 1 into restarting ptrace calls
While we are at it, fold do_ptrace into its lone caller. We no longer set tcp->ptrace_errno = ESRCH on ESRC error in upeek. Other code paths where ptrace fails wern't doing it, and the code which checks tcp->ptrace_errno even assumes it is never set to ESRCH. (It was me who added this code sometime ago, so it was my fault that it was a bit messy) I ran sigkill_rain test and verified that unfinished syscalls are still handled correctly. * util.c (ptrace_restart): Do not pass addr=1 to ptrace(), pass 0 instead. I have no idea why we were passing 1. Ptrace documentation says that addr parameter is ignored. (do_ptrace): Remove this function. (upeek): Use ptrace() instead of do_ptrace(). * defs.h: Remove do_ptrace() declaration. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
4c65c44478
commit
114aefd618
1
defs.h
1
defs.h
@ -466,7 +466,6 @@ extern void droptcb(struct tcb *);
|
||||
extern void set_sortby(const char *);
|
||||
extern void set_overhead(int);
|
||||
extern void qualify(const char *);
|
||||
extern long do_ptrace(int request, struct tcb *tcp, void *addr, void *data);
|
||||
extern int ptrace_restart(int request, struct tcb *tcp, int sig);
|
||||
extern int trace_syscall(struct tcb *);
|
||||
extern void count_syscall(struct tcb *, struct timeval *);
|
||||
|
31
util.c
31
util.c
@ -165,31 +165,6 @@ stpcpy(char *dst, const char *src)
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Generic ptrace wrapper which tracks ESRCH errors
|
||||
* by setting tcp->ptrace_errno to ESRCH.
|
||||
*
|
||||
* We assume that ESRCH indicates likely process death (SIGKILL?),
|
||||
* modulo bugs where process somehow ended up not stopped.
|
||||
* Unfortunately kernel uses ESRCH for that case too. Oh well.
|
||||
*
|
||||
* Currently used by upeek() only.
|
||||
* TODO: use this in all other ptrace() calls while decoding.
|
||||
*/
|
||||
long
|
||||
do_ptrace(int request, struct tcb *tcp, void *addr, void *data)
|
||||
{
|
||||
long l;
|
||||
|
||||
errno = 0;
|
||||
l = ptrace(request, tcp->pid, addr, (long) data);
|
||||
/* Non-ESRCH errors might be our invalid reg/mem accesses,
|
||||
* we do not record them. */
|
||||
if (errno == ESRCH)
|
||||
tcp->ptrace_errno = ESRCH;
|
||||
return l;
|
||||
}
|
||||
|
||||
/*
|
||||
* Used when we want to unblock stopped traced process.
|
||||
* Should be only used with PTRACE_CONT, PTRACE_DETACH and PTRACE_SYSCALL.
|
||||
@ -204,7 +179,7 @@ ptrace_restart(int op, struct tcb *tcp, int sig)
|
||||
const char *msg;
|
||||
|
||||
errno = 0;
|
||||
ptrace(op, tcp->pid, (void *) 1, (long) sig);
|
||||
ptrace(op, tcp->pid, (void *) 0, (long) sig);
|
||||
err = errno;
|
||||
if (!err || err == ESRCH)
|
||||
return 0;
|
||||
@ -219,7 +194,7 @@ ptrace_restart(int op, struct tcb *tcp, int sig)
|
||||
if (op == PTRACE_LISTEN)
|
||||
msg = "LISTEN";
|
||||
#endif
|
||||
perror_msg("ptrace(PTRACE_%s,pid:%d,1,sig:%d)", msg, tcp->pid, sig);
|
||||
perror_msg("ptrace(PTRACE_%s,pid:%d,sig:%d)", msg, tcp->pid, sig);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1011,7 +986,7 @@ upeek(struct tcb *tcp, long off, long *res)
|
||||
long val;
|
||||
|
||||
errno = 0;
|
||||
val = do_ptrace(PTRACE_PEEKUSER, tcp, (char *) off, 0);
|
||||
val = ptrace(PTRACE_PEEKUSER, tcp->pid, (char *) off, 0);
|
||||
if (val == -1 && errno) {
|
||||
if (errno != ESRCH) {
|
||||
perror_msg("upeek: PTRACE_PEEKUSER pid:%d @0x%lx)", tcp->pid, off);
|
||||
|
Loading…
x
Reference in New Issue
Block a user