aboutsummaryrefslogtreecommitdiffstats
path: root/fs/notify/inotify
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2014-02-17 07:09:50 -0500
committerJan Kara <jack@suse.cz>2014-02-18 05:17:17 -0500
commit45a22f4c11fef4ecd5c61c0a299cd3f23d77be8e (patch)
treeb1f71eb3ff7209849bd27b0dbb131ea74bd7f63b /fs/notify/inotify
parent6d0abeca3242a88cab8232e4acd7e2bf088f3bc2 (diff)
inotify: Fix reporting of cookies for inotify events
My rework of handling of notification events (namely commit 7053aee26a35 "fsnotify: do not share events between notification groups") broke sending of cookies with inotify events. We didn't propagate the value passed to fsnotify() properly and passed 4 uninitialized bytes to userspace instead (so it is also an information leak). Sadly I didn't notice this during my testing because inotify cookies aren't used very much and LTP inotify tests ignore them. Fix the problem by passing the cookie value properly. Fixes: 7053aee26a3548ebaba046ae2e52396ccf56ac6c Reported-by: Vegard Nossum <vegard.nossum@oracle.com> Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/notify/inotify')
-rw-r--r--fs/notify/inotify/inotify.h2
-rw-r--r--fs/notify/inotify/inotify_fsnotify.c3
-rw-r--r--fs/notify/inotify/inotify_user.c2
3 files changed, 4 insertions, 3 deletions
diff --git a/fs/notify/inotify/inotify.h b/fs/notify/inotify/inotify.h
index 485eef3f4407..ed855ef6f077 100644
--- a/fs/notify/inotify/inotify.h
+++ b/fs/notify/inotify/inotify.h
@@ -27,6 +27,6 @@ extern int inotify_handle_event(struct fsnotify_group *group,
27 struct fsnotify_mark *inode_mark, 27 struct fsnotify_mark *inode_mark,
28 struct fsnotify_mark *vfsmount_mark, 28 struct fsnotify_mark *vfsmount_mark,
29 u32 mask, void *data, int data_type, 29 u32 mask, void *data, int data_type,
30 const unsigned char *file_name); 30 const unsigned char *file_name, u32 cookie);
31 31
32extern const struct fsnotify_ops inotify_fsnotify_ops; 32extern const struct fsnotify_ops inotify_fsnotify_ops;
diff --git a/fs/notify/inotify/inotify_fsnotify.c b/fs/notify/inotify/inotify_fsnotify.c
index d5ee56348bb8..43ab1e1a07a2 100644
--- a/fs/notify/inotify/inotify_fsnotify.c
+++ b/fs/notify/inotify/inotify_fsnotify.c
@@ -67,7 +67,7 @@ int inotify_handle_event(struct fsnotify_group *group,
67 struct fsnotify_mark *inode_mark, 67 struct fsnotify_mark *inode_mark,
68 struct fsnotify_mark *vfsmount_mark, 68 struct fsnotify_mark *vfsmount_mark,
69 u32 mask, void *data, int data_type, 69 u32 mask, void *data, int data_type,
70 const unsigned char *file_name) 70 const unsigned char *file_name, u32 cookie)
71{ 71{
72 struct inotify_inode_mark *i_mark; 72 struct inotify_inode_mark *i_mark;
73 struct inotify_event_info *event; 73 struct inotify_event_info *event;
@@ -103,6 +103,7 @@ int inotify_handle_event(struct fsnotify_group *group,
103 fsn_event = &event->fse; 103 fsn_event = &event->fse;
104 fsnotify_init_event(fsn_event, inode, mask); 104 fsnotify_init_event(fsn_event, inode, mask);
105 event->wd = i_mark->wd; 105 event->wd = i_mark->wd;
106 event->sync_cookie = cookie;
106 event->name_len = len; 107 event->name_len = len;
107 if (len) 108 if (len)
108 strcpy(event->name, file_name); 109 strcpy(event->name, file_name);
diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
index 497395c8274b..6528b5a54ca0 100644
--- a/fs/notify/inotify/inotify_user.c
+++ b/fs/notify/inotify/inotify_user.c
@@ -495,7 +495,7 @@ void inotify_ignored_and_remove_idr(struct fsnotify_mark *fsn_mark,
495 495
496 /* Queue ignore event for the watch */ 496 /* Queue ignore event for the watch */
497 inotify_handle_event(group, NULL, fsn_mark, NULL, FS_IN_IGNORED, 497 inotify_handle_event(group, NULL, fsn_mark, NULL, FS_IN_IGNORED,
498 NULL, FSNOTIFY_EVENT_NONE, NULL); 498 NULL, FSNOTIFY_EVENT_NONE, NULL, 0);
499 499
500 i_mark = container_of(fsn_mark, struct inotify_inode_mark, fsn_mark); 500 i_mark = container_of(fsn_mark, struct inotify_inode_mark, fsn_mark);
501 /* remove this mark from the idr */ 501 /* remove this mark from the idr */