[CRIU] [PATCH] Resolve file descriptor clashes with inherit fds

Pavel Emelyanov xemul at parallels.com
Wed Nov 26 12:21:45 PST 2014


On 11/26/2014 11:02 PM, Andrew Vagin wrote:
> On Wed, Nov 26, 2014 at 10:13:49PM +0300, Pavel Emelyanov wrote:
>> On 11/26/2014 01:54 AM, Saied Kazemi wrote:
>>> Since with --inherit-fd option criu's caller can set any fd to be
>>> inheritied, there is a chance of fd clash during restore.  Resolve such
>>> cases by moving the inherit fd to a different descriptor.
>>>
>>> Signed-off-by: Saied Kazemi <saied at google.com>
>>
>> I have a crazy idea how to keep all inherit-fds in a service-fd area :)
>> We can create a unix socket and "send" all inherited fd-s there. At the
>> time of fd restore we can just pull one out of this queue :)
> 
> How to specify which one should be pulled out?

At the time you put them in you remember the sequence.

>>
>> What do you think?
> 
> Are you going to read them all each time, when you need one of them?

No. You restore file descriptors in one place. Before this "place" you
receive them all, then dup2 in the proper places. That's the proposal
how to keep them from being reopen_fd_as()-d and close_fd_safe()-d.

> How many file descriptors can be sent in one unix socket?

Technically any.

Thanks,
Pavel



More information about the CRIU mailing list