linux-stable/fs/notify/fanotify
Amir Goldstein 62b4f33818 fanotify: fix ignore mask logic for events on child and on dir
commit 2f02fd3fa1 upstream.

The comments in fanotify_group_event_mask() say:

  "If the event is on dir/child and this mark doesn't care about
   events on dir/child, don't send it!"

Specifically, mount and filesystem marks do not care about events
on child, but they can still specify an ignore mask for those events.
For example, a group that has:
- A mount mark with mask 0 and ignore_mask FAN_OPEN
- An inode mark on a directory with mask FAN_OPEN | FAN_OPEN_EXEC
  with flag FAN_EVENT_ON_CHILD

A child file open for exec would be reported to group with the FAN_OPEN
event despite the fact that FAN_OPEN is in ignore mask of mount mark,
because the mark iteration loop skips over non-inode marks for events
on child when calculating the ignore mask.

Move ignore mask calculation to the top of the iteration loop block
before excluding marks for events on dir/child.

Link: https://lore.kernel.org/r/20200524072441.18258-1-amir73il@gmail.com
Reported-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/linux-fsdevel/20200521162443.GA26052@quack2.suse.cz/
Fixes: 55bf882c7f "fanotify: fix merging marks masks with FAN_ONDIR"
Fixes: b469e7e47c "fanotify: fix handling of events on child..."
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Cc: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-06-30 23:17:00 -04:00
..
Kconfig treewide: Fix typos in Kconfig 2017-10-12 15:42:00 +02:00
Makefile
fanotify.c fanotify: fix ignore mask logic for events on child and on dir 2020-06-30 23:17:00 -04:00
fanotify.h fanotify: Avoid lost events due to ENOMEM for unlimited queues 2018-02-27 10:25:33 +01:00
fanotify_user.c Merge branch 'akpm' (patches from Andrew) 2018-08-17 16:49:31 -07:00