diff options
author | Jan Kara <jack@suse.cz> | 2014-02-17 07:09:50 -0500 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2014-02-18 05:17:17 -0500 |
commit | 45a22f4c11fef4ecd5c61c0a299cd3f23d77be8e (patch) | |
tree | b1f71eb3ff7209849bd27b0dbb131ea74bd7f63b /fs/notify | |
parent | 6d0abeca3242a88cab8232e4acd7e2bf088f3bc2 (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')
-rw-r--r-- | fs/notify/dnotify/dnotify.c | 2 | ||||
-rw-r--r-- | fs/notify/fanotify/fanotify.c | 2 | ||||
-rw-r--r-- | fs/notify/fsnotify.c | 2 | ||||
-rw-r--r-- | fs/notify/inotify/inotify.h | 2 | ||||
-rw-r--r-- | fs/notify/inotify/inotify_fsnotify.c | 3 | ||||
-rw-r--r-- | fs/notify/inotify/inotify_user.c | 2 |
6 files changed, 7 insertions, 6 deletions
diff --git a/fs/notify/dnotify/dnotify.c b/fs/notify/dnotify/dnotify.c index 0b9ff4395e6a..abc8cbcfe90e 100644 --- a/fs/notify/dnotify/dnotify.c +++ b/fs/notify/dnotify/dnotify.c | |||
@@ -86,7 +86,7 @@ static int dnotify_handle_event(struct fsnotify_group *group, | |||
86 | struct fsnotify_mark *inode_mark, | 86 | struct fsnotify_mark *inode_mark, |
87 | struct fsnotify_mark *vfsmount_mark, | 87 | struct fsnotify_mark *vfsmount_mark, |
88 | u32 mask, void *data, int data_type, | 88 | u32 mask, void *data, int data_type, |
89 | const unsigned char *file_name) | 89 | const unsigned char *file_name, u32 cookie) |
90 | { | 90 | { |
91 | struct dnotify_mark *dn_mark; | 91 | struct dnotify_mark *dn_mark; |
92 | struct dnotify_struct *dn; | 92 | struct dnotify_struct *dn; |
diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c index 0e792f5e3147..205dc2163822 100644 --- a/fs/notify/fanotify/fanotify.c +++ b/fs/notify/fanotify/fanotify.c | |||
@@ -147,7 +147,7 @@ static int fanotify_handle_event(struct fsnotify_group *group, | |||
147 | struct fsnotify_mark *inode_mark, | 147 | struct fsnotify_mark *inode_mark, |
148 | struct fsnotify_mark *fanotify_mark, | 148 | struct fsnotify_mark *fanotify_mark, |
149 | u32 mask, void *data, int data_type, | 149 | u32 mask, void *data, int data_type, |
150 | const unsigned char *file_name) | 150 | const unsigned char *file_name, u32 cookie) |
151 | { | 151 | { |
152 | int ret = 0; | 152 | int ret = 0; |
153 | struct fanotify_event_info *event; | 153 | struct fanotify_event_info *event; |
diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c index 1d4e1ea2f37c..9d3e9c50066a 100644 --- a/fs/notify/fsnotify.c +++ b/fs/notify/fsnotify.c | |||
@@ -179,7 +179,7 @@ static int send_to_group(struct inode *to_tell, | |||
179 | 179 | ||
180 | return group->ops->handle_event(group, to_tell, inode_mark, | 180 | return group->ops->handle_event(group, to_tell, inode_mark, |
181 | vfsmount_mark, mask, data, data_is, | 181 | vfsmount_mark, mask, data, data_is, |
182 | file_name); | 182 | file_name, cookie); |
183 | } | 183 | } |
184 | 184 | ||
185 | /* | 185 | /* |
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 | ||
32 | extern const struct fsnotify_ops inotify_fsnotify_ops; | 32 | extern 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 */ |