Commit b60c85b4 authored by Miklos Szeredi's avatar Miklos Szeredi Committed by Ben Hutchings

fuse: listxattr: verify xattr list

commit cb3ae6d2 upstream.

Make sure userspace filesystem is returning a well formed list of xattr
names (zero or more nonzero length, null terminated strings).

[Michael Theall: only verify in the nonzero size case]
Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
[bwh: Backported to 3.2: adjust context, indentation]
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent 93d39020
...@@ -1536,6 +1536,23 @@ static ssize_t fuse_getxattr(struct dentry *entry, const char *name, ...@@ -1536,6 +1536,23 @@ static ssize_t fuse_getxattr(struct dentry *entry, const char *name,
return ret; return ret;
} }
static int fuse_verify_xattr_list(char *list, size_t size)
{
size_t origsize = size;
while (size) {
size_t thislen = strnlen(list, size);
if (!thislen || thislen == size)
return -EIO;
size -= thislen + 1;
list += thislen + 1;
}
return origsize;
}
static ssize_t fuse_listxattr(struct dentry *entry, char *list, size_t size) static ssize_t fuse_listxattr(struct dentry *entry, char *list, size_t size)
{ {
struct inode *inode = entry->d_inode; struct inode *inode = entry->d_inode;
...@@ -1574,9 +1591,11 @@ static ssize_t fuse_listxattr(struct dentry *entry, char *list, size_t size) ...@@ -1574,9 +1591,11 @@ static ssize_t fuse_listxattr(struct dentry *entry, char *list, size_t size)
} }
fuse_request_send(fc, req); fuse_request_send(fc, req);
ret = req->out.h.error; ret = req->out.h.error;
if (!ret) if (!ret) {
ret = size ? req->out.args[0].size : outarg.size; ret = size ? req->out.args[0].size : outarg.size;
else { if (ret > 0 && size)
ret = fuse_verify_xattr_list(list, ret);
} else {
if (ret == -ENOSYS) { if (ret == -ENOSYS) {
fc->no_listxattr = 1; fc->no_listxattr = 1;
ret = -EOPNOTSUPP; ret = -EOPNOTSUPP;
......
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