fuse: readdir: check for slash in names
authorMiklos Szeredi <mszeredi@suse.cz>
Tue, 3 Sep 2013 12:28:38 +0000 (14:28 +0200)
committerBen Hutchings <ben@decadent.org.uk>
Sat, 26 Oct 2013 20:06:02 +0000 (21:06 +0100)
commit efeb9e60d48f7778fdcad4a0f3ad9ea9b19e5dfd upstream.

Userspace can add names containing a slash character to the directory
listing.  Don't allow this as it could cause all sorts of trouble.

Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
[bwh: Backported to 3.2: drop changes to parse_dirplusfile() which we
 don't have]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
fs/fuse/dir.c

index 2747103..06e2f73 100644 (file)
@@ -1063,6 +1063,8 @@ static int parse_dirfile(char *buf, size_t nbytes, struct file *file,
                        return -EIO;
                if (reclen > nbytes)
                        break;
+               if (memchr(dirent->name, '/', dirent->namelen) != NULL)
+                       return -EIO;
 
                over = filldir(dstbuf, dirent->name, dirent->namelen,
                               file->f_pos, dirent->ino, dirent->type);