HomeFreeBSD

fork: fix use-after-free with vfork

Description

fork: fix use-after-free with vfork

The pointer to the child is stored without any reference held. Then it is
blindly used to wait until P_PPWAIT is cleared. However, if the child is
autoreaped it could have exited and get freed before the parent started
waiting.

Use the existing hold mechanism to mitigate the problem. Most common case
of doing exec remains unchanged. The corner case of doing exit performs
wake up before waiting for holds to clear.

Reviewed by: kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D18295

Details

Provenance
mjgAuthored on
Reviewer
kib
Differential Revision
D18295: fork: fix use-after-free with vfork
Parents
rS340783: Plug some networking sysctl leaks.
Branches
Unknown
Tags
Unknown