HomeFreeBSD

fork: plug a use after free of the returned process

Description

fork: plug a use after free of the returned process

fork1 required its callers to pass a pointer to struct proc * which would
be set to the new process (if any). procdesc and racct manipulation also
used said pointer.

However, the process could have exited prior to do_fork return and be
automatically reaped, thus making this a use-after-free.

Fix the problem by letting callers indicate whether they want the pid or
the struct proc, return the process in stopped state for the latter case.

Reviewed by: kib

Details

Provenance
mjgAuthored on
Reviewer
kib
Parents
rS295232: fork: pass arguments to fork1 in a dedicated structure
Branches
Unknown
Tags
Unknown