Randall Huang
1d295b32df
f2fs: fix to avoid accessing xattr across the boundary
commit 2777e654371dd4207a3a7f4fb5fa39550053a080 upstream.
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>
[bwh: Backported to 4.14: adjust context]
Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-05-20 08:17:04 +02:00
..
2019-10-11 18:18:38 +02:00
2019-08-06 19:05:21 +02:00
2020-01-27 14:46:52 +01:00
2020-04-02 16:34:33 +02:00
2019-12-17 20:37:24 +01:00
2017-11-02 11:10:55 +01:00
2018-12-01 09:42:51 +01:00
2020-05-05 19:15:49 +02:00
2018-12-17 09:28:53 +01:00
2020-05-02 17:24:13 +02:00
2020-05-10 10:29:00 +02:00
2019-08-06 19:05:23 +02:00
2019-11-12 19:18:18 +01:00
2018-11-13 11:15:12 -08:00
2019-07-31 07:28:22 +02:00
2019-05-08 07:20:49 +02:00
2019-03-23 14:35:21 +01:00
2019-12-17 20:38:33 +01:00
2020-03-11 18:02:51 +01:00
2017-11-02 11:10:55 +01:00
2019-12-05 15:37:28 +01:00
2020-01-27 14:46:06 +01:00
2020-04-24 08:01:22 +02:00
2020-05-05 19:15:47 +02:00
2020-05-20 08:17:04 +02:00
2020-03-11 18:03:03 +01:00
2018-12-17 09:28:53 +01:00
2019-12-17 20:38:44 +01:00
2020-04-24 08:00:27 +02:00
2019-12-01 09:13:57 +01:00
2020-04-24 08:00:45 +02:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2019-05-31 06:47:12 -07:00
2018-10-03 17:00:57 -07:00
2020-04-24 08:00:54 +02:00
2019-05-08 07:20:49 +02:00
2020-01-27 14:46:26 +01:00
2019-12-17 20:38:50 +01:00
2019-12-17 20:38:15 +01:00
2017-11-02 11:10:55 +01:00
2018-03-28 18:24:43 +02:00
2020-05-05 19:15:52 +02:00
2018-02-03 17:39:08 +01:00
2020-05-02 17:24:41 +02:00
2018-05-30 07:51:47 +02:00
2017-11-02 11:10:55 +01:00
2020-01-12 12:11:59 +01:00
2017-11-02 11:10:55 +01:00
2020-04-24 08:00:43 +02:00
2017-11-02 11:10:55 +01:00
2020-02-28 16:36:08 +01:00
2019-12-17 20:39:21 +01:00
2020-05-02 17:24:21 +02:00
2020-01-09 10:17:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2020-01-12 12:11:59 +01:00
2017-09-06 17:27:26 -07:00
2020-02-28 16:36:08 +01:00
2017-11-02 11:10:55 +01:00
2018-09-05 09:26:32 +02:00
2018-09-05 09:26:41 +02:00
2018-12-17 09:28:48 +01:00
2020-02-14 16:32:11 -05:00
2020-02-28 16:36:02 +01:00
2019-05-25 18:25:36 +02:00
2020-05-02 17:24:43 +02:00
2018-12-21 14:13:04 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-09-14 18:13:32 -07:00
2019-10-05 12:48:06 +02:00
2019-07-03 13:15:59 +02:00
2018-06-26 08:06:33 +08:00
2019-11-06 12:42:59 +01:00
2019-04-17 08:37:53 +02:00
2020-04-24 08:01:00 +02:00
2020-01-14 20:05:39 +01:00
2020-01-09 10:17:58 +01:00
2020-05-20 08:16:58 +02:00
2020-03-11 18:02:43 +01:00
2019-02-06 17:31:34 +01:00
2019-04-27 09:35:41 +02:00
2020-01-12 12:11:59 +01:00
2019-02-12 19:46:10 +01:00
2020-04-24 08:00:38 +02:00
2017-12-17 15:07:59 +01:00
2017-11-02 11:10:55 +01:00
2019-04-05 22:31:28 +02:00
2020-04-24 08:00:43 +02:00
2017-11-02 11:10:55 +01:00
2019-11-12 19:18:47 +01:00
2020-04-02 16:34:21 +02:00
2017-09-13 09:11:44 -07:00
2018-11-10 07:48:33 -08:00
2019-12-17 20:38:57 +01:00
2020-04-02 16:34:35 +02:00
2020-01-09 10:17:55 +01:00
2017-11-02 11:10:55 +01:00
2018-02-22 15:42:25 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2020-03-11 18:02:53 +01:00
2020-05-02 17:24:20 +02:00
2017-11-02 11:10:55 +01:00
2020-03-20 10:54:16 +01:00
2019-05-04 09:15:18 +02:00
2020-05-02 17:24:47 +02:00
2017-11-02 11:10:55 +01:00
2019-12-01 09:13:51 +01:00
2020-01-04 14:00:04 +01:00
2017-11-02 11:10:55 +01:00
2018-02-22 15:42:28 +01:00
2017-11-02 11:10:55 +01:00
2019-05-04 09:15:18 +02:00
2017-11-02 11:10:55 +01:00
2019-10-11 18:18:48 +02:00
2018-05-30 07:51:47 +02:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2020-01-04 13:59:58 +01:00
2017-11-02 11:10:55 +01:00
2018-10-10 08:54:27 +02:00