summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiklos Szeredi <mszeredi@suse.cz>2013-07-17 14:53:53 +0200
committerMiklos Szeredi <mszeredi@suse.cz>2013-07-17 14:53:53 +0200
commita28ef45cbb1e7fadd5159deb17b02de15c6e4aaf (patch)
treee8d90f874259b6fc442b38eafdb59b7106b42934
parentfuse: readdirplus: fix dentry leak (diff)
downloadlinux-a28ef45cbb1e7fadd5159deb17b02de15c6e4aaf.tar.xz
linux-a28ef45cbb1e7fadd5159deb17b02de15c6e4aaf.zip
fuse: readdirplus: sanity checks
Add sanity checks before adding or updating an entry with data received from readdirplus. Signed-off-by: Miklos Szeredi <mszeredi@suse.cz> CC: stable@vger.kernel.org
-rw-r--r--fs/fuse/dir.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 2ae5308174e2..bb6829720dd6 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -1223,6 +1223,12 @@ static int fuse_direntplus_link(struct file *file,
if (name.name[1] == '.' && name.len == 2)
return 0;
}
+
+ if (invalid_nodeid(o->nodeid))
+ return -EIO;
+ if (!fuse_valid_type(o->attr.mode))
+ return -EIO;
+
fc = get_fuse_conn(dir);
name.hash = full_name_hash(name.name, name.len);
@@ -1231,10 +1237,14 @@ static int fuse_direntplus_link(struct file *file,
inode = dentry->d_inode;
if (!inode) {
d_drop(dentry);
- } else if (get_node_id(inode) != o->nodeid) {
+ } else if (get_node_id(inode) != o->nodeid ||
+ ((o->attr.mode ^ inode->i_mode) & S_IFMT)) {
err = d_invalidate(dentry);
if (err)
goto out;
+ } else if (is_bad_inode(inode)) {
+ err = -EIO;
+ goto out;
} else {
struct fuse_inode *fi;
fi = get_fuse_inode(inode);