fuse: readdir: check for slash in names
authorMiklos Szeredi <mszeredi@suse.cz>
Tue, 3 Sep 2013 12:28:38 +0000 (14:28 +0200)
committerMiklos Szeredi <mszeredi@suse.cz>
Tue, 3 Sep 2013 12:28:38 +0000 (14:28 +0200)
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>
Cc: stable@vger.kernel.org
fs/fuse/dir.c

index c8334f75c8c9d87f59d53270907eefc06148d90f..8fec28ff4a0d1d1affe39cee85a7f2538d1ad3fa 100644 (file)
@@ -1174,6 +1174,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;
 
                if (!dir_emit(ctx, dirent->name, dirent->namelen,
                               dirent->ino, dirent->type))
@@ -1320,6 +1322,8 @@ static int parse_dirplusfile(char *buf, size_t nbytes, struct file *file,
                        return -EIO;
                if (reclen > nbytes)
                        break;
+               if (memchr(dirent->name, '/', dirent->namelen) != NULL)
+                       return -EIO;
 
                if (!over) {
                        /* We fill entries into dstbuf only as much as