Skip to content
Commit 74630b1b authored by Adhemerval Zanella's avatar Adhemerval Zanella
Browse files

posix: Fix pidfd_spawn/pidfd_spawnp leak if execve fails (BZ 31695)



If the pidfd_spawn/pidfd_spawnp helper process succeeds, but evecve
fails for some reason (either with an invalid/non-existent, memory
allocation, etc.) the resulting pidfd is never closed, nor returned
to caller (so it can call close).

Since the process creation failed, it should be up to posix_spawn to
also, close the file descriptor in this case (similar to what it
does to reap the process).

This patch also changes the waitpid with waitid (P_PIDFD) for pidfd
case, to avoid a possible pid re-use.

Checked on x86_64-linux-gnu.
Reviewed-by: default avatarCarlos O'Donell <carlos@redhat.com>

(cherry picked from commit c90cfce8)
parent 7f9f25f2
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment