summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLogan Gunthorpe <logang@deltatee.com>2024-06-04 18:38:37 +0200
committerMariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>2024-06-13 15:19:48 +0200
commit539ad6e6f9a067646a018d77582af0babf8e125e (patch)
treea84d4d14e5298c58b3f14e99b20810820f5d1e48
parentmdadm: Fix hang race condition in wait_for_zero_forks() (diff)
downloadmdadm-539ad6e6f9a067646a018d77582af0babf8e125e.tar.xz
mdadm-539ad6e6f9a067646a018d77582af0babf8e125e.zip
mdadm: Block SIGCHLD processes before starting children
There is a small race condition noticed during code review, but never actully hit in practice, with the write_zero feature. If a write zeros fork finishes quickly before wait_for_zero_forks() gets called, then the SIGCHLD will be delivered before the signalfd is setup. While this is only theoretical, fix this by blocking the SIGCHLD signal before forking any children. Signed-off-by: Logan Gunthorpe <logang@deltatee.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
-rw-r--r--Create.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/Create.c b/Create.c
index 4f992a22..bd4875e4 100644
--- a/Create.c
+++ b/Create.c
@@ -401,6 +401,7 @@ static int add_disks(int mdfd, struct mdinfo *info, struct shape *s,
*/
sigemptyset(&sigset);
sigaddset(&sigset, SIGINT);
+ sigaddset(&sigset, SIGCHLD);
sigprocmask(SIG_BLOCK, &sigset, &orig_sigset);
memset(zero_pids, 0, sizeof(zero_pids));