@@ -1081,42 +1081,45 @@ static int fanotify_remove_inode_mark(struct fsnotify_group *group,
10811081 flags , umask );
10821082}
10831083
1084- static void fanotify_mark_add_ignored_mask (struct fsnotify_mark * fsn_mark ,
1085- __u32 mask , unsigned int flags ,
1086- __u32 * removed )
1084+ static bool fanotify_mark_update_flags (struct fsnotify_mark * fsn_mark ,
1085+ unsigned int fan_flags )
10871086{
1088- fsn_mark -> ignored_mask |= mask ;
1087+ bool recalc = false ;
10891088
10901089 /*
10911090 * Setting FAN_MARK_IGNORED_SURV_MODIFY for the first time may lead to
10921091 * the removal of the FS_MODIFY bit in calculated mask if it was set
10931092 * because of an ignored mask that is now going to survive FS_MODIFY.
10941093 */
1095- if ((flags & FAN_MARK_IGNORED_SURV_MODIFY ) &&
1094+ if ((fan_flags & FAN_MARK_IGNORED_MASK ) &&
1095+ (fan_flags & FAN_MARK_IGNORED_SURV_MODIFY ) &&
10961096 !(fsn_mark -> flags & FSNOTIFY_MARK_FLAG_IGNORED_SURV_MODIFY )) {
10971097 fsn_mark -> flags |= FSNOTIFY_MARK_FLAG_IGNORED_SURV_MODIFY ;
10981098 if (!(fsn_mark -> mask & FS_MODIFY ))
1099- * removed = FS_MODIFY ;
1099+ recalc = true ;
11001100 }
1101+
1102+ return recalc ;
11011103}
11021104
1103- static __u32 fanotify_mark_add_to_mask (struct fsnotify_mark * fsn_mark ,
1104- __u32 mask , unsigned int flags ,
1105- __u32 * removed )
1105+ static bool fanotify_mark_add_to_mask (struct fsnotify_mark * fsn_mark ,
1106+ __u32 mask , unsigned int fan_flags )
11061107{
1107- __u32 oldmask , newmask ;
1108+ bool recalc ;
11081109
11091110 spin_lock (& fsn_mark -> lock );
1110- oldmask = fsnotify_calc_mask (fsn_mark );
1111- if (!(flags & FAN_MARK_IGNORED_MASK )) {
1111+ if (!(fan_flags & FAN_MARK_IGNORED_MASK ))
11121112 fsn_mark -> mask |= mask ;
1113- } else {
1114- fanotify_mark_add_ignored_mask (fsn_mark , mask , flags , removed );
1115- }
1116- newmask = fsnotify_calc_mask (fsn_mark );
1113+ else
1114+ fsn_mark -> ignored_mask |= mask ;
1115+
1116+ recalc = fsnotify_calc_mask (fsn_mark ) &
1117+ ~fsnotify_conn_mask (fsn_mark -> connector );
1118+
1119+ recalc |= fanotify_mark_update_flags (fsn_mark , fan_flags );
11171120 spin_unlock (& fsn_mark -> lock );
11181121
1119- return newmask & ~ oldmask ;
1122+ return recalc ;
11201123}
11211124
11221125static struct fsnotify_mark * fanotify_add_new_mark (struct fsnotify_group * group ,
@@ -1170,11 +1173,11 @@ static int fanotify_group_init_error_pool(struct fsnotify_group *group)
11701173
11711174static int fanotify_add_mark (struct fsnotify_group * group ,
11721175 fsnotify_connp_t * connp , unsigned int obj_type ,
1173- __u32 mask , unsigned int flags ,
1176+ __u32 mask , unsigned int fan_flags ,
11741177 __kernel_fsid_t * fsid )
11751178{
11761179 struct fsnotify_mark * fsn_mark ;
1177- __u32 added , removed = 0 ;
1180+ bool recalc ;
11781181 int ret = 0 ;
11791182
11801183 mutex_lock (& group -> mark_mutex );
@@ -1191,14 +1194,14 @@ static int fanotify_add_mark(struct fsnotify_group *group,
11911194 * Error events are pre-allocated per group, only if strictly
11921195 * needed (i.e. FAN_FS_ERROR was requested).
11931196 */
1194- if (!(flags & FAN_MARK_IGNORED_MASK ) && (mask & FAN_FS_ERROR )) {
1197+ if (!(fan_flags & FAN_MARK_IGNORED_MASK ) && (mask & FAN_FS_ERROR )) {
11951198 ret = fanotify_group_init_error_pool (group );
11961199 if (ret )
11971200 goto out ;
11981201 }
11991202
1200- added = fanotify_mark_add_to_mask (fsn_mark , mask , flags , & removed );
1201- if (removed || ( added & ~ fsnotify_conn_mask ( fsn_mark -> connector )) )
1203+ recalc = fanotify_mark_add_to_mask (fsn_mark , mask , fan_flags );
1204+ if (recalc )
12021205 fsnotify_recalc_mask (fsn_mark -> connector );
12031206
12041207out :
0 commit comments