]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
idmap: kill child when writing the idmap fails
authorChristian Brauner <brauner@kernel.org>
Thu, 23 Mar 2023 10:09:28 +0000 (11:09 +0100)
committerChristian Brauner <brauner@kernel.org>
Thu, 23 Mar 2023 10:21:21 +0000 (11:21 +0100)
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 <brauner@kernel.org>
libmount/src/hook_idmap.c

index 9306e5d9711f857e0acf3b0fe99075a8f5d3d20e..a861c2c39ff9d41665d36662e36ab01b9014ba43 100644 (file)
@@ -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);