diff options
author | Miklos Szeredi <mszeredi@suse.cz> | 2013-07-17 08:53:53 -0400 |
---|---|---|
committer | Miklos Szeredi <mszeredi@suse.cz> | 2013-07-17 08:53:53 -0400 |
commit | a28ef45cbb1e7fadd5159deb17b02de15c6e4aaf (patch) | |
tree | e8d90f874259b6fc442b38eafdb59b7106b42934 /fs/fuse/dir.c | |
parent | 53ce9a3364de0723b27d861de93bfc882f7db050 (diff) |
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
Diffstat (limited to 'fs/fuse/dir.c')
-rw-r--r-- | fs/fuse/dir.c | 12 |
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, | |||
1223 | if (name.name[1] == '.' && name.len == 2) | 1223 | if (name.name[1] == '.' && name.len == 2) |
1224 | return 0; | 1224 | return 0; |
1225 | } | 1225 | } |
1226 | |||
1227 | if (invalid_nodeid(o->nodeid)) | ||
1228 | return -EIO; | ||
1229 | if (!fuse_valid_type(o->attr.mode)) | ||
1230 | return -EIO; | ||
1231 | |||
1226 | fc = get_fuse_conn(dir); | 1232 | fc = get_fuse_conn(dir); |
1227 | 1233 | ||
1228 | name.hash = full_name_hash(name.name, name.len); | 1234 | name.hash = full_name_hash(name.name, name.len); |
@@ -1231,10 +1237,14 @@ static int fuse_direntplus_link(struct file *file, | |||
1231 | inode = dentry->d_inode; | 1237 | inode = dentry->d_inode; |
1232 | if (!inode) { | 1238 | if (!inode) { |
1233 | d_drop(dentry); | 1239 | d_drop(dentry); |
1234 | } else if (get_node_id(inode) != o->nodeid) { | 1240 | } else if (get_node_id(inode) != o->nodeid || |
1241 | ((o->attr.mode ^ inode->i_mode) & S_IFMT)) { | ||
1235 | err = d_invalidate(dentry); | 1242 | err = d_invalidate(dentry); |
1236 | if (err) | 1243 | if (err) |
1237 | goto out; | 1244 | goto out; |
1245 | } else if (is_bad_inode(inode)) { | ||
1246 | err = -EIO; | ||
1247 | goto out; | ||
1238 | } else { | 1248 | } else { |
1239 | struct fuse_inode *fi; | 1249 | struct fuse_inode *fi; |
1240 | fi = get_fuse_inode(inode); | 1250 | fi = get_fuse_inode(inode); |