linux/drivers/staging/erofs
Gao Xiang 419d6efc50 staging: erofs: keep corrupted fs from crashing kernel in erofs_namei()
As Al pointed out, "
... and while we are at it, what happens to
	unsigned int nameoff = le16_to_cpu(de[mid].nameoff);
	unsigned int matched = min(startprfx, endprfx);

	struct qstr dname = QSTR_INIT(data + nameoff,
		unlikely(mid >= ndirents - 1) ?
			maxsize - nameoff :
			le16_to_cpu(de[mid + 1].nameoff) - nameoff);

	/* string comparison without already matched prefix */
	int ret = dirnamecmp(name, &dname, &matched);
if le16_to_cpu(de[...].nameoff) is not monotonically increasing?  I.e.
what's to prevent e.g. (unsigned)-1 ending up in dname.len?

Corrupted fs image shouldn't oops the kernel.. "

Revisit the related lookup flow to address the issue.

Fixes: d72d1ce601 ("staging: erofs: add namei functions")
Cc: <stable@vger.kernel.org> # 4.19+
Suggested-by: Al Viro <viro@ZenIV.linux.org.uk>
Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-02-14 10:47:21 +01:00
..
Documentation/filesystems staging: erofs: complete POSIX ACL support 2019-01-30 15:38:50 +01:00
include staging: erofs: add trace points for reading zipped data 2018-09-18 16:35:03 +02:00
data.c staging: erofs: clean up erofs_map_blocks_iter 2019-01-15 15:52:26 +01:00
dir.c staging: erofs: Fix spelling issue 2018-12-12 11:30:05 +01:00
erofs_fs.h staging: erofs: remove __EROFS_BIT 2018-12-12 11:29:46 +01:00
inode.c staging: erofs: complete POSIX ACL support 2019-01-30 15:38:50 +01:00
internal.h staging: erofs: drop the extern prefix for function definitions 2019-01-18 10:37:16 +01:00
Kconfig staging: erofs: fix undefined LZ4_decompress_safe_partial() 2018-11-09 08:34:39 -08:00
Makefile staging: prefix header search paths with $(srctree)/ 2019-02-04 12:30:27 +01:00
namei.c staging: erofs: keep corrupted fs from crashing kernel in erofs_namei() 2019-02-14 10:47:21 +01:00
super.c staging: erofs: complete POSIX ACL support 2019-01-30 15:38:50 +01:00
TODO staging: erofs: update erofs-utils information in TODO 2018-12-06 16:08:56 +01:00
unzip_pagevec.h staging: erofs: unzip_{pagevec.h,vle.c}: rectify BUG_ONs 2018-12-12 10:56:34 +01:00
unzip_vle_lz4.c staging: erofs: fixed -Wmissing-prototype warnings by making functions static. 2019-01-11 10:44:20 +01:00
unzip_vle.c staging: erofs: remove redundant unlikely annotation in unzip_vle.c 2019-02-12 10:45:45 +01:00
unzip_vle.h staging: erofs: drop the extern prefix for function definitions 2019-01-18 10:37:16 +01:00
utils.c staging: erofs: staticize erofs_shrink_count, erofs_shrink_scan 2019-01-18 10:37:16 +01:00
xattr.c staging: erofs: fix memleak of inode's shared xattr array 2019-02-14 10:47:20 +01:00
xattr.h staging: erofs: complete POSIX ACL support 2019-01-30 15:38:50 +01:00