]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
mdadm: Block SIGCHLD processes before starting children
authorLogan Gunthorpe <logang@deltatee.com>
Tue, 4 Jun 2024 16:38:37 +0000 (10:38 -0600)
committerMariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Thu, 13 Jun 2024 13:19:48 +0000 (15:19 +0200)
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>
Create.c

index 4f992a22b7c9ea77b169b5bb3b8905d5ac88a907..bd4875e4a408b76a6fe264665140fde4b3804e6c 100644 (file)
--- 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));