You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mdadm/SOURCES/0103-mdadm-Block-SIGCHLD-pr...

38 lines
1.1 KiB

From 539ad6e6f9a067646a018d77582af0babf8e125e Mon Sep 17 00:00:00 2001
From: Logan Gunthorpe <logang@deltatee.com>
Date: Tue, 4 Jun 2024 10:38:37 -0600
Subject: [PATCH 103/157] 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>
---
Create.c | 1 +
1 file changed, 1 insertion(+)
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));
--
2.41.0