[CRIU] [PATCH] fsnotify: Filter event mask from old kernels

Andrey Vagin avagin at virtuozzo.com
Wed Oct 4 01:19:47 MSK 2017


Applied, thanks
On Mon, Oct 02, 2017 at 10:07:48AM +0300, Cyrill Gorcunov wrote:
> From: Cyrill Gorcunov <gorcunov at virtuozzo.com>
> 
> When checkpoint is done on the kernels where
> commit 6933599697c96c3213c95f5f1fc7cb6abfd08c54
> is not yet present then mask is not filtered
> and saved in image in this raw form.
> 
> For such case restore on more modern kernels
> will fail because only a small set of events
> are allowed to pass from userspace.
> 
> Signed-off-by: Cyrill Gorcunov <gorcunov at virtuozzo.com>
> ---
>  criu/fsnotify.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/criu/fsnotify.c b/criu/fsnotify.c
> index c26e5c6ec387..955cd106b3cb 100644
> --- a/criu/fsnotify.c
> +++ b/criu/fsnotify.c
> @@ -556,12 +556,19 @@ static int restore_one_inotify(int inotify_fd, struct fsnotify_mark_info *info)
>  	InotifyWdEntry *iwe = info->iwe;
>  	int ret = -1, target = -1;
>  	char buf[PSFDS], *path;
> +	uint32_t mask;
>  
>  	path = get_mark_path("inotify", info->remap, iwe->f_handle,
>  			     iwe->i_ino, iwe->s_dev, buf, &target);
>  	if (!path)
>  		goto err;
>  
> +	mask = iwe->mask & IN_ALL_EVENTS;
> +	if (iwe->mask & ~IN_ALL_EVENTS) {
> +		pr_info("\t\tfilter event mask %#x -> %#x\n",
> +			iwe->mask, mask);
> +	}
> +
>  	/*
>  	 * FIXME The kernel allocates wd-s sequentially,
>  	 * this is suboptimal, but the kernel doesn't
> @@ -570,7 +577,7 @@ static int restore_one_inotify(int inotify_fd, struct fsnotify_mark_info *info)
>  	while (1) {
>  		int wd;
>  
> -		wd = inotify_add_watch(inotify_fd, path, iwe->mask);
> +		wd = inotify_add_watch(inotify_fd, path, mask);
>  		if (wd < 0) {
>  			pr_perror("Can't add watch for 0x%x with 0x%x", inotify_fd, iwe->wd);
>  			break;
> -- 
> 2.7.5
> 


More information about the CRIU mailing list