History

fanotify: simplify handling of FAN_ONDIR

fanotify mark add/remove code jumps through hoops to avoid setting the FS_ISDIR in the commulative object mask. That was just papering over a bug in fsnotify() handling of the FS_ISDIR extra flag. This bug is now fixed, so all the hoops can be removed along with the unneeded internal flag FAN_MARK_ONDIR.

Amir Goldstein committed 8 years ago

Commit a72fd221 parent 007d1e82 files · +5 −30Browse files

Unified · Split

2 files
  1. fs/notify/fanotify/fanotify_user.c +5 −27
  2. include/linux/fanotify.h +0 −3
fs/notify/fanotify/fanotify_user.c+5−27
@@ -506,18 +506,10 @@ static __u32 fanotify_mark_remove_from_mask(struct fsnotify_mark *fsn_mark, · 505 unmodified lines
506506
507507 spin_lock(&fsn_mark->lock);
508508 if (!(flags & FAN_MARK_IGNORED_MASK)) {
509− __u32 tmask = fsn_mark->mask & ~mask;
510−
511− if (flags & FAN_MARK_ONDIR)
512− tmask &= ~FAN_ONDIR;
513−
514509 oldmask = fsn_mark->mask;
515− fsn_mark->mask = tmask;
510+ fsn_mark->mask &= ~mask;
516511 } else {
517− __u32 tmask = fsn_mark->ignored_mask & ~mask;
518− if (flags & FAN_MARK_ONDIR)
519− tmask &= ~FAN_ONDIR;
520− fsn_mark->ignored_mask = tmask;
512+ fsn_mark->ignored_mask &= ~mask;
521513 }
522514 *destroy = !(fsn_mark->mask | fsn_mark->ignored_mask);
523515 spin_unlock(&fsn_mark->lock);
@@ -586,19 +578,10 @@ static __u32 fanotify_mark_add_to_mask(struct fsnotify_mark *fsn_mark, · 62 unmodified lines
586578
587579 spin_lock(&fsn_mark->lock);
588580 if (!(flags & FAN_MARK_IGNORED_MASK)) {
589− __u32 tmask = fsn_mark->mask | mask;
590−
591− if (flags & FAN_MARK_ONDIR)
592− tmask |= FAN_ONDIR;
593−
594581 oldmask = fsn_mark->mask;
595− fsn_mark->mask = tmask;
582+ fsn_mark->mask |= mask;
596583 } else {
597− __u32 tmask = fsn_mark->ignored_mask | mask;
598− if (flags & FAN_MARK_ONDIR)
599− tmask |= FAN_ONDIR;
600−
601− fsn_mark->ignored_mask = tmask;
584+ fsn_mark->ignored_mask |= mask;
602585 if (flags & FAN_MARK_IGNORED_SURV_MODIFY)
603586 fsn_mark->flags |= FSNOTIFY_MARK_FLAG_IGNORED_SURV_MODIFY;
604587 }
@@ -820,7 +803,7 @@ static int do_fanotify_mark(int fanotify_fd, unsigned int flags, __u64 mask, · 215 unmodified lines
820803 struct fsnotify_group *group;
821804 struct fd f;
822805 struct path path;
823− u32 valid_mask = FAN_ALL_EVENTS | FAN_EVENT_ON_CHILD;
806+ u32 valid_mask = FAN_ALL_EVENTS | FAN_EVENT_ON_CHILD | FAN_ONDIR;
824807 unsigned int mark_type = flags & FAN_MARK_TYPE_MASK;
825808 int ret;
826809
@@ -857,11 +840,6 @@ static int do_fanotify_mark(int fanotify_fd, unsigned int flags, __u64 mask, · 30 unmodified lines
857840 return -EINVAL;
858841 }
859842
860− if (mask & FAN_ONDIR) {
861− flags |= FAN_MARK_ONDIR;
862− mask &= ~FAN_ONDIR;
863− }
864−
865843 if (IS_ENABLED(CONFIG_FANOTIFY_ACCESS_PERMISSIONS))
866844 valid_mask |= FAN_ALL_PERM_EVENTS;
867845
include/linux/fanotify.h+0−3
@@ -4,9 +4,6 @@ · 3 unmodified lines
44
55 #include <uapi/linux/fanotify.h>
66
7−/* not valid from userspace, only kernel internal */
8−#define FAN_MARK_ONDIR 0x80000000
9−
107 #define FAN_GROUP_FLAG(group, flag) \
118 ((group)->fanotify_data.flags & (flag))
129