aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2009-08-29 01:39:44 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-08-29 01:39:44 -0400
commit8442edc18843491978f7820f87dbdf293461290e (patch)
tree87052e51e6398843799511e009159e27bda2aee1
parent825e1e23914b9c3dbc49ee8c5a1d1cb421c1270a (diff)
parent750a8870fe4016ef3091fc97e084d58c613c2cc7 (diff)
Merge branch 'for-linus' of git://git.infradead.org/users/eparis/notify
* 'for-linus' of git://git.infradead.org/users/eparis/notify: inotify: update the group mask on mark addition inotify: fix length reporting and size checking inotify: do not send a block of zeros when no pathname is available
-rw-r--r--fs/notify/inotify/inotify_user.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
index 0e781bc88d1e..dcd2040d330c 100644
--- a/fs/notify/inotify/inotify_user.c
+++ b/fs/notify/inotify/inotify_user.c
@@ -154,7 +154,8 @@ static struct fsnotify_event *get_one_event(struct fsnotify_group *group,
154 154
155 event = fsnotify_peek_notify_event(group); 155 event = fsnotify_peek_notify_event(group);
156 156
157 event_size += roundup(event->name_len, event_size); 157 if (event->name_len)
158 event_size += roundup(event->name_len + 1, event_size);
158 159
159 if (event_size > count) 160 if (event_size > count)
160 return ERR_PTR(-EINVAL); 161 return ERR_PTR(-EINVAL);
@@ -180,7 +181,7 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
180 struct fsnotify_event_private_data *fsn_priv; 181 struct fsnotify_event_private_data *fsn_priv;
181 struct inotify_event_private_data *priv; 182 struct inotify_event_private_data *priv;
182 size_t event_size = sizeof(struct inotify_event); 183 size_t event_size = sizeof(struct inotify_event);
183 size_t name_len; 184 size_t name_len = 0;
184 185
185 /* we get the inotify watch descriptor from the event private data */ 186 /* we get the inotify watch descriptor from the event private data */
186 spin_lock(&event->lock); 187 spin_lock(&event->lock);
@@ -196,10 +197,12 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
196 inotify_free_event_priv(fsn_priv); 197 inotify_free_event_priv(fsn_priv);
197 } 198 }
198 199
199 /* round up event->name_len so it is a multiple of event_size 200 /*
201 * round up event->name_len so it is a multiple of event_size
200 * plus an extra byte for the terminating '\0'. 202 * plus an extra byte for the terminating '\0'.
201 */ 203 */
202 name_len = roundup(event->name_len + 1, event_size); 204 if (event->name_len)
205 name_len = roundup(event->name_len + 1, event_size);
203 inotify_event.len = name_len; 206 inotify_event.len = name_len;
204 207
205 inotify_event.mask = inotify_mask_to_arg(event->mask); 208 inotify_event.mask = inotify_mask_to_arg(event->mask);
@@ -325,8 +328,9 @@ static long inotify_ioctl(struct file *file, unsigned int cmd,
325 list_for_each_entry(holder, &group->notification_list, event_list) { 328 list_for_each_entry(holder, &group->notification_list, event_list) {
326 event = holder->event; 329 event = holder->event;
327 send_len += sizeof(struct inotify_event); 330 send_len += sizeof(struct inotify_event);
328 send_len += roundup(event->name_len, 331 if (event->name_len)
329 sizeof(struct inotify_event)); 332 send_len += roundup(event->name_len + 1,
333 sizeof(struct inotify_event));
330 } 334 }
331 mutex_unlock(&group->notification_mutex); 335 mutex_unlock(&group->notification_mutex);
332 ret = put_user(send_len, (int __user *) p); 336 ret = put_user(send_len, (int __user *) p);
@@ -587,6 +591,10 @@ retry:
587 /* match the ref from fsnotify_init_markentry() */ 591 /* match the ref from fsnotify_init_markentry() */
588 fsnotify_put_mark(&tmp_ientry->fsn_entry); 592 fsnotify_put_mark(&tmp_ientry->fsn_entry);
589 593
594 /* if this mark added a new event update the group mask */
595 if (mask & ~group->mask)
596 fsnotify_recalc_group_mask(group);
597
590out_err: 598out_err:
591 if (ret < 0) 599 if (ret < 0)
592 kmem_cache_free(inotify_inode_mark_cachep, tmp_ientry); 600 kmem_cache_free(inotify_inode_mark_cachep, tmp_ientry);