Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Szeredi <mszeredi@redhat.com>2016-10-01 07:32:32 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-10-22 12:06:47 +0200
commitd902d889db76fb07d9dc7d605fef6b427b89e8ca (patch)
treea5e592f2816e1f4a00a29d3f3680b92dcee29a40
parent74589581898e4df964dceacc73aa887169085ba8 (diff)
fuse: listxattr: verify xattr list
commit cb3ae6d25a5471be62bfe6ac1fccc0e91edeaba0 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: Miklos Szeredi <mszeredi@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--fs/fuse/dir.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index cca7b048c07b..8980931e1dd2 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -1800,6 +1800,23 @@ static ssize_t fuse_getxattr(struct dentry *entry, struct inode *inode,
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)
{
struct inode *inode = d_inode(entry);
@@ -1835,6 +1852,8 @@ static ssize_t fuse_listxattr(struct dentry *entry, char *list, size_t size)
ret = fuse_simple_request(fc, &args);
if (!ret && !size)
ret = outarg.size;
+ if (ret > 0 && size)
+ ret = fuse_verify_xattr_list(list, ret);
if (ret == -ENOSYS) {
fc->no_listxattr = 1;
ret = -EOPNOTSUPP;