Repository: opencontainers/runc
File: libcontainer/nsenter/nsexec.c (C)

Code before:
			continue;
		}

		int fd_tree = sys_open_tree(-EBADF, idmap_src,
					    OPEN_TREE_CLONE | OPEN_TREE_CLOEXEC |
					    AT_SYMLINK_NOFOLLOW | AT_NO_AUTOMOUNT);
		if (fd_tree < 0) {
			sane_kill(pid, SIGKILL);
			if (errno == EINVAL || errno == ENOSYS)
				bail("failed to use open_tree(2) with path: %s, the kernel doesn't supports ID-mapped mounts", idmap_src);
			else
				bail("failed to use open_tree(2) with path: %s", idmap_src);
		}

		struct mount_attr attr = {
			.attr_set = MOUNT_ATTR_IDMAP,
			.userns_fd = userns_fd,
		};

		ret = sys_mount_setattr(fd_tree, "", AT_EMPTY_PATH, &attr, sizeof(attr));
		if (ret < 0) {
			sane_kill(pid, SIGKILL);
			if (errno == ENOSYS)
				bail("failed to use mount_setattr(2), the kernel doesn't supports ID-mapped mounts");
			else if (errno == EINVAL)
				bail("failed to use mount_setattr(2), maybe the filesystem doesn't supports ID-mapped mounts: %s", idmap_src);
			else
				bail("failed to use mount_setattr(2) for path: %s", idmap_src);
		}

		write_log(DEBUG, "~> sending idmap source: %s with mapping from: %s", idmap_src, proc_user_path);
		send_fd(sockfd, fd_tree);

		if (close(fd_tree) < 0) {
			sane_kill(pid, SIGKILL);
			bail("error closing fd_tree");
		}

		idmap_src += strlen(idmap_src) + 1;
	}

	if (close(userns_fd) < 0) {
		sane_kill(pid, SIGKILL);
		bail("error closing userns fd");
	}
}

void receive_idmapsources(int sockfd)
{
	receive_fd_sources(sockfd, "_LIBCONTAINER_IDMAP_FDS");
}

Review comment (bug):
`maybe` means support or not? I suggest change to:
```
bail("failed to use mount_setattr(2), the filesystem doesn't support this ID-mapped mount: %s, error msg: Invalid argument", idmap_src);
```

Code after:
			continue;
		}

		int fd_tree = sys_open_tree(-EBADF, idmap_src,
					    OPEN_TREE_CLONE | OPEN_TREE_CLOEXEC |
					    AT_SYMLINK_NOFOLLOW | AT_NO_AUTOMOUNT);
		if (fd_tree < 0) {
			sane_kill(pid, SIGKILL);
			if (errno == ENOSYS) {
				bail("open_tree(2) failed, the kernel doesn't support ID-mapped mounts");
			} else if (errno == EINVAL) {
				bail("open_tree(2) failed with path: %s, the kernel doesn't support ID-mapped mounts",
				     idmap_src);
			} else {
				bail("open_tree(2) failed with path: %s", idmap_src);
			}
		}

		struct mount_attr attr = {
			.attr_set = MOUNT_ATTR_IDMAP,
			.userns_fd = userns_fd,
		};

		ret = sys_mount_setattr(fd_tree, "", AT_EMPTY_PATH, &attr, sizeof(attr));
		if (ret < 0) {
			sane_kill(pid, SIGKILL);
			if (errno == ENOSYS)
				bail("mount_setattr(2) failed, the kernel doesn't support ID-mapped mounts");
			else if (errno == EINVAL)
				bail("mount_setattr(2) failed with path: %s, maybe the filesystem doesn't support ID-mapped mounts", idmap_src);
			else
				bail("mount_setattr(2) failed with path: %s", idmap_src);
		}

		write_log(DEBUG, "~> sending idmap source: %s with mapping from: %s", idmap_src, proc_user_path);
		send_fd(sockfd, fd_tree);

		if (close(fd_tree) < 0) {
			sane_kill(pid, SIGKILL);
			bail("error closing fd_tree");
		}

		idmap_src += strlen(idmap_src) + 1;
	}

	if (close(userns_fd) < 0) {
		sane_kill(pid, SIGKILL);
		bail("error closing userns fd");
	}
}