From 4ff68eeb36185ef538a7ccc8ca30b0c1be662109 Mon Sep 17 00:00:00 2001 From: Cyrill Gorcunov Date: Mon, 2 Oct 2017 10:07:48 +0300 Subject: [PATCH] fsnotify: Filter event mask from old kernels 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 Signed-off-by: Andrei Vagin --- criu/fsnotify.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/criu/fsnotify.c b/criu/fsnotify.c index 54f70e698..6098b5b4c 100644 --- a/criu/fsnotify.c +++ b/criu/fsnotify.c @@ -551,12 +551,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 @@ -565,7 +572,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;