mirror_zfs/lib/libzfs
shodanshok 299da6ace3 Fix race in libzfs_run_process_impl
When replacing a disk, a child process is forked to run a script called
zfs_prepare_disk (which can be useful for disk firmware update or health
check). The parent than calls waitpid and checks the child error/status
code.

However, the _reap_children thread (created from zed_exec_process to
manage zedlets) also waits for all children with the same PGID and can
stole the signal, causing the replace operation to be aborted.

As waitpid returns -1, the parent incorrectly assume that the child
process had an error or was killed. This, in turn, leaves the newly
added disk in REMOVED or UNAVAIL status rather than completing the
replace process.

This patch changes the PGID of the child process execuing the
prepare script, shielding it from the _reap_children thread.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by:  Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: Gionatan Danti <g.danti@assyoma.it>
Closes #16801
2024-12-04 14:12:39 -08:00
..
os freebsd: remove __FBSDID macro use 2024-11-18 11:44:05 -08:00
.gitignore Clean up lib dependencies 2020-07-10 14:26:00 -07:00
libzfs_changelist.c Add '-u' - nomount flag for zfs set 2023-10-03 15:41:46 -07:00
libzfs_config.c Replace dead opensolaris.org license link 2022-07-11 14:16:13 -07:00
libzfs_crypto.c libzfs: use zfs_strerror() in place of strerror() 2024-11-05 15:43:53 -08:00
libzfs_dataset.c libzfs: use zfs_strerror() in place of strerror() 2024-11-05 15:43:53 -08:00
libzfs_diff.c libzfs: use zfs_strerror() in place of strerror() 2024-11-05 15:43:53 -08:00
libzfs_impl.h nvpair: Constify string functions 2023-03-14 15:25:50 -07:00
libzfs_import.c Fix "out of memory" error 2024-01-29 14:53:29 -08:00
libzfs_iter.c libzfs: add v2 iterator interfaces 2023-04-10 11:53:02 -07:00
libzfs_mount.c libzfs: use zfs_strerror() in place of strerror() 2024-11-05 15:43:53 -08:00
libzfs_pool.c Add ashift validation when adding devices to a pool 2024-04-29 13:50:05 -07:00
libzfs_sendrecv.c libzfs: use zfs_strerror() in place of strerror() 2024-11-05 15:43:53 -08:00
libzfs_status.c nvpair: Constify string functions 2023-03-14 15:25:50 -07:00
libzfs_util.c Fix race in libzfs_run_process_impl 2024-12-04 14:12:39 -08:00
libzfs.abi value strings: pretty printers for flags and enums 2024-11-15 10:15:00 -08:00
libzfs.pc.in Spruce up pkg-config files for libzfs/libzfs_core 2020-09-04 11:11:18 -07:00
libzfs.suppr Library ABI tracking with abigail 2020-11-17 09:18:52 -08:00
Makefile.am value strings: pretty printers for flags and enums 2024-11-15 10:15:00 -08:00
THIRDPARTYLICENSE.openssl Fix typos in lib/ 2019-09-02 17:53:27 -07:00
THIRDPARTYLICENSE.openssl.descrip Encryption patch follow-up 2017-10-11 16:54:48 -04:00