Skip to content

Commit 45a22f4

Browse files
committed
inotify: Fix reporting of cookies for inotify events
My rework of handling of notification events (namely commit 7053aee "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: 7053aee Reported-by: Vegard Nossum <vegard.nossum@oracle.com> Signed-off-by: Jan Kara <jack@suse.cz>
1 parent 6d0abec commit 45a22f4

9 files changed

Lines changed: 10 additions & 9 deletions

File tree

‎fs/notify/dnotify/dnotify.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ static int dnotify_handle_event(struct fsnotify_group *group,
8686
struct fsnotify_mark *inode_mark,
8787
struct fsnotify_mark *vfsmount_mark,
8888
u32 mask, void *data, int data_type,
89-
const unsigned char *file_name)
89+
const unsigned char *file_name, u32 cookie)
9090
{
9191
struct dnotify_mark *dn_mark;
9292
struct dnotify_struct *dn;

‎fs/notify/fanotify/fanotify.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ static int fanotify_handle_event(struct fsnotify_group *group,
147147
struct fsnotify_mark *inode_mark,
148148
struct fsnotify_mark *fanotify_mark,
149149
u32 mask, void *data, int data_type,
150-
const unsigned char *file_name)
150+
const unsigned char *file_name, u32 cookie)
151151
{
152152
int ret = 0;
153153
struct fanotify_event_info *event;

‎fs/notify/fsnotify.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ static int send_to_group(struct inode *to_tell,
179179

180180
return group->ops->handle_event(group, to_tell, inode_mark,
181181
vfsmount_mark, mask, data, data_is,
182-
file_name);
182+
file_name, cookie);
183183
}
184184

185185
/*

‎fs/notify/inotify/inotify.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ extern int inotify_handle_event(struct fsnotify_group *group,
2727
struct fsnotify_mark *inode_mark,
2828
struct fsnotify_mark *vfsmount_mark,
2929
u32 mask, void *data, int data_type,
30-
const unsigned char *file_name);
30+
const unsigned char *file_name, u32 cookie);
3131

3232
extern const struct fsnotify_ops inotify_fsnotify_ops;

‎fs/notify/inotify/inotify_fsnotify.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ int inotify_handle_event(struct fsnotify_group *group,
6767
struct fsnotify_mark *inode_mark,
6868
struct fsnotify_mark *vfsmount_mark,
6969
u32 mask, void *data, int data_type,
70-
const unsigned char *file_name)
70+
const unsigned char *file_name, u32 cookie)
7171
{
7272
struct inotify_inode_mark *i_mark;
7373
struct inotify_event_info *event;
@@ -103,6 +103,7 @@ int inotify_handle_event(struct fsnotify_group *group,
103103
fsn_event = &event->fse;
104104
fsnotify_init_event(fsn_event, inode, mask);
105105
event->wd = i_mark->wd;
106+
event->sync_cookie = cookie;
106107
event->name_len = len;
107108
if (len)
108109
strcpy(event->name, file_name);

‎fs/notify/inotify/inotify_user.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ void inotify_ignored_and_remove_idr(struct fsnotify_mark *fsn_mark,
495495

496496
/* Queue ignore event for the watch */
497497
inotify_handle_event(group, NULL, fsn_mark, NULL, FS_IN_IGNORED,
498-
NULL, FSNOTIFY_EVENT_NONE, NULL);
498+
NULL, FSNOTIFY_EVENT_NONE, NULL, 0);
499499

500500
i_mark = container_of(fsn_mark, struct inotify_inode_mark, fsn_mark);
501501
/* remove this mark from the idr */

‎include/linux/fsnotify_backend.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ struct fsnotify_ops {
9999
struct fsnotify_mark *inode_mark,
100100
struct fsnotify_mark *vfsmount_mark,
101101
u32 mask, void *data, int data_type,
102-
const unsigned char *file_name);
102+
const unsigned char *file_name, u32 cookie);
103103
void (*free_group_priv)(struct fsnotify_group *group);
104104
void (*freeing_mark)(struct fsnotify_mark *mark, struct fsnotify_group *group);
105105
void (*free_event)(struct fsnotify_event *event);

‎kernel/audit_tree.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@ static int audit_tree_handle_event(struct fsnotify_group *group,
916916
struct fsnotify_mark *inode_mark,
917917
struct fsnotify_mark *vfsmount_mark,
918918
u32 mask, void *data, int data_type,
919-
const unsigned char *file_name)
919+
const unsigned char *file_name, u32 cookie)
920920
{
921921
return 0;
922922
}

‎kernel/audit_watch.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ static int audit_watch_handle_event(struct fsnotify_group *group,
471471
struct fsnotify_mark *inode_mark,
472472
struct fsnotify_mark *vfsmount_mark,
473473
u32 mask, void *data, int data_type,
474-
const unsigned char *dname)
474+
const unsigned char *dname, u32 cookie)
475475
{
476476
struct inode *inode;
477477
struct audit_parent *parent;

0 commit comments

Comments
 (0)