[PATCH 5/6] fanotify: dont set FAN_ONDIR implicitly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Currently we set the FAN_ONDIR flag in a marks ignore_mask whenever the user
wants to add something to the mask of the mark but does not explicitly specifiy
FAN_ONDIR. We also never set that flag in a marks event mask.

The problem is that even if the user has specified FAN_ONDIR with a call to
fanotify_mark() it will be set ignored as soon as a subsequent call does not
specify this flag, which may not be what the user expected.
Furthermore it is hard to ever unset FAN_ONDIR once it is set in the ignore_mask 
so that a mark will very likely not be destroyed before its group is destroyed.

With this patch FAN_ONDIR is treated as every other flag, thus if specified it 
is set in a marks event maks and no longer implicitly set in the ignore_mask. 

Signed-off-by: Lino Sanfilippo <LinoSanfilippo@xxxxxx>
---
 fs/notify/fanotify/fanotify.c      |    2 +-
 fs/notify/fanotify/fanotify_user.c |   16 +++-------------
 2 files changed, 4 insertions(+), 14 deletions(-)

diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c
index c2ba86a..72705f2 100644
--- a/fs/notify/fanotify/fanotify.c
+++ b/fs/notify/fanotify/fanotify.c
@@ -194,7 +194,7 @@ static bool fanotify_should_send_event(struct fsnotify_group *group,
 	}
 
 	if (S_ISDIR(path->dentry->d_inode->i_mode) &&
-	    (marks_ignored_mask & FS_ISDIR))
+	    !((marks_mask & ~marks_ignored_mask) & FS_ISDIR))
 		return false;
 
 	/*
diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
index 6b9606a..acf8465 100644
--- a/fs/notify/fanotify/fanotify_user.c
+++ b/fs/notify/fanotify/fanotify_user.c
@@ -603,12 +603,6 @@ static __u32 fanotify_mark_add_to_mask(struct fsnotify_mark *fsn_mark,
 		if (flags & FAN_MARK_IGNORED_SURV_MODIFY)
 			fsn_mark->flags |= FSNOTIFY_MARK_FLAG_IGNORED_SURV_MODIFY;
 	}
-
-	if (!(flags & FAN_MARK_ONDIR)) {
-		__u32 tmask = fsn_mark->ignored_mask | FAN_ONDIR;
-		fsnotify_set_mark_ignored_mask_locked(fsn_mark, tmask);
-	}
-
 	spin_unlock(&fsn_mark->lock);
 
 	return mask & ~oldmask;
@@ -832,15 +826,11 @@ SYSCALL_DEFINE(fanotify_mark)(int fanotify_fd, unsigned int flags,
 		return -EINVAL;
 	}
 
-	if (mask & FAN_ONDIR) {
-		flags |= FAN_MARK_ONDIR;
-		mask &= ~FAN_ONDIR;
-	}
-
 #ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS
-	if (mask & ~(FAN_ALL_EVENTS | FAN_ALL_PERM_EVENTS | FAN_EVENT_ON_CHILD))
+	if (mask & ~(FAN_ALL_EVENTS | FAN_ALL_PERM_EVENTS | FAN_ONDIR |
+		     FAN_EVENT_ON_CHILD))
 #else
-	if (mask & ~(FAN_ALL_EVENTS | FAN_EVENT_ON_CHILD))
+	if (mask & ~(FAN_ALL_EVENTS | FAN_ONDIR | FAN_EVENT_ON_CHILD))
 #endif
 		return -EINVAL;
 
-- 
1.5.6.5

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux