From owner-freebsd-current@FreeBSD.ORG Mon Apr 14 14:12:48 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 CA49F37B401; Mon, 14 Apr 2003 14:12:48 -0700 (PDT) Received: from ns1.xcllnt.net (209-128-86-226.BAYAREA.NET [209.128.86.226]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5B94F43F75; Mon, 14 Apr 2003 14:12:47 -0700 (PDT) (envelope-from marcel@xcllnt.net) Received: from athlon.pn.xcllnt.net (athlon.pn.xcllnt.net [192.168.4.3]) by ns1.xcllnt.net (8.12.9/8.12.9) with ESMTP id h3ELClwk044180; Mon, 14 Apr 2003 14:12:47 -0700 (PDT) (envelope-from marcel@piii.pn.xcllnt.net) Received: from athlon.pn.xcllnt.net (localhost [127.0.0.1]) by athlon.pn.xcllnt.net (8.12.9/8.12.9) with ESMTP id h3ELChGN000920; Mon, 14 Apr 2003 14:12:43 -0700 (PDT) (envelope-from marcel@athlon.pn.xcllnt.net) Received: (from marcel@localhost) by athlon.pn.xcllnt.net (8.12.9/8.12.9/Submit) id h3ELCd2s000919; Mon, 14 Apr 2003 14:12:39 -0700 (PDT) (envelope-from marcel) Date: Mon, 14 Apr 2003 14:12:39 -0700 From: Marcel Moolenaar To: John Baldwin Message-ID: <20030414211239.GA843@athlon.pn.xcllnt.net> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.3i cc: julian@FreeBSD.org 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: Mon, 14 Apr 2003 21:12:49 -0000 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... -- Marcel Moolenaar USPA: A-39004 marcel@xcllnt.net