From 8aed8cebdd973e95d20743e00e35467c7b467d0d Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Tue, 28 Jul 2020 10:58:07 +0200 Subject: [PATCH] fanotify: compare fsid when merging name event When merging name events, fsids of the two involved events have to match. Otherwise we could merge events from two different filesystems and thus effectively loose the second event. Backporting note: Although the commit cacfb956d46e introducing this bug was merged for 5.7, the relevant code didn't get used in the end until 7e8283af6ede ("fanotify: report parent fid + name + child fid") which will be merged with this patch. So there's no need for backporting this. Fixes: cacfb956d46e ("fanotify: record name info for FAN_DIR_MODIFY event") Reported-by: Amir Goldstein Signed-off-by: Jan Kara --- fs/notify/fanotify/fanotify.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c index bd9e88e889ea..c942910a8649 100644 --- a/fs/notify/fanotify/fanotify.c +++ b/fs/notify/fanotify/fanotify.c @@ -82,6 +82,9 @@ static bool fanotify_name_event_equal(struct fanotify_name_event *fne1, if (!info1->dir_fh_totlen) return false; + if (!fanotify_fsid_equal(&fne1->fsid, &fne2->fsid)) + return false; + return fanotify_info_equal(info1, info2); }