HomeFreeBSD

procdesc: fix reparenting when the debugger is attached

Description

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
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D20361

Details

Committed
oshogboAug 5 2019, 8:15 PM
Reviewer
markj
Differential Revision
D20361: procdesc: fix reparenting when the debugger is attached
Parents
rS350611: proc: introduce the proc_add_orphan function
Branches
Unknown
Tags
Unknown