summaryrefslogtreecommitdiff
blob: a186b180a9d8f81017201080817ac1b3fafaf204 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Index: linux-2.6.18.8/fs/dnotify.c
===================================================================
--- linux-2.6.18.8.orig/fs/dnotify.c
+++ linux-2.6.18.8/fs/dnotify.c
@@ -67,6 +67,9 @@ int fcntl_dirnotify(int fd, struct file 
 	struct dnotify_struct **prev;
 	struct inode *inode;
 	fl_owner_t id = current->files;
+#ifndef __GENKSYMS__
+	struct file *f;
+#endif
 	int error = 0;
 
 	if ((arg & ~DN_MULTISHOT) == 0) {
@@ -93,8 +96,13 @@ int fcntl_dirnotify(int fd, struct file 
 		prev = &odn->dn_next;
 	}
 
+	rcu_read_lock();
+	f = fcheck(fd);
+	rcu_read_unlock();
 	/* we'd lost the race with close(), sod off silently */
-	if (fcheck(fd) != filp)
+	/* 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, current->pid, 0);