[CRIU] [PATCH v3 06/26] files: Allow to receive further fds

Pavel Emelyanov xemul at virtuozzo.com
Tue Dec 6 09:16:35 PST 2016


>  int recv_fd_from_peer(struct fdinfo_list_entry *fle)
>  {
>  	struct fdinfo_list_entry *tmp;
>  	int fd, ret;
>  
> +	if (fle->received)
> +		return fle->fe->fd;
> +again:
>  	ret = recv_fds(fle->fe->fd, &fd, 1, (void *)&tmp, sizeof(struct fdinfo_list_entry *));
>  	if (ret)
>  		return -1;
>  
>  	if (tmp != fle) {
> -		pr_err("Received wrong fle\n");
> -		return -1;
> +		pr_info("Further fle=%p, pid=%d\n", tmp, fle->pid);
> +		if (!task_fle(current, fle)) {

OK, so this routine makes sure the fle received sits in current's list.
Two questions: 1. should we consider receiving of non-current fle as BUG()?
and 2. can we make the same check by comparing fle->pid with current? All
fle's are in shmem, so contents is accessible by everyone.


> +			pr_err("Unexpected fle %p, pid=%d\n", fle, current->pid.virt);
> +			return -1;
> +		}
> +		if (keep_fd_for_future(tmp, fd))
> +			return -1;
> +		goto again;
>  	}
>  	close(fle->fe->fd);
> +	fle->received = 1;
>  
>  	return fd;
>  }



More information about the CRIU mailing list