Skip to content

Commit 61859d1

Browse files
Cyrill Gorcunovxemul
Cyrill Gorcunov
authored andcommitted
fsnotify: Filter out internal inotify bits when restoring marks
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 <[email protected]> Signed-off-by: Pavel Emelyanov <[email protected]>
1 parent 9f631ad commit 61859d1

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

fsnotify.c

+14
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,10 @@ static int dump_inotify_entry(union fdinfo_entries *e, void *arg)
223223
we->f_handle->bytes, we->f_handle->type,
224224
we->f_handle->handle[0], we->f_handle->handle[1]);
225225

226+
if (we->mask & KERNEL_FS_EVENT_ON_CHILD)
227+
pr_warn_once("\t\tDetected FS_EVENT_ON_CHILD bit "
228+
"in mask (will be ignored on restore)\n");
229+
226230
if (check_open_handle(we->s_dev, we->i_ino, we->f_handle)) {
227231
free_inotify_wd_entry(e);
228232
return -1;
@@ -813,6 +817,16 @@ static int collect_one_inotify_mark(void *o, ProtobufCMessage *msg)
813817
INIT_LIST_HEAD(&mark->list);
814818
mark->remap = NULL;
815819

820+
/*
821+
* The kernel prior 4.3 might export internal event
822+
* mask bits which are not part of user-space API. It
823+
* is fixed in kernel but we have to keep backward
824+
* compatibility with old images. So mask out
825+
* inappropriate bits (in particular fdinfo might
826+
* have FS_EVENT_ON_CHILD bit set).
827+
*/
828+
mark->iwe->mask &= ~KERNEL_FS_EVENT_ON_CHILD;
829+
816830
return collect_inotify_mark(mark);
817831
}
818832

include/fsnotify.h

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#include "protobuf.h"
88
#include "protobuf/fsnotify.pb-c.h"
99

10+
#define KERNEL_FS_EVENT_ON_CHILD 0x08000000
11+
1012
struct fsnotify_params {
1113
u32 faflags;
1214
u32 evflags;

0 commit comments

Comments
 (0)