Bug 215676 - fanotify Ignoring/Excluding a Directory not working with FAN_MARK_MOUNT
Summary: fanotify Ignoring/Excluding a Directory not working with FAN_MARK_MOUNT
Status: RESOLVED ANSWERED
Alias: None
Product: File System
Classification: Unclassified
Component: VFS (show other bugs)
Hardware: All Linux
: P1 high
Assignee: fs_vfs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-03-12 11:19 UTC by Srinivas
Modified: 2022-03-21 09:13 UTC (History)
2 users (show)

See Also:
Kernel Version: 5.11.0-27
Subsystem:
Regression: No
Bisected commit-id:


Attachments
Test program to show directory exclusion not working (7.99 KB, text/plain)
2022-03-12 11:19 UTC, Srinivas
Details

Description Srinivas 2022-03-12 11:19:16 UTC
Created attachment 300557 [details]
Test program to show directory exclusion not working

If a  process calls fanotify_mark(fd, FAN_MARK_ADD | FAN_MARK_MOUNT, FAN_OPEN_PERM, 0, "/mountpoint") no other directory exclusions can be applied.

However a path (file) exclusion can still be applied using 

fanotify_mark(fd, FAN_MARK_ADD | FAN_MARK_IGNORED_MASK | FAN_MARK_IGNORED_SURV_MODIFY, FAN_OPEN_PERM | FAN_CLOSE_WRITE, AT_FDCWD, "/tmp/fio/abc");  ===> path exclusion that works.


I think the directory exclusion not working is a bug as otherwise AV solutions cant exclude directories when using FAN_MARK_MOUNT.

I believe the change should be simple since we are already supporting path exclusions. So we should be able to add the same for the directory inode.
Comment 1 Jan Kara 2022-03-15 11:57:51 UTC
This is the expected behavior, although there are workarounds and possible future improvements. More details in the email thread here:

https://lore.kernel.org/all/CAOQ4uxiDubhONM3w502anndtbqy73q_Kt5bOQ07zbATb8ndvVA@mail.gmail.com
Comment 2 Jan Kara 2022-03-21 09:13:53 UTC
Closing the bug as things are working as expected. We are working with Amir on implementing some scheme that would allow this feature to work...

Note You need to log in before you can comment on or make changes to this bug.