Bug in ptrace

utzoo!utcsrgv!garfield!andrew utzoo!utcsrgv!garfield!andrew
Sat Apr 23 02:57:16 AEST 1983


     We have recently stumbled across a minor bug involving  the  ptrace  system
call.   When  ptrace  is  called  from  the parent, but the child has not called
ptrace(0), the system tries to get  information  from  the  child  anyway.   The
parent  sleeps  while  waiting for this information, which is never forthcoming.
This effectively ties up the ptrace facility and all other  processes  (ie.  sdb
adb)  using  ptrace  will sleep forever.  The sleeping priority can soon becomes
negative and then even "kill" cannot interrupt the slumbers of these processes.

     Fortunately, this can be easily fixed by checking to see if  the  child  is
being  traced before actually doing the ptrace request.  For 4.1bsd, change line
615 in "sys/sig.c" from:

         if (p == 0 || p->p_stat != SSTOP || p->p_ppid != u.u_procp->p_pid) {

 to:
         if (p == 0 || p->p_stat != SSTOP || p->p_ppid != u.u_procp->p_pid
                 || !(p->p_flag & STRC)) {



More information about the Net.bugs mailing list