All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] inotify: do not send a block of zeros when no pathname is available
@ 2009-08-28 17:20 Eric Paris
  2009-08-28 17:20 ` [PATCH 2/3] inotify: fix length reporting and size checking Eric Paris
  2009-08-28 17:20 ` [PATCH 3/3] inotify: update the group mask on mark addition Eric Paris
  0 siblings, 2 replies; 3+ messages in thread
From: Eric Paris @ 2009-08-28 17:20 UTC (permalink / raw)
  To: linux-kernel

From: Brian Rogers <brian@xyzw.org>

When an event has no pathname, there's no need to pad it with a null byte and
therefore generate an inotify_event sized block of zeros. This fixes a
regression introduced by commit 0db501bd0610ee0c0aca84d927f90bcccd09e2bd where
my system wouldn't finish booting because some process was being confused by
this.

Signed-off-by: Brian Rogers <brian@xyzw.org>
Signed-off-by: Eric Paris <eparis@redhat.com>
---

 fs/notify/inotify/inotify_user.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
index 0e781bc..b547ae1 100644
--- a/fs/notify/inotify/inotify_user.c
+++ b/fs/notify/inotify/inotify_user.c
@@ -180,7 +180,7 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
 	struct fsnotify_event_private_data *fsn_priv;
 	struct inotify_event_private_data *priv;
 	size_t event_size = sizeof(struct inotify_event);
-	size_t name_len;
+	size_t name_len = 0;
 
 	/* we get the inotify watch descriptor from the event private data */
 	spin_lock(&event->lock);
@@ -196,10 +196,12 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
 		inotify_free_event_priv(fsn_priv);
 	}
 
-	/* round up event->name_len so it is a multiple of event_size
+	/*
+	 * round up event->name_len so it is a multiple of event_size
 	 * plus an extra byte for the terminating '\0'.
 	 */
-	name_len = roundup(event->name_len + 1, event_size);
+	if (event->name_len)
+		name_len = roundup(event->name_len + 1, event_size);
 	inotify_event.len = name_len;
 
 	inotify_event.mask = inotify_mask_to_arg(event->mask);


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/3] inotify: fix length reporting and size checking
  2009-08-28 17:20 [PATCH 1/3] inotify: do not send a block of zeros when no pathname is available Eric Paris
@ 2009-08-28 17:20 ` Eric Paris
  2009-08-28 17:20 ` [PATCH 3/3] inotify: update the group mask on mark addition Eric Paris
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Paris @ 2009-08-28 17:20 UTC (permalink / raw)
  To: linux-kernel

0db501bd0610ee0c0 introduced a regresion in that it now sends a nul
terminator but the length accounting when checking for space or
reporting to userspace did not take this into account.  This corrects
all of the rounding logic.

Signed-off-by: Eric Paris <eparis@redhat.com>
---

 fs/notify/inotify/inotify_user.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
index b547ae1..6111670 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,
 
 	event = fsnotify_peek_notify_event(group);
 
-	event_size += roundup(event->name_len, event_size);
+	if (event->name_len)
+		event_size += roundup(event->name_len + 1, event_size);
 
 	if (event_size > count)
 		return ERR_PTR(-EINVAL);
@@ -327,8 +328,9 @@ static long inotify_ioctl(struct file *file, unsigned int cmd,
 		list_for_each_entry(holder, &group->notification_list, event_list) {
 			event = holder->event;
 			send_len += sizeof(struct inotify_event);
-			send_len += roundup(event->name_len,
-					     sizeof(struct inotify_event));
+			if (event->name_len)
+				send_len += roundup(event->name_len + 1,
+						sizeof(struct inotify_event));
 		}
 		mutex_unlock(&group->notification_mutex);
 		ret = put_user(send_len, (int __user *) p);


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 3/3] inotify: update the group mask on mark addition
  2009-08-28 17:20 [PATCH 1/3] inotify: do not send a block of zeros when no pathname is available Eric Paris
  2009-08-28 17:20 ` [PATCH 2/3] inotify: fix length reporting and size checking Eric Paris
@ 2009-08-28 17:20 ` Eric Paris
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Paris @ 2009-08-28 17:20 UTC (permalink / raw)
  To: linux-kernel

Seperating the addition and update of marks in inotify resulted in a
regression in that inotify never gets events.  The inotify group mask is
always 0.  This mask should be updated any time a new mark is added.

Signed-off-by: Eric Paris <eparis@redhat.com>
---

 fs/notify/inotify/inotify_user.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
index 6111670..dcd2040 100644
--- a/fs/notify/inotify/inotify_user.c
+++ b/fs/notify/inotify/inotify_user.c
@@ -591,6 +591,10 @@ retry:
 	/* match the ref from fsnotify_init_markentry() */
 	fsnotify_put_mark(&tmp_ientry->fsn_entry);
 
+	/* if this mark added a new event update the group mask */
+	if (mask & ~group->mask)
+		fsnotify_recalc_group_mask(group);
+
 out_err:
 	if (ret < 0)
 		kmem_cache_free(inotify_inode_mark_cachep, tmp_ientry);


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-08-28 17:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-28 17:20 [PATCH 1/3] inotify: do not send a block of zeros when no pathname is available Eric Paris
2009-08-28 17:20 ` [PATCH 2/3] inotify: fix length reporting and size checking Eric Paris
2009-08-28 17:20 ` [PATCH 3/3] inotify: update the group mask on mark addition Eric Paris

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.