]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
MFCr350612
authorMariusz Zaborski <oshogbo@FreeBSD.org>
Tue, 10 Sep 2019 20:18:06 +0000 (20:18 +0000)
committerMariusz Zaborski <oshogbo@FreeBSD.org>
Tue, 10 Sep 2019 20:18:06 +0000 (20:18 +0000)
commit80311a9eab099fb08689fdd3180d8a1696161667
treec0622d810df72f4c0ad3e5f21c00a8cf459421b4
parentc84b0b909df8dff8a26a4186a0bafac5ecf71854
MFCr350612
  procdesc: fix reparenting when the debugger is attached

  The process is reparented to the debugger while it is attached.
    B          B
   /   ---->   |
  A          A D

  Every time when the process is reparented, it is added to the orphan list
  of the previous parent:

  A->orphan = B
  D->orphan = NULL

  When the A process will close the process descriptor to the B process,
  the B process will be reparented to the init process.
    B            B - init
    |   ---->
  A D          A   D

  A->orphan = B
  D->orphan = B

  In this scenario, the B process is in the orphan list of A and D.

  When the last process descriptor is closed instead of reparenting
  it to the reaper let it stay with the debugger process and set
  our previews parent to the reaper.

  Add test case for this situation.
  Notice that without this patch the kernel will crash with this test case:
  panic: orphan 0xfffff8000e990530 of 0xfffff8000e990000 has unexpected oppid 1

  Reviewed by:  markj, kib
  Differential Revision:        https://reviews.freebsd.org/D20361
sys/kern/sys_procdesc.c
tests/sys/kern/ptrace_test.c