Commit c7e58be7 authored by Pavel Emelyanov's avatar Pavel Emelyanov

files: Don't even try to move service descriptors

When serving out fds in files engine we _may_ goto move_fd_from()
call on the recently added service transport fd.

Avoid this theoretical situation.
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
Acked-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent e7e9ece1
......@@ -793,6 +793,12 @@ int prepare_fd_pid(struct pstree_item *item)
if (ret <= 0)
break;
if (e->fd >= service_fd_min_fd()) {
ret = -1;
pr_err("Too big FD number to restore %d\n", e->fd);
break;
}
ret = collect_fd(pid, e, rst_info);
if (ret < 0) {
fdinfo_entry__free_unpacked(e, NULL);
......@@ -950,7 +956,7 @@ int send_fd_to_peer(int fd, struct fdinfo_list_entry *fle, int sock)
return send_fd(sock, &saddr, len, fd);
}
static int send_fd_to_self(int fd, struct fdinfo_list_entry *fle, int *sock)
static int send_fd_to_self(int fd, struct fdinfo_list_entry *fle, int sock)
{
int dfd = fle->fe->fd;
......@@ -961,10 +967,9 @@ static int send_fd_to_self(int fd, struct fdinfo_list_entry *fle, int *sock)
if (inherit_fd_resolve_clash(dfd) < 0)
return -1;
pr_info("\t\t\tGoing to dup %d into %d\n", fd, dfd);
if (move_fd_from(sock, dfd))
return -1;
BUG_ON(dfd == sock);
pr_info("\t\t\tGoing to dup %d into %d\n", fd, dfd);
if (dup2(fd, dfd) != dfd) {
pr_perror("Can't dup local fd %d -> %d", fd, dfd);
return -1;
......@@ -1006,7 +1011,7 @@ static int serve_out_fd(int pid, int fd, struct file_desc *d)
list_for_each_entry(fle, &d->fd_info_head, desc_list) {
if (pid == fle->pid)
ret = send_fd_to_self(fd, fle, &sock);
ret = send_fd_to_self(fd, fle, sock);
else
ret = send_fd_to_peer(fd, fle, sock);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment