fanotify: Move recalculation of inode / vfsmount mask under mark_mutex
Move recalculation of inode / vfsmount notification mask under group->mark_mutex of the mark which was modified. These are the only places where mask recalculation happens without mark being protected from detaching from inode / vfsmount which will cause issues with the following patches. Reviewed-by: Miklos Szeredi <mszeredi@redhat.com> Reviewed-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Jan Kara <jack@suse.cz>
This commit is contained in:
parent
25c829afbd
commit
c97476400d
|
@ -542,6 +542,8 @@ static int fanotify_remove_vfsmount_mark(struct fsnotify_group *group,
|
|||
|
||||
removed = fanotify_mark_remove_from_mask(fsn_mark, mask, flags,
|
||||
&destroy_mark);
|
||||
if (removed & real_mount(mnt)->mnt_fsnotify_mask)
|
||||
fsnotify_recalc_vfsmount_mask(mnt);
|
||||
if (destroy_mark)
|
||||
fsnotify_detach_mark(fsn_mark);
|
||||
mutex_unlock(&group->mark_mutex);
|
||||
|
@ -549,9 +551,6 @@ static int fanotify_remove_vfsmount_mark(struct fsnotify_group *group,
|
|||
fsnotify_free_mark(fsn_mark);
|
||||
|
||||
fsnotify_put_mark(fsn_mark);
|
||||
if (removed & real_mount(mnt)->mnt_fsnotify_mask)
|
||||
fsnotify_recalc_vfsmount_mask(mnt);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -572,6 +571,8 @@ static int fanotify_remove_inode_mark(struct fsnotify_group *group,
|
|||
|
||||
removed = fanotify_mark_remove_from_mask(fsn_mark, mask, flags,
|
||||
&destroy_mark);
|
||||
if (removed & inode->i_fsnotify_mask)
|
||||
fsnotify_recalc_inode_mask(inode);
|
||||
if (destroy_mark)
|
||||
fsnotify_detach_mark(fsn_mark);
|
||||
mutex_unlock(&group->mark_mutex);
|
||||
|
@ -580,8 +581,6 @@ static int fanotify_remove_inode_mark(struct fsnotify_group *group,
|
|||
|
||||
/* matches the fsnotify_find_inode_mark() */
|
||||
fsnotify_put_mark(fsn_mark);
|
||||
if (removed & inode->i_fsnotify_mask)
|
||||
fsnotify_recalc_inode_mask(inode);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -657,10 +656,9 @@ static int fanotify_add_vfsmount_mark(struct fsnotify_group *group,
|
|||
}
|
||||
}
|
||||
added = fanotify_mark_add_to_mask(fsn_mark, mask, flags);
|
||||
mutex_unlock(&group->mark_mutex);
|
||||
|
||||
if (added & ~real_mount(mnt)->mnt_fsnotify_mask)
|
||||
fsnotify_recalc_vfsmount_mask(mnt);
|
||||
mutex_unlock(&group->mark_mutex);
|
||||
|
||||
fsnotify_put_mark(fsn_mark);
|
||||
return 0;
|
||||
|
@ -695,10 +693,9 @@ static int fanotify_add_inode_mark(struct fsnotify_group *group,
|
|||
}
|
||||
}
|
||||
added = fanotify_mark_add_to_mask(fsn_mark, mask, flags);
|
||||
mutex_unlock(&group->mark_mutex);
|
||||
|
||||
if (added & ~inode->i_fsnotify_mask)
|
||||
fsnotify_recalc_inode_mask(inode);
|
||||
mutex_unlock(&group->mark_mutex);
|
||||
|
||||
fsnotify_put_mark(fsn_mark);
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue