Skip to contentSkip to conversation

idr_get_new_above not working?

PATCH In review John McCutchan 2 participants 3 messages Aug 15, 2005 VFS

lore
Share & tools
lore
#0 lore raw

Hey,

Inotify is using idr_get_new_above to make sure that the next watch descriptor is larger/different than any of the previous watch descriptors. We keep track of the largest wd that we get out of idr_get_new_above, and pass that to idr_get_new_above. I have noticed though, that idr_get_new_above always returns the first available id. This causes a serious problem for inotify, because user space will get a IGNORE event for a wd K that might refer to the last holder of the K.

Signature · 1 line
John McCutchan <[email protected]>
#1 lore raw

PATCH 1/1 inotify: idr_get_new_above not working?

Quoted 7 lines · John McCutchan

Inotify is using idr_get_new_above to make sure that the next watch descriptor is larger/different than any of the previous watch descriptors. We keep track of the largest wd that we get out of idr_get_new_above, and pass that to idr_get_new_above. I have noticed though, that idr_get_new_above always returns the first available id. This causes a serious problem for inotify, because user space will get a IGNORE event for a wd K that might refer to the last holder of the K.

Turns out that the problem was in our court and not the idr layer. idr_get_new_above() seems to work fine.

One-line patch is attached. Please merge before 2.6.13.

Robert Love

We are saving the wrong thing in ->last_wd. We want the wd, not the return value.

 fs/inotify.c |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)
fs/inotify.c +1 -1
diff -urN linux-2.6.13-rc6-git2/fs/inotify.c linux/fs/inotify.c
@@ -402,7 +402,7 @@
 		return ERR_PTR(ret);
 	}
 
-	dev->last_wd = ret;
+	dev->last_wd = watch->wd;
 	watch->mask = mask;
 	atomic_set(&watch->count, 0);
 	INIT_LIST_HEAD(&watch->d_list);
#2 lore raw

Re: [patch] inotify: idr_get_new_above not working?

Quoted 10 lines · Robert Love
Quoted 7 lines · John McCutchan

Inotify is using idr_get_new_above to make sure that the next watch descriptor is larger/different than any of the previous watch descriptors. We keep track of the largest wd that we get out of idr_get_new_above, and pass that to idr_get_new_above. I have noticed though, that idr_get_new_above always returns the first available id. This causes a serious problem for inotify, because user space will get a IGNORE event for a wd K that might refer to the last holder of the K.

Quoted 4 lines

Turns out that the problem was in our court and not the idr layer. idr_get_new_above() seems to work fine.

One-line patch is attached. Please merge before 2.6.13.

My bad! Patch looks correct.

Signature · 1 line
John McCutchan <[email protected]>