[CRIU] [PATCH] fsmptify: Filter out internal inotify bits when restoring marks

Pavel Emelyanov xemul at parallels.com
Mon Oct 12 04:06:33 PDT 2015


On 10/12/2015 02:04 PM, Cyrill Gorcunov wrote:
> On Mon, Oct 12, 2015 at 01:27:12PM +0300, Pavel Emelyanov wrote:
>> On 09/22/2015 12:48 AM, Cyrill Gorcunov wrote:
>>> The kernel prior 4.3 is exporting FS_EVENT_ON_CHILD
>>> bit via procfs fdinfo interface. This bit is kernel's
>>> internal and should not be passed in inotify_add_watch
>>> call. Thus simply filter it out when obtain from old
>>> images for backward compatibility reason.
>>>
>>> More details here https://lkml.org/lkml/2015/9/21/680
>>>
>>> Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
>>> ---
>>>  fsnotify.c | 10 ++++++++++
>>>  1 file changed, 10 insertions(+)
>>>
>>> diff --git a/fsnotify.c b/fsnotify.c
>>> index 9b1323363457..17abd499c337 100644
>>> --- a/fsnotify.c
>>> +++ b/fsnotify.c
>>> @@ -801,6 +801,16 @@ static int collect_one_inotify_mark(void *o, ProtobufCMessage *msg)
>>>  	INIT_LIST_HEAD(&mark->list);
>>>  	mark->remap = NULL;
>>>  
>>> +	/*
>>> +	 * The kernel prior 4.3 might export internal event
>>> +	 * mask bits which are not part of user-space API. It
>>> +	 * is fixed in kernel but we have to keep backward
>>> +	 * compatibility with old images. So mask out
>>> +	 * inappropriate bits (in particular fdinfo might
>>> +	 * have FS_EVENT_ON_CHILD bit set).
>>> +	 */
>>> +	mark->iwe->mask &= IN_ALL_EVENTS;
>>
>> OK, so after thinking about it more, here's what seems correct to me:
>>
>> 1. On restore drop the FS_EVENT_ON_CHILD from image unconditionally.
> 
> We can't: this bit is internal kernel bit and may be a valid one in
> a future (exported into userspace). So what we need is to simply
> filter out all unsupported bits I think.

If this bit becomes valid we'll notice it via warning and take actions.
If we simply filter those out, as you propose, we'll miss it.

-- Pavel


More information about the CRIU mailing list