From owner-freebsd-bugs Sat Jan 26 8:30:11 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 791EA37B404 for ; Sat, 26 Jan 2002 08:30:02 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g0QGU2w95955; Sat, 26 Jan 2002 08:30:02 -0800 (PST) (envelope-from gnats) Date: Sat, 26 Jan 2002 08:30:02 -0800 (PST) Message-Id: <200201261630.g0QGU2w95955@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: freebsd-gnats-submit@FreeBSD.ORG Cc: Dave Zarzycki Subject: Re: kern/29741: ptrace(pid);ptrace(ppid) makes pid and ppid unkillable Date: Sun, 27 Jan 2002 03:28:31 +1100 I can reproduce this problem with 4.5-RC. The problem seems to be that ptrace() allows a process to attach to its owner. I've attached a patch for both RELENG_4 and -CURRENT that seems to correct the problem. When I try to reproduce it now: tim@descent$ gdb -q (gdb) file gdb Reading symbols from gdb...(no debugging symbols found)...done. (gdb) run -q Starting program: /usr/bin/gdb -q warning: shared library handler failed to enable breakpoint Program received signal SIGTRAP, Trace/breakpoint trap. 0x2815e39c in ?? () (gdb) cont Continuing. (gdb) file gdb Reading symbols from gdb...(no debugging symbols found)...done. (gdb) attach 177 Attaching to program: /usr/bin/gdb, process 177 ptrace: Invalid argument. I'm not exactly sure what the warning is about; it was there before I mucked with ptrace. Patch for RELENG_4: Index: src/sys/kern/sys_process.c =================================================================== RCS file: /home/ncvs/src/sys/kern/sys_process.c,v retrieving revision 1.51.2.3 diff -c -r1.51.2.3 sys_process.c *** src/sys/kern/sys_process.c 2002/01/22 17:22:59 1.51.2.3 --- src/sys/kern/sys_process.c 2002/01/26 16:19:02 *************** *** 233,240 **** break; case PT_ATTACH: ! /* Self */ ! if (p->p_pid == curp->p_pid) return EINVAL; /* Already traced */ --- 233,240 ---- break; case PT_ATTACH: ! /* Self or owner */ ! if (p->p_pid == curp->p_pid || p->p_pid == curp->p_oppid) return EINVAL; /* Already traced */ Patch for -CURRENT (not tested!): Index: src/sys/kern/sys_process.c =================================================================== RCS file: /home/ncvs/src/sys/kern/sys_process.c,v retrieving revision 1.76 diff -c -r1.76 sys_process.c *** src/sys/kern/sys_process.c 2001/10/21 23:57:15 1.76 --- src/sys/kern/sys_process.c 2002/01/26 16:20:34 *************** *** 308,315 **** break; case PT_ATTACH: ! /* Self */ ! if (p->p_pid == curp->p_pid) { PROC_UNLOCK(p); return (EINVAL); } --- 308,315 ---- break; case PT_ATTACH: ! /* Self or owner */ ! if (p->p_pid == curp->p_pid || p->p_pid == curp->p_oppid) { PROC_UNLOCK(p); return (EINVAL); } Tim To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message