Skip to content

Commit

Permalink
fuse: readdirplus: sanity checks
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Miklos Szeredi committed Jul 17, 2013
1 parent 53ce9a3 commit a28ef45
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion fs/fuse/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit a28ef45

Please sign in to comment.