diff options
author | Logan Gunthorpe <logang@deltatee.com> | 2024-06-04 18:38:37 +0200 |
---|---|---|
committer | Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> | 2024-06-13 15:19:48 +0200 |
commit | 539ad6e6f9a067646a018d77582af0babf8e125e (patch) | |
tree | a84d4d14e5298c58b3f14e99b20810820f5d1e48 | |
parent | mdadm: Fix hang race condition in wait_for_zero_forks() (diff) | |
download | mdadm-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.c | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -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)); |