alistair23-linux/fs/f2fs
Randall Huang 2777e65437 f2fs: fix to avoid accessing xattr across the boundary
When we traverse xattr entries via __find_xattr(),
if the raw filesystem content is faked or any hardware failure occurs,
out-of-bound error can be detected by KASAN.
Fix the issue by introducing boundary check.

[   38.402878] c7   1827 BUG: KASAN: slab-out-of-bounds in f2fs_getxattr+0x518/0x68c
[   38.402891] c7   1827 Read of size 4 at addr ffffffc0b6fb35dc by task
[   38.402935] c7   1827 Call trace:
[   38.402952] c7   1827 [<ffffff900809003c>] dump_backtrace+0x0/0x6bc
[   38.402966] c7   1827 [<ffffff9008090030>] show_stack+0x20/0x2c
[   38.402981] c7   1827 [<ffffff900871ab10>] dump_stack+0xfc/0x140
[   38.402995] c7   1827 [<ffffff9008325c40>] print_address_description+0x80/0x2d8
[   38.403009] c7   1827 [<ffffff900832629c>] kasan_report_error+0x198/0x1fc
[   38.403022] c7   1827 [<ffffff9008326104>] kasan_report_error+0x0/0x1fc
[   38.403037] c7   1827 [<ffffff9008325000>] __asan_load4+0x1b0/0x1b8
[   38.403051] c7   1827 [<ffffff90085fcc44>] f2fs_getxattr+0x518/0x68c
[   38.403066] c7   1827 [<ffffff90085fc508>] f2fs_xattr_generic_get+0xb0/0xd0
[   38.403080] c7   1827 [<ffffff9008395708>] __vfs_getxattr+0x1f4/0x1fc
[   38.403096] c7   1827 [<ffffff9008621bd0>] inode_doinit_with_dentry+0x360/0x938
[   38.403109] c7   1827 [<ffffff900862d6cc>] selinux_d_instantiate+0x2c/0x38
[   38.403123] c7   1827 [<ffffff900861b018>] security_d_instantiate+0x68/0x98
[   38.403136] c7   1827 [<ffffff9008377db8>] d_splice_alias+0x58/0x348
[   38.403149] c7   1827 [<ffffff900858d16c>] f2fs_lookup+0x608/0x774
[   38.403163] c7   1827 [<ffffff900835eacc>] lookup_slow+0x1e0/0x2cc
[   38.403177] c7   1827 [<ffffff9008367fe0>] walk_component+0x160/0x520
[   38.403190] c7   1827 [<ffffff9008369ef4>] path_lookupat+0x110/0x2b4
[   38.403203] c7   1827 [<ffffff900835dd38>] filename_lookup+0x1d8/0x3a8
[   38.403216] c7   1827 [<ffffff900835eeb0>] user_path_at_empty+0x54/0x68
[   38.403229] c7   1827 [<ffffff9008395f44>] SyS_getxattr+0xb4/0x18c
[   38.403241] c7   1827 [<ffffff9008084200>] el0_svc_naked+0x34/0x38

Signed-off-by: Randall Huang <huangrandall@google.com>
[Jaegeuk Kim: Fix wrong ending boundary]
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2019-05-09 09:43:29 -07:00
..
acl.c f2fs: Replace spaces with tab 2019-05-08 21:23:11 -07:00
acl.h f2fs: add SPDX license identifiers 2018-09-12 13:07:10 -07:00
checkpoint.c f2fs: fix to avoid potential race on sbi->unusable_block_count access/update 2019-05-08 21:23:13 -07:00
data.c f2fs: introduce DATA_GENERIC_ENHANCE 2019-05-08 21:23:13 -07:00
debug.c f2fs: no need to check return value of debugfs_create functions 2019-01-22 14:25:25 +01:00
dir.c f2fs-for-5.1-rc1 2019-03-15 13:42:53 -07:00
extent_cache.c f2fs: fix to initialize variable to avoid UBSAN/smatch warning 2019-01-22 15:31:26 -08:00
f2fs.h f2fs: introduce DATA_GENERIC_ENHANCE 2019-05-08 21:23:13 -07:00
file.c f2fs: add tracepoint for f2fs_filemap_fault() 2019-05-08 21:23:13 -07:00
gc.c f2fs: introduce DATA_GENERIC_ENHANCE 2019-05-08 21:23:13 -07:00
gc.h f2fs: add SPDX license identifiers 2018-09-12 13:07:10 -07:00
hash.c f2fs: add SPDX license identifiers 2018-09-12 13:07:10 -07:00
inline.c f2fs: fix to retrieve inline xattr space 2019-05-08 21:23:06 -07:00
inode.c f2fs: introduce DATA_GENERIC_ENHANCE 2019-05-08 21:23:13 -07:00
Kconfig fscrypt: remove filesystem specific build config option 2019-01-23 23:56:43 -05:00
Makefile
namei.c f2fs: mark is_extension_exist() inline 2019-05-08 21:23:10 -07:00
node.c f2fs: introduce DATA_GENERIC_ENHANCE 2019-05-08 21:23:13 -07:00
node.h f2fs: check PageWriteback flag for ordered case 2018-12-26 15:16:56 -08:00
recovery.c f2fs: introduce DATA_GENERIC_ENHANCE 2019-05-08 21:23:13 -07:00
segment.c f2fs: fix to avoid potential race on sbi->unusable_block_count access/update 2019-05-08 21:23:13 -07:00
segment.h f2fs: introduce DATA_GENERIC_ENHANCE 2019-05-08 21:23:13 -07:00
shrinker.c f2fs: fix sbi->extent_list corruption issue 2018-12-26 15:16:54 -08:00
super.c f2fs: fix to avoid potential race on sbi->unusable_block_count access/update 2019-05-08 21:23:13 -07:00
sysfs.c f2fs-for-5.1-rc1 2019-03-15 13:42:53 -07:00
trace.c f2fs: do not use mutex lock in atomic context 2019-03-05 19:58:06 -08:00
trace.h f2fs: add SPDX license identifiers 2018-09-12 13:07:10 -07:00
xattr.c f2fs: fix to avoid accessing xattr across the boundary 2019-05-09 09:43:29 -07:00
xattr.h f2fs: fix to avoid accessing xattr across the boundary 2019-05-09 09:43:29 -07:00