mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 14:25:26 +00:00
process: block signals while spawning child processes
Between fork() and execvp() calls in the process_start() function both child and parent processes share the same file descriptors. This means that, if a child process received a signal during this time interval, then it could potentially write data to a shared file descriptor. One such example is fatal signal handler, where, if child process received SIGTERM signal, then it would write data into pipe. Then a read event would occur on the other end of the pipe where parent process is listening and this would make parent process to incorrectly believe that it was the one who received SIGTERM. Also, since parent process never reads data from this pipe, then this bug would make parent process to consume 100% CPU by immediately waking up from the event loop. This patch will help to avoid this problem by blocking signals until child closes all its file descriptors. Signed-off-by: Ansis Atteka <aatteka@nicira.com> Reported-by: Suganya Ramachandran <suganyar@vmware.com> Issue: 1255110
This commit is contained in:
@@ -374,3 +374,21 @@ fatal_signal_fork(void)
|
||||
raise(stored_sig_nr);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
/* Blocks all fatal signals and returns previous signal mask into
|
||||
* 'prev_mask'. */
|
||||
void
|
||||
fatal_signal_block(sigset_t *prev_mask)
|
||||
{
|
||||
int i;
|
||||
sigset_t block_mask;
|
||||
|
||||
sigemptyset(&block_mask);
|
||||
for (i = 0; i < ARRAY_SIZE(fatal_signals); i++) {
|
||||
int sig_nr = fatal_signals[i];
|
||||
sigaddset(&block_mask, sig_nr);
|
||||
}
|
||||
xpthread_sigmask(SIG_BLOCK, &block_mask, prev_mask);
|
||||
}
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user