* [BUGFIX] dnotify: handle_event shouldn't match on FS_EVENT_ON_CHILD
@ 2009-10-18 12:46 Andreas Gruenbacher
2009-10-18 12:49 ` Andreas Gruenbacher
2009-10-18 15:52 ` Eric Paris
0 siblings, 2 replies; 4+ messages in thread
From: Andreas Gruenbacher @ 2009-10-18 12:46 UTC (permalink / raw)
To: Linus Torvalds; +Cc: linux-kernel, Andrew Morton, Eric Paris
Mask off FS_EVENT_ON_CHILD in dnotify_handle_event(). Otherwise, when there
is more than one watch on a directory and dnotify_should_send_event()
succeeds, events with FS_EVENT_ON_CHILD set will trigger all watches and cause
spurious events.
This case was overlooked in commit e42e2773.
Signed-off-by: Andreas Gruenbacher <agruen@suse.de>
---
fs/notify/dnotify/dnotify.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/fs/notify/dnotify/dnotify.c b/fs/notify/dnotify/dnotify.c
index 828a889..0a8f1de 100644
--- a/fs/notify/dnotify/dnotify.c
+++ b/fs/notify/dnotify/dnotify.c
@@ -106,7 +106,7 @@ static int dnotify_handle_event(struct fsnotify_group *group,
spin_lock(&entry->lock);
prev = &dnentry->dn;
while ((dn = *prev) != NULL) {
- if ((dn->dn_mask & event->mask) == 0) {
+ if ((dn->dn_mask & event->mask & ~FS_EVENT_ON_CHILD) == 0) {
prev = &dn->dn_next;
continue;
}
--
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [BUGFIX] dnotify: handle_event shouldn't match on FS_EVENT_ON_CHILD
2009-10-18 12:46 [BUGFIX] dnotify: handle_event shouldn't match on FS_EVENT_ON_CHILD Andreas Gruenbacher
@ 2009-10-18 12:49 ` Andreas Gruenbacher
2009-10-18 15:52 ` Eric Paris
1 sibling, 0 replies; 4+ messages in thread
From: Andreas Gruenbacher @ 2009-10-18 12:49 UTC (permalink / raw)
To: Linus Torvalds; +Cc: linux-kernel, Andrew Morton, Eric Paris
Test case demonstrating the bug:
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
static void create_event(int s, siginfo_t* si, void* p)
{
printf("create\n");
}
static void delete_event(int s, siginfo_t* si, void* p)
{
printf("delete\n");
}
int main (void) {
struct sigaction action;
char *tmpdir, *file;
int fd1, fd2;
sigemptyset (&action.sa_mask);
action.sa_flags = SA_SIGINFO;
action.sa_sigaction = create_event;
sigaction (SIGRTMIN + 0, &action, NULL);
action.sa_sigaction = delete_event;
sigaction (SIGRTMIN + 1, &action, NULL);
# define TMPDIR "/tmp/test.XXXXXX"
tmpdir = malloc(strlen(TMPDIR) + 1);
strcpy(tmpdir, TMPDIR);
mkdtemp(tmpdir);
# define TMPFILE "file"
file = malloc(strlen(tmpdir) + strlen(TMPFILE) + 2);
sprintf(file, "%s/%s", tmpdir, TMPFILE);
fd1 = open (tmpdir, O_RDONLY);
fcntl(fd1, F_SETSIG, SIGRTMIN);
fcntl(fd1, F_NOTIFY, DN_MULTISHOT | DN_CREATE);
fd2 = open (tmpdir, O_RDONLY);
fcntl(fd2, F_SETSIG, SIGRTMIN + 1);
fcntl(fd2, F_NOTIFY, DN_MULTISHOT | DN_DELETE);
if (fork()) {
creat(file, 0600);
/* Spurious event triggered below! */
unlink(file);
} else {
sleep(1);
rmdir(tmpdir);
}
return 0;
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [BUGFIX] dnotify: handle_event shouldn't match on FS_EVENT_ON_CHILD
2009-10-18 12:46 [BUGFIX] dnotify: handle_event shouldn't match on FS_EVENT_ON_CHILD Andreas Gruenbacher
2009-10-18 12:49 ` Andreas Gruenbacher
@ 2009-10-18 15:52 ` Eric Paris
2009-10-18 19:22 ` Andreas Gruenbacher
1 sibling, 1 reply; 4+ messages in thread
From: Eric Paris @ 2009-10-18 15:52 UTC (permalink / raw)
To: Andreas Gruenbacher; +Cc: Linus Torvalds, linux-kernel, Andrew Morton
On Sun, 2009-10-18 at 14:46 +0200, Andreas Gruenbacher wrote:
> Mask off FS_EVENT_ON_CHILD in dnotify_handle_event(). Otherwise, when there
> is more than one watch on a directory and dnotify_should_send_event()
> succeeds, events with FS_EVENT_ON_CHILD set will trigger all watches and cause
> spurious events.
Added to my linus tree last night (along with a couple other fixes) will
push it public and ask him to pull when I finish testing.
-Eric
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [BUGFIX] dnotify: handle_event shouldn't match on FS_EVENT_ON_CHILD
2009-10-18 15:52 ` Eric Paris
@ 2009-10-18 19:22 ` Andreas Gruenbacher
0 siblings, 0 replies; 4+ messages in thread
From: Andreas Gruenbacher @ 2009-10-18 19:22 UTC (permalink / raw)
To: Eric Paris; +Cc: Linus Torvalds, linux-kernel, Andrew Morton
On Sunday, 18 October 2009 17:52:10 Eric Paris wrote:
> Added to my linus tree last night (along with a couple other fixes) will
> push it public and ask him to pull when I finish testing.
Thanks.
Andreas
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-10-18 19:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-18 12:46 [BUGFIX] dnotify: handle_event shouldn't match on FS_EVENT_ON_CHILD Andreas Gruenbacher
2009-10-18 12:49 ` Andreas Gruenbacher
2009-10-18 15:52 ` Eric Paris
2009-10-18 19:22 ` Andreas Gruenbacher
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.