From: Miklos Szeredi Date: Tue, 3 Sep 2013 12:28:38 +0000 (+0200) Subject: fuse: readdir: check for slash in names X-Git-Tag: firefly_0821_release~176^2~5376^2~1 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=efeb9e60d48f7778fdcad4a0f3ad9ea9b19e5dfd;p=firefly-linux-kernel-4.4.55.git fuse: readdir: check for slash in names 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 Cc: stable@vger.kernel.org --- diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index c8334f75c8c9..8fec28ff4a0d 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -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