Date: Wed, 6 Feb 2002 07:20:03 -0800 (PST) From: "Tim J. Robbins" <tim@robbins.dropbear.id.au> To: freebsd-bugs@FreeBSD.org Subject: Re: kern/29741: ptrace(pid);ptrace(ppid) makes pid and ppid unkillable Message-ID: <200202061520.g16FK3t28746@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR kern/29741; it has been noted by GNATS. From: "Tim J. Robbins" <tim@robbins.dropbear.id.au> To: Dave Zarzycki <zarzycki@FreeBSD.org> Cc: freebsd-gnats-submit@FreeBSD.org Subject: Re: kern/29741: ptrace(pid);ptrace(ppid) makes pid and ppid unkillable Date: Thu, 7 Feb 2002 02:10:26 +1100 This patch (against RELENG_4) does solve the gdb -> gdb -> gdb -> grandparent problem. I don't think the "if (curp->p_flag & P_TRACED)" bit is even necessary at all; ptrace()'ing an ancestor seems like a bad idea to me, regardless of whether you're being traced or not. --- sys_process.c.old Thu Feb 7 00:05:09 2002 +++ sys_process.c Thu Feb 7 01:27:36 2002 @@ -203,7 +203,7 @@ struct proc *curp; struct ptrace_args *uap; { - struct proc *p; + struct proc *p, *pp; struct iovec iov; struct uio uio; int error = 0; @@ -240,6 +240,12 @@ /* Already traced */ if (p->p_flag & P_TRACED) return EBUSY; + + /* Can't trace an ancestor if you're being traced */ + if (curp->p_flag & P_TRACED) + for (pp = curp->p_pptr; pp != NULL; pp = pp->p_pptr) + if (pp == p) + return EINVAL; /* not owned by you, has done setuid (unless you're root) */ if ((p->p_cred->p_ruid != curp->p_cred->p_ruid) || Tim To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200202061520.g16FK3t28746>