Date: Tue, 26 Aug 2014 16:39:36 -0500 From: Bryan Drewery <bdrewery@FreeBSD.org> To: John-Mark Gurney <jmg@funkthat.com> Cc: Mateusz Guzik <mjguzik@gmail.com>, John Baldwin <jhb@freebsd.org>, Mateusz Guzik <mjg@freebsd.org>, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r270444 - in head/sys: kern sys Message-ID: <53FCFE98.9010800@FreeBSD.org> In-Reply-To: <201408261723.10854.jhb@freebsd.org> References: <201408240904.s7O949sI083660@svn.freebsd.org> <201408261509.26815.jhb@freebsd.org> <20140826193210.GL71691@funkthat.com> <201408261723.10854.jhb@freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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 <stdio.h> >>> >>> 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) <hit Ctrl-Z> >>> 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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?53FCFE98.9010800>