From owner-svn-src-head@FreeBSD.ORG Tue Aug 26 21:39:43 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B8135A6B for ; Tue, 26 Aug 2014 21:39:43 +0000 (UTC) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 96A02315F for ; Tue, 26 Aug 2014 21:39:43 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.9/8.14.9) with ESMTP id s7QLdhfW014230 for ; Tue, 26 Aug 2014 21:39:43 GMT (envelope-from bdrewery@freefall.freebsd.org) Received: (from bdrewery@localhost) by freefall.freebsd.org (8.14.9/8.14.9/Submit) id s7QLdhgJ014224 for svn-src-head@freebsd.org; Tue, 26 Aug 2014 21:39:43 GMT (envelope-from bdrewery) Received: (qmail 40304 invoked from network); 26 Aug 2014 16:39:41 -0500 Received: from unknown (HELO ?10.10.0.24?) (freebsd@shatow.net@10.10.0.24) by sweb.xzibition.com with ESMTPA; 26 Aug 2014 16:39:41 -0500 Message-ID: <53FCFE98.9010800@FreeBSD.org> Date: Tue, 26 Aug 2014 16:39:36 -0500 From: Bryan Drewery Organization: FreeBSD User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.0 MIME-Version: 1.0 To: John-Mark Gurney Subject: Re: svn commit: r270444 - in head/sys: kern sys References: <201408240904.s7O949sI083660@svn.freebsd.org> <201408261509.26815.jhb@freebsd.org> <20140826193210.GL71691@funkthat.com> <201408261723.10854.jhb@freebsd.org> In-Reply-To: <201408261723.10854.jhb@freebsd.org> OpenPGP: id=6E4697CF; url=http://www.shatow.net/bryan/bryan2.asc Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="LRugLOi8w5XMmr5B43HhmWM0fomc9h9aB" Cc: Mateusz Guzik , John Baldwin , Mateusz Guzik , svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-head@freebsd.org X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Aug 2014 21:39:43 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --LRugLOi8w5XMmr5B43HhmWM0fomc9h9aB Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 8/26/2014 4:23 PM, John Baldwin wrote: > On Tuesday, August 26, 2014 3:32:10 pm John-Mark Gurney wrote: >> John Baldwin wrote this message on Tue, Aug 26, 2014 at 15:09 -0400: >>> On Monday, August 25, 2014 6:30:34 pm John-Mark Gurney wrote: >>>> John Baldwin wrote this message on Mon, Aug 25, 2014 at 13:35 -0400:= >>>>> On Monday, August 25, 2014 07:02:41 PM Mateusz Guzik wrote: >>>>>> On Mon, Aug 25, 2014 at 10:23:19AM -0400, John Baldwin wrote: >>>>>>> On Sunday, August 24, 2014 09:04:09 AM Mateusz Guzik wrote: >>>>>>>> Author: mjg >>>>>>>> Date: Sun Aug 24 09:04:09 2014 >>>>>>>> New Revision: 270444 >>>>>>>> URL: http://svnweb.freebsd.org/changeset/base/270444 >>>>>>>> >>>>>>>> Log: >>>>>>>> Fix getppid for traced processes. >>>>>>>> =20 >>>>>>>> Traced processes always have the tracer set as the parent. >>>>>>>> Utilize proc_realparent to obtain the right process when neede= d. >>>>>>> >>>>>>> Are you sure this won't break things? I know of several applicat= ions that >>>>>>> expect a debugger to be the parent when attached and change behav= ior as a >>>>>>> result (e.g. inserting a breakpoint on an assertion failure rathe= r than >>>>>>> generating a core). >>>>>> >>>>>> Well, this is what linux and solaris do. >>>>> >>>>> Interesting. >>>>> >>>>>> I don't feel strongly about this change. If you really want I'm ha= ppy to >>>>>> revert. >>>>> >>>>> In general I'd like to someday have the debugger-debuggee relations= hip not=20 >>>>> override parent-child and this is a step in that direction. Howeve= r, this=20 >>>>> will break existing applications, so this needs to be clearly docum= ented in=20 >>>>> the release notes. In addition, we should probably advertise how a= process=20 >>>>> can correctly determine if it is being run under a debugger (right = now you can=20 >>>>> do 'getppid()' and use strcmp or strstr on the p_comm of that pid s= o you can=20 >>>>> do different things for "gdb" vs "gcore", etc. so just checking P_T= RACED from=20 >>>>> kinfo_proc wouldn't be equivalent in functionality) >>>> >>>> But what about when you attach gdb to a running process... That >>>> doesn't magicly make the now debugged process a child of gdb does it= ? >>> >>> % cat hello.c >>> #include >>> >>> int >>> main() >>> { >>> printf("hello world\n"); >>> (void)getchar(); >>> return (0); >>> } >>> % cc -g hello.c -o hello >>> % ./hello=20 >>> hello world >>> load: 9.81 cmd: hello 42599 [ttyin] 1.67r 0.00u 0.00s 0% 1056k >>> >>> < different window > >>> >>> % ps -O ppid -p `pgrep hello` >>> PID PPID TT STAT TIME COMMAND >>> 42599 5340 16 I+ 0:00.00 ./hello >>> % gdb hello `pgrep hello` >>> GNU gdb 6.1.1 [FreeBSD] >>> ... >>> (gdb) >>> Suspended >>> % ps -O ppid -p `pgrep hello` >>> PID PPID TT STAT TIME COMMAND >>> 42599 45079 16 TX+ 0:00.00 ./hello >> >> Wow, learn something new every day... >> >> But doesn't that break apps that use getppid to signal their parent >> that forked them? >=20 > Until mjg@'s commit, yes. It's been that way in FreeBSD at least for > as long as I can remember. Certainly back to 4.x. >=20 Fun things can happen (local DoS) when you trace your own parent too. Recently fixed by other commits. Easily thwarted by security.bsd.unprivileged_proc_debug=3D0. --=20 Regards, Bryan Drewery --LRugLOi8w5XMmr5B43HhmWM0fomc9h9aB Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (MingW32) iQEcBAEBAgAGBQJT/P6YAAoJEDXXcbtuRpfPI60H/0Wo09VS/ar8zLbm0B8r8gSm uV4/vMKbtkXtKy7yoXVrEKrznZL6hrJLL8q9e9XF6njuSvGtgu9WS5s1pU8oD4OY cQfi7YsUt3+ESLFbSYNKoCIqaNKa/8uv3DcIc7YR2maDXCShbvc2KnShw5SFpVOd ObvppKxNnTGrfwjJW1Ha59gIad222oFmqQtA/4DUUF4PIk0AGNdHfcAivYbtcJnn HDUmfYo25x35kcTfzMaI5srgAwTVlMwBFdKpDZm7Kkc8O+uUSwdm9BioWeLkg9Nk 53s8E8SS+lGisVIzp3qlrFxtYDhrv40CtSEDXBtdL4gqwo0e42O/y79/3tUBvJM= =8fyp -----END PGP SIGNATURE----- --LRugLOi8w5XMmr5B43HhmWM0fomc9h9aB--