From 0da740bdb53bde3fc05c7f327b15bdb7790787db Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 1 May 2008 03:52:22 +0100 Subject: [PATCH] --- yaml --- r: 95635 b: refs/heads/master c: 214b7049a7929f03bbd2786aaef04b8b79db34e2 h: refs/heads/master i: 95633: bbed3244630839dbe7c909e9ac05b6cf91660ddb 95631: 98dd82056dcf0ebb265a6e30a4030d242ca0665b v: v3 --- [refs] | 2 +- trunk/fs/dnotify.c | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index 63c3e94a6947..ec7afd7798f2 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 6d98ca736441029e4e87ad3b6dc4a8645dc4c6d3 +refs/heads/master: 214b7049a7929f03bbd2786aaef04b8b79db34e2 diff --git a/trunk/fs/dnotify.c b/trunk/fs/dnotify.c index 28d01ed66de0..eaecc4cfe540 100644 --- a/trunk/fs/dnotify.c +++ b/trunk/fs/dnotify.c @@ -20,6 +20,7 @@ #include #include #include +#include int dir_notify_enable __read_mostly = 1; @@ -66,6 +67,7 @@ int fcntl_dirnotify(int fd, struct file *filp, unsigned long arg) struct dnotify_struct **prev; struct inode *inode; fl_owner_t id = current->files; + struct file *f; int error = 0; if ((arg & ~DN_MULTISHOT) == 0) { @@ -92,6 +94,15 @@ int fcntl_dirnotify(int fd, struct file *filp, unsigned long arg) prev = &odn->dn_next; } + rcu_read_lock(); + f = fcheck(fd); + rcu_read_unlock(); + /* we'd lost the race with close(), sod off silently */ + /* note that inode->i_lock prevents reordering problems + * between accesses to descriptor table and ->i_dnotify */ + if (f != filp) + goto out_free; + error = __f_setown(filp, task_pid(current), PIDTYPE_PID, 0); if (error) goto out_free;