fsnotify: fix ignore mask logic in fsnotify()
Subsystems (2)
Amir Goldstein
reviewerPATCH 1/1 fsnotify: fix ignore mask logic in fsnotify()
Commit 92183a42898d ("fsnotify: fix ignore mask logic in send_to_group()") acknoledges the use case of ignoring an event on an inode mark, because of an ignore mask on a mount mark of the same group (i.e. I want to get all events on this file, except for the events that came from that mount).
This change depends on correctly merging the inode marks and mount marks group lists, so that the mount mark ignore mask would be tested in send_to_group(). Alas, the merging of the lists did not take into account the case where event in question is not in the mask of any of the mount marks.
To fix this, completely remove the tests for inode and mount event masks from the lists merging code.
---
Jan,
Posting this fix independent from the super block mark series, so you can send it in this cycle if you wish.
New LTP test fanotify10 from [1] demonstrates the problem and the fix. Note that the test verifies the expected behavior as agreed in this discussion [2].
Thanks,
Amir.
[1] https://github.com/amir73il/ltp/commits/fanotify_sb
[2] https://marc.info/?l=linux-fsdevel&m=152284295703053&w=2
fs/notify/fsnotify.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-)
fs/notify/fsnotify.c +3 -10
@@ -357,16 +357,9 @@ int fsnotify(struct inode *to_tell, __u32 mask, const void *data, int data_is, iter_info.srcu_idx =srcu_read_lock (&fsnotify_mark_srcu); -if ((mask &FS_MODIFY ) || - (test_mask & to_tell->i_fsnotify_mask)) { - iter_info.marks[FSNOTIFY_OBJ_TYPE_INODE ] = -fsnotify_first_mark (&to_tell->i_fsnotify_marks); - } - -if (mnt && ((mask &FS_MODIFY ) || - (test_mask & mnt->mnt_fsnotify_mask))) { - iter_info.marks[FSNOTIFY_OBJ_TYPE_INODE ] = -fsnotify_first_mark (&to_tell->i_fsnotify_marks); + iter_info.marks[FSNOTIFY_OBJ_TYPE_INODE ] = +fsnotify_first_mark (&to_tell->i_fsnotify_marks); +if (mnt) { iter_info.marks[FSNOTIFY_OBJ_TYPE_VFSMOUNT ] =fsnotify_first_mark (&mnt->mnt_fsnotify_marks); }
Signature · 1 line
2.17.1
Jan Kara
maintainerQuoted 12 lines · Amir Goldstein
Commit
92183a42898d("fsnotify: fix ignore mask logic insend_to_group()") acknoledges the use case of ignoring an event on an inode mark, because of an ignore mask on a mount mark of the same group (i.e. I want to get all events on this file, except for the events that came from that mount).This change depends on correctly merging the inode marks and mount marks group lists, so that the mount mark ignore mask would be tested in
send_to_group(). Alas, the merging of the lists did not take into account the case where event in question is not in the mask of any of the mount marks.
Quoted 5 lines
To fix this, completely remove the tests for inode and mount event masks from the lists merging code.
Fixes 92183a42898d ("fsnotify: fix ignore mask logic in send_to_group")Signed-off-by Amir Goldstein <[email protected]>
Great, thanks. Added to my tree.
Honza
Quoted 47 lines
---
Jan,
Posting this fix independent from the super block mark series, so you can send it in this cycle if you wish.
New LTP test fanotify10 from [1] demonstrates the problem and the fix. Note that the test verifies the expected behavior as agreed in this discussion [2].
Thanks,
Amir.[1] https://github.com/amir73il/ltp/commits/fanotify_sb
[2] https://marc.info/?l=linux-fsdevel&m=152284295703053&w=2fs/notify/fsnotify.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-)fs/notify/fsnotify.c +3
-10@@ -357,16 +357,9 @@ int fsnotify(struct inode *to_tell, __u32 mask, const void *data, int data_is, iter_info.srcu_idx =srcu_read_lock (&fsnotify_mark_srcu); -if ((mask &FS_MODIFY ) || - (test_mask & to_tell->i_fsnotify_mask)) { - iter_info.marks[FSNOTIFY_OBJ_TYPE_INODE ] = -fsnotify_first_mark (&to_tell->i_fsnotify_marks); - } - -if (mnt && ((mask &FS_MODIFY ) || - (test_mask & mnt->mnt_fsnotify_mask))) { - iter_info.marks[FSNOTIFY_OBJ_TYPE_INODE ] = -fsnotify_first_mark (&to_tell->i_fsnotify_marks); + iter_info.marks[FSNOTIFY_OBJ_TYPE_INODE ] = +fsnotify_first_mark (&to_tell->i_fsnotify_marks); +if (mnt) { iter_info.marks[FSNOTIFY_OBJ_TYPE_VFSMOUNT ] =fsnotify_first_mark (&mnt->mnt_fsnotify_marks); }Signature · 1 line
2.17.1
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR