From: Christian Brauner Date: Thu, 23 Mar 2023 10:09:28 +0000 (+0100) Subject: idmap: kill child when writing the idmap fails X-Git-Tag: v2.39-rc2~19^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=648e2d6c8d060195550101b3751277d9c4002749;p=thirdparty%2Futil-linux.git idmap: kill child when writing the idmap fails This fixes the second issues reported in [1] where calling mount -o 'X-mount.idmap=[...]' just hangs. Fixes: https://github.com/util-linux/util-linux/issues/2130 [1] Signed-off-by: Christian Brauner --- diff --git a/libmount/src/hook_idmap.c b/libmount/src/hook_idmap.c index 9306e5d971..a861c2c39f 100644 --- a/libmount/src/hook_idmap.c +++ b/libmount/src/hook_idmap.c @@ -229,12 +229,16 @@ static int get_userns_fd_from_idmap(struct list_head *idmap) /* Wait for child to set up a new namespace. */ rc = read_all(sock_fds[1], &c, 1); - if (rc != 1) + if (rc != 1) { + kill(pid, SIGKILL); goto err_wait; + } rc = map_ids(idmap, pid); - if (rc < 0) + if (rc < 0) { + kill(pid, SIGKILL); goto err_wait; + } snprintf(path, sizeof(path), "/proc/%d/ns/user", pid); fd_userns = open(path, O_RDONLY | O_CLOEXEC | O_NOCTTY);