From: Logan Gunthorpe Date: Tue, 4 Jun 2024 16:38:37 +0000 (-0600) Subject: mdadm: Block SIGCHLD processes before starting children X-Git-Tag: mdadm-4.4~144 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=539ad6e6f9a067646a018d77582af0babf8e125e;p=thirdparty%2Fmdadm.git 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 Signed-off-by: Mariusz Tkaczyk --- 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));