From c7ea57c66c8c9f9607928bf7c55fc409eecc3e57 Mon Sep 17 00:00:00 2001 From: Amir Goldstein Date: Fri, 11 Dec 2020 10:19:36 +0200 Subject: [PATCH] fsnotify: fix for fix events reported to watching parent and child The child watch is expecting an event without file name and without the ON_CHILD flag. Reported-by: Hugh Dickins Signed-off-by: Amir Goldstein --- fs/notify/fsnotify.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c index a0da9e766992..30d422b8c0fc 100644 --- a/fs/notify/fsnotify.c +++ b/fs/notify/fsnotify.c @@ -291,13 +291,18 @@ static int fsnotify_handle_event(struct fsnotify_group *group, __u32 mask, } if (!inode_mark) return 0; + } + if (mask & FS_EVENT_ON_CHILD) { /* * Some events can be sent on both parent dir and child marks * (e.g. FS_ATTRIB). If both parent dir and child are * watching, report the event once to parent dir with name (if * interested) and once to child without name (if interested). + * The child watcher is expecting an event without a file name + * and without the FS_EVENT_ON_CHILD flag. */ + mask &= ~FS_EVENT_ON_CHILD; dir = NULL; name = NULL; } -- 2.25.1