Date: Sat, 26 Jan 2002 08:30:02 -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: <200201261630.g0QGU2w95955@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: freebsd-gnats-submit@FreeBSD.ORG Cc: Dave Zarzycki <zarzycki@FreeBSD.ORG> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200201261630.g0QGU2w95955>