aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiklos Szeredi <miklos@szeredi.hu>2006-02-28 19:59:03 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-02-28 23:53:43 -0500
commit50322fe7d46b544d5649edb58bdbe5c95dd44b98 (patch)
tree0d6b61c08b2e61657278b7ff54529013f9e46d85
parent511030bcd24119fa3759ef3f914d354e107ef839 (diff)
[PATCH] fuse: fix bug in negative lookup
If negative entries (nodeid == 0) were sent in reply to LOOKUP requests, two bugs could be triggered: - looking up a negative entry would return -EIO, - revaildate on an entry which turned negative would send a FORGET request with zero nodeid, which would cause an abort() in the library. The above would only happen if the 'negative_timeout=N' option was used, otherwise lookups reply -ENOENT, which worked correctly. Signed-off-by: Miklos Szeredi <miklos@szeredi.hu> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--fs/fuse/dir.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 21fd59c7bc24..c72a8a97935c 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -111,6 +111,8 @@ static int fuse_dentry_revalidate(struct dentry *entry, struct nameidata *nd)
111 111
112 /* Doesn't hurt to "reset" the validity timeout */ 112 /* Doesn't hurt to "reset" the validity timeout */
113 fuse_invalidate_entry_cache(entry); 113 fuse_invalidate_entry_cache(entry);
114
115 /* For negative dentries, always do a fresh lookup */
114 if (!inode) 116 if (!inode)
115 return 0; 117 return 0;
116 118
@@ -122,6 +124,9 @@ static int fuse_dentry_revalidate(struct dentry *entry, struct nameidata *nd)
122 fuse_lookup_init(req, entry->d_parent->d_inode, entry, &outarg); 124 fuse_lookup_init(req, entry->d_parent->d_inode, entry, &outarg);
123 request_send(fc, req); 125 request_send(fc, req);
124 err = req->out.h.error; 126 err = req->out.h.error;
127 /* Zero nodeid is same as -ENOENT */
128 if (!err && !outarg.nodeid)
129 err = -ENOENT;
125 if (!err) { 130 if (!err) {
126 struct fuse_inode *fi = get_fuse_inode(inode); 131 struct fuse_inode *fi = get_fuse_inode(inode);
127 if (outarg.nodeid != get_node_id(inode)) { 132 if (outarg.nodeid != get_node_id(inode)) {
@@ -190,8 +195,9 @@ static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry,
190 fuse_lookup_init(req, dir, entry, &outarg); 195 fuse_lookup_init(req, dir, entry, &outarg);
191 request_send(fc, req); 196 request_send(fc, req);
192 err = req->out.h.error; 197 err = req->out.h.error;
193 if (!err && ((outarg.nodeid && invalid_nodeid(outarg.nodeid)) || 198 /* Zero nodeid is same as -ENOENT, but with valid timeout */
194 !valid_mode(outarg.attr.mode))) 199 if (!err && outarg.nodeid &&
200 (invalid_nodeid(outarg.nodeid) || !valid_mode(outarg.attr.mode)))
195 err = -EIO; 201 err = -EIO;
196 if (!err && outarg.nodeid) { 202 if (!err && outarg.nodeid) {
197 inode = fuse_iget(dir->i_sb, outarg.nodeid, outarg.generation, 203 inode = fuse_iget(dir->i_sb, outarg.nodeid, outarg.generation,