From owner-freebsd-current@FreeBSD.ORG Tue Apr 15 06:22:19 2003 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id F14B437B401; Tue, 15 Apr 2003 06:22:18 -0700 (PDT) Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6EB2943FBF; Tue, 15 Apr 2003 06:22:17 -0700 (PDT) (envelope-from bde@zeta.org.au) Received: from katana.zip.com.au (katana.zip.com.au [61.8.7.246]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id XAA26453; Tue, 15 Apr 2003 23:21:59 +1000 Date: Tue, 15 Apr 2003 23:21:57 +1000 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: Marcel Moolenaar In-Reply-To: <20030414211239.GA843@athlon.pn.xcllnt.net> Message-ID: <20030415231559.J1029@gamplex.bde.org> References: <20030414211239.GA843@athlon.pn.xcllnt.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: current@freebsd.org Subject: Re: Bug in rev 1.3 of sys/i386/linux/linux_ptrace.c X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Apr 2003 13:22:19 -0000 On Mon, 14 Apr 2003, Marcel Moolenaar wrote: > On Mon, Apr 14, 2003 at 04:12:06PM -0400, John Baldwin wrote: > > In the linux_ptrace() function there is the following code: > *snip* > > /* not currently stopped */ > > if ((p->p_flag & (P_TRACED|P_WAITED)) == 0) { > > error = EBUSY; > > goto fail; > > } > > > > ... > > > > Now, since we've already checked P_TRACED above, this last > > check will never fail. The diff in rev 1.3 was: > > > > - if (p->p_stat != SSTOP || (p->p_flag & P_WAITED) == 0) { > > + if ((p->p_flag & (P_TRACED|P_WAITED)) == 0) { > > > > So should this be (P_STOPPED|P_WAITED) instead? Or maybe just > > (P_STOPPED_TRACE|P_WAITED)? > > I don't know the difference between P_STOPPED and P_STOPPED_TRACE > but yes, we should check whether the process is stopped. The > equivalent in sys/kern/sys_process.c is: > > if (!P_SHOULDSTOP(p) || (p->p_flag & P_WAITED) == 0) { > > P_SHOULDSTOP(p) expands to: > > ((p)->p_flag & P_STOPPED) > > Using P_STOPPED makes us bug-for-bug compatible... Isn't it, er, terrific to have not completelty trivial signal and ptrace code rotting differently in 1 + ${N_ARCH} * ${N_COMPAT} places ;-). Bruce