A few potential race conditions with signals and PIDs
1
vote
1
answer
200
views
I'm aware that because of PID-reuse on Unix-like kernels, signals can be delivered to the wrong process if they are sent after the PID has already been reaped.
Discussion of what follows will probably necessarily depend on the specific kernel we're discussing, so I'm happy to reduce scope to Linux. Though I welcome answers with experts on other kernels.
A few situations to consider:
1. Let's say I'm in the middle of a call to
kill(2)
to a zombie process (i.e., I'm already in kernel space and executing kernel code to initiate the signal). Concurrently, the parent of the zombie calls wait(2)
. Is it possible that my call to kill(2)
could end up attempting to act on a different process?
2. Let's say I've kill(2)
-ed (i.e., successfully returned into user space from the call) a process, but before my signal can be delivered, a different signal is caught and kills the process. In this case, I assume it's guaranteed that my signal will be trashed? One line of reasoning why is: even if the PID gets reaped and a different process with the same PID is spawned concurrently, delivering the signal to the new process could open permission loopholes.
Thank you
Asked by Ani Agarwal
(113 rep)
Aug 19, 2024, 10:26 AM
Last activity: Aug 19, 2024, 06:41 PM
Last activity: Aug 19, 2024, 06:41 PM