Commit a28ef45c authored by Miklos Szeredi's avatar Miklos Szeredi

fuse: readdirplus: sanity checks

Add sanity checks before adding or updating an entry with data received
from readdirplus.
Signed-off-by: default avatarMiklos Szeredi <mszeredi@suse.cz>
CC: stable@vger.kernel.org
parent 53ce9a33
...@@ -1223,6 +1223,12 @@ static int fuse_direntplus_link(struct file *file, ...@@ -1223,6 +1223,12 @@ static int fuse_direntplus_link(struct file *file,
if (name.name[1] == '.' && name.len == 2) if (name.name[1] == '.' && name.len == 2)
return 0; return 0;
} }
if (invalid_nodeid(o->nodeid))
return -EIO;
if (!fuse_valid_type(o->attr.mode))
return -EIO;
fc = get_fuse_conn(dir); fc = get_fuse_conn(dir);
name.hash = full_name_hash(name.name, name.len); name.hash = full_name_hash(name.name, name.len);
...@@ -1231,10 +1237,14 @@ static int fuse_direntplus_link(struct file *file, ...@@ -1231,10 +1237,14 @@ static int fuse_direntplus_link(struct file *file,
inode = dentry->d_inode; inode = dentry->d_inode;
if (!inode) { if (!inode) {
d_drop(dentry); 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); err = d_invalidate(dentry);
if (err) if (err)
goto out; goto out;
} else if (is_bad_inode(inode)) {
err = -EIO;
goto out;
} else { } else {
struct fuse_inode *fi; struct fuse_inode *fi;
fi = get_fuse_inode(inode); fi = get_fuse_inode(inode);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment