ChenXiaoSong
d2bb6a9b8b
ntfs: fix use-after-free in ntfs_ucsncmp()
...
commit 38c9c22a85aeed28d0831f230136e9cf6fa2ed44 upstream.
Syzkaller reported use-after-free bug as follows:
==================================================================
BUG: KASAN: use-after-free in ntfs_ucsncmp+0x123/0x130
Read of size 2 at addr ffff8880751acee8 by task a.out/879
CPU: 7 PID: 879 Comm: a.out Not tainted 5.19.0-rc4-next-20220630-00001-gcc5218c8bd2c-dirty #7
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 04/01/2014
Call Trace:
<TASK>
dump_stack_lvl+0x1c0/0x2b0
print_address_description.constprop.0.cold+0xd4/0x484
print_report.cold+0x55/0x232
kasan_report+0xbf/0xf0
ntfs_ucsncmp+0x123/0x130
ntfs_are_names_equal.cold+0x2b/0x41
ntfs_attr_find+0x43b/0xb90
ntfs_attr_lookup+0x16d/0x1e0
ntfs_read_locked_attr_inode+0x4aa/0x2360
ntfs_attr_iget+0x1af/0x220
ntfs_read_locked_inode+0x246c/0x5120
ntfs_iget+0x132/0x180
load_system_files+0x1cc6/0x3480
ntfs_fill_super+0xa66/0x1cf0
mount_bdev+0x38d/0x460
legacy_get_tree+0x10d/0x220
vfs_get_tree+0x93/0x300
do_new_mount+0x2da/0x6d0
path_mount+0x496/0x19d0
__x64_sys_mount+0x284/0x300
do_syscall_64+0x3b/0xc0
entry_SYSCALL_64_after_hwframe+0x46/0xb0
RIP: 0033:0x7f3f2118d9ea
Code: 48 8b 0d a9 f4 0b 00 f7 d8 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 49 89 ca b8 a5 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 76 f4 0b 00 f7 d8 64 89 01 48
RSP: 002b:00007ffc269deac8 EFLAGS: 00000202 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f3f2118d9ea
RDX: 0000000020000000 RSI: 0000000020000100 RDI: 00007ffc269dec00
RBP: 00007ffc269dec80 R08: 00007ffc269deb00 R09: 00007ffc269dec44
R10: 0000000000000000 R11: 0000000000000202 R12: 000055f81ab1d220
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
</TASK>
The buggy address belongs to the physical page:
page:0000000085430378 refcount:1 mapcount:1 mapping:0000000000000000 index:0x555c6a81d pfn:0x751ac
memcg:ffff888101f7e180
anon flags: 0xfffffc00a0014(uptodate|lru|mappedtodisk|swapbacked|node=0|zone=1|lastcpupid=0x1fffff)
raw: 000fffffc00a0014 ffffea0001bf2988 ffffea0001de2448 ffff88801712e201
raw: 0000000555c6a81d 0000000000000000 0000000100000000 ffff888101f7e180
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff8880751acd80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffff8880751ace00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff8880751ace80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
^
ffff8880751acf00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffff8880751acf80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
==================================================================
The reason is that struct ATTR_RECORD->name_offset is 6485, end address of
name string is out of bounds.
Fix this by adding sanity check on end address of attribute name string.
[akpm@linux-foundation.org: coding-style cleanups]
[chenxiaosong2@huawei.com: cleanup suggested by Hawkins Jiawei]
Link: https://lkml.kernel.org/r/20220709064511.3304299-1-chenxiaosong2@huawei.com
Link: https://lkml.kernel.org/r/20220707105329.4020708-1-chenxiaosong2@huawei.com
Signed-off-by: ChenXiaoSong <chenxiaosong2@huawei.com>
Signed-off-by: Hawkins Jiawei <yin31149@gmail.com>
Cc: Anton Altaparmakov <anton@tuxera.com>
Cc: ChenXiaoSong <chenxiaosong2@huawei.com>
Cc: Yongqiang Liu <liuyongqiang13@huawei.com>
Cc: Zhang Yi <yi.zhang@huawei.com>
Cc: Zhang Xiaoxu <zhangxiaoxu5@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-08-25 11:09:20 +02:00
..
2022-06-25 11:44:57 +02:00
2019-08-06 18:29:35 +02:00
2020-09-12 11:47:39 +02:00
2020-01-29 10:24:34 +01:00
2019-12-21 10:40:46 +01:00
2018-12-01 09:44:19 +01:00
2022-06-14 16:52:28 +02:00
2020-11-10 10:24:00 +01:00
2021-09-26 13:36:18 +02:00
2022-06-14 16:52:41 +02:00
2019-08-06 18:29:38 +02:00
2022-03-02 11:32:03 +01:00
2018-11-13 11:17:03 -08:00
2021-07-20 16:21:11 +02:00
2019-05-08 07:19:10 +02:00
2019-03-23 13:19:47 +01:00
2022-06-14 16:52:34 +02:00
2021-05-26 11:29:07 +02:00
2020-12-02 08:31:28 +01:00
2018-11-27 16:09:38 +01:00
2020-01-29 10:24:03 +01:00
2022-04-20 09:06:35 +02:00
2022-06-25 11:45:18 +02:00
2021-05-22 10:40:30 +02:00
2022-06-14 16:52:30 +02:00
2018-12-17 09:38:34 +01:00
2022-06-25 11:45:19 +02:00
2022-04-27 13:14:10 +02:00
2021-08-04 11:58:02 +02:00
2020-04-24 07:58:59 +02:00
2021-06-03 08:23:33 +02:00
2021-11-12 13:18:02 +01:00
2020-09-03 11:21:19 +02:00
2022-06-14 16:52:38 +02:00
2022-06-14 16:52:30 +02:00
2019-11-25 09:52:23 +01:00
2020-12-29 13:44:57 +01:00
2020-08-21 11:02:06 +02:00
2019-03-13 14:04:52 -07:00
2022-06-25 11:45:17 +02:00
2020-12-29 13:44:59 +01:00
2022-06-06 08:19:46 +02:00
2022-07-21 20:40:30 +02:00
2022-06-14 16:52:31 +02:00
2022-08-25 11:09:20 +02:00
2022-06-14 16:52:34 +02:00
2021-11-26 11:48:38 +01:00
2021-10-17 10:05:38 +02:00
2021-12-08 08:45:04 +01:00
2020-01-12 11:24:20 +01:00
2021-10-06 10:23:41 +02:00
2022-02-23 11:56:39 +01:00
2021-08-15 13:01:04 +02:00
2020-08-26 10:29:03 +02:00
2021-05-22 10:40:32 +02:00
2022-03-23 09:00:34 +01:00
2018-12-17 09:38:32 +01:00
2022-03-02 11:32:05 +01:00
2022-04-20 09:06:40 +02:00
2022-02-08 18:15:26 +01:00
2020-08-21 11:02:11 +02:00
2022-07-12 16:26:24 +02:00
2018-12-21 14:11:31 +01:00
2020-06-03 08:16:42 +02:00
2019-07-10 09:55:38 +02:00
2021-03-17 16:10:18 +01:00
2019-11-06 12:18:04 +01:00
2020-10-01 20:40:12 +02:00
2020-11-10 10:23:56 +01:00
2020-05-20 08:15:32 +02:00
2018-02-25 11:05:55 +01:00
2020-06-30 15:38:35 -04:00
2017-07-05 14:40:26 +02:00
2018-02-28 10:18:33 +01:00
2019-03-27 14:13:04 +09:00
2021-04-16 11:59:07 +02:00
2019-03-13 14:04:58 -07:00
2020-10-14 09:48:13 +02:00
2022-06-06 08:19:46 +02:00
2018-01-31 12:55:52 +01:00
2021-12-08 08:45:06 +01:00
2022-03-02 11:32:07 +01:00
2022-06-14 16:52:34 +02:00
2020-04-02 17:20:27 +02:00
2017-09-20 08:20:01 +02:00
2017-09-20 08:19:59 +02:00
2020-11-24 13:03:05 +01:00
2020-01-12 11:24:13 +01:00
2018-02-22 15:43:48 +01:00
2017-07-21 07:42:22 +02:00
2017-10-18 09:35:39 +02:00
2020-03-11 07:53:07 +01:00
2021-08-26 08:37:29 -04:00
2018-02-17 13:21:15 +01:00
2020-03-20 09:07:44 +01:00
2021-08-15 13:01:03 +02:00
2020-05-02 17:23:20 +02:00
2017-03-15 10:02:43 +08:00
2017-01-26 08:24:37 +01:00
2019-06-11 12:22:49 +02:00
2020-01-04 13:41:06 +01:00
2021-03-24 10:59:25 +01:00
2021-07-20 16:21:16 +02:00
2021-12-14 10:04:48 +01:00
2019-06-11 12:22:45 +02:00
2017-06-14 15:06:01 +02:00
2022-02-23 11:56:39 +01:00
2017-05-08 07:47:54 +02:00
2019-09-06 10:19:37 +02:00
2020-08-21 11:01:55 +02:00