From owner-freebsd-bugs Wed Feb 6 7:20: 9 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 64C1A37B423 for ; Wed, 6 Feb 2002 07:20:03 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g16FK3t28746; Wed, 6 Feb 2002 07:20:03 -0800 (PST) (envelope-from gnats) Date: Wed, 6 Feb 2002 07:20:03 -0800 (PST) Message-Id: <200202061520.g16FK3t28746@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: "Tim J. Robbins" Subject: Re: kern/29741: ptrace(pid);ptrace(ppid) makes pid and ppid unkillable Reply-To: "Tim J. Robbins" Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org The following reply was made to PR kern/29741; it has been noted by GNATS. From: "Tim J. Robbins" To: Dave Zarzycki 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