ChenXiaoSong
911904c577
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-03 11:59:37 +02:00
..
2022-06-22 14:11:02 +02:00
2021-03-04 10:26:48 +01:00
2022-06-29 08:58:46 +02:00
2019-10-25 00:03:11 -04:00
2021-01-06 14:48:39 +01:00
2022-06-14 18:11:24 +02:00
2020-11-05 11:43:36 +01:00
2022-06-14 18:12:01 +02:00
2022-06-14 18:12:02 +02:00
2019-09-19 09:42:37 -07:00
2022-03-02 11:41:10 +01:00
2019-11-23 21:44:49 -05:00
2021-09-12 08:56:38 +02:00
2022-01-27 09:19:36 +01:00
2022-02-01 17:24:34 +01:00
2022-07-29 17:14:16 +02:00
2021-05-26 12:05:19 +02:00
2020-12-02 08:49:53 +01:00
2021-11-21 13:38:51 +01:00
2019-11-10 11:56:05 -05:00
2022-04-15 14:18:13 +02:00
2022-07-21 20:59:18 +02:00
2022-06-14 18:11:56 +02:00
2022-06-14 18:11:30 +02:00
2021-09-22 12:26:25 +02:00
2022-03-16 13:21:47 +01:00
2022-05-18 09:47:26 +02:00
2021-07-31 08:19:38 +02:00
2021-05-19 10:08:29 +02:00
2021-04-14 08:24:14 +02:00
2022-05-09 09:03:28 +02:00
2022-06-14 18:11:36 +02:00
2021-11-12 14:43:03 +01:00
2022-04-27 13:50:50 +02:00
2022-06-14 18:11:55 +02:00
2022-06-14 18:11:29 +02:00
2022-06-14 18:12:00 +02:00
2021-09-22 12:26:34 +02:00
2022-04-15 14:18:35 +02:00
2022-06-22 14:11:21 +02:00
2020-12-30 11:51:22 +01:00
2022-06-06 08:33:51 +02:00
2022-07-21 20:59:18 +02:00
2022-06-14 18:11:34 +02:00
2022-08-03 11:59:37 +02:00
2022-06-14 18:11:46 +02:00
2022-01-20 09:19:17 +01:00
2021-12-22 09:29:40 +01:00
2022-06-14 18:11:41 +02:00
2021-03-04 10:26:45 +01:00
2021-09-30 10:09:26 +02:00
2022-02-23 11:59:55 +01:00
2020-10-29 09:57:53 +01:00
2021-08-12 13:21:05 +02:00
2020-08-26 10:40:51 +02:00
2021-05-19 10:08:29 +02:00
2021-03-07 12:20:48 +01:00
2022-03-02 11:41:13 +01:00
2022-04-15 14:18:31 +02:00
2022-02-01 17:24:34 +01:00
2020-08-21 13:05:37 +02:00
2019-09-17 11:48:24 -04:00
2021-10-06 15:42:30 +02:00
2022-07-12 16:30:48 +02:00
2021-12-14 14:49:02 +01:00
2020-02-11 04:35:12 -08:00
2021-10-06 15:42:35 +02:00
2022-06-14 18:11:23 +02:00
2021-03-17 17:03:57 +01:00
2021-05-22 11:38:29 +02:00
2020-11-05 11:43:24 +01:00
2020-01-14 20:08:18 +01:00
2022-06-22 14:11:03 +02:00
2020-12-11 13:23:30 +01:00
2020-10-29 09:57:45 +01:00
2022-06-14 18:11:41 +02:00
2020-10-01 13:17:19 +02:00
2021-04-14 08:24:11 +02:00
2020-01-12 12:21:37 +01:00
2020-02-11 04:35:37 -08:00
2020-10-07 08:01:31 +02:00
2022-06-06 08:33:50 +02:00
2021-09-15 09:47:28 +02:00
2022-05-25 09:14:34 +02:00
2022-03-02 11:41:18 +01:00
2020-04-17 10:50:21 +02:00
2022-02-08 18:24:29 +01:00
2019-09-12 21:06:14 -04:00
2022-06-14 18:11:44 +02:00
2020-03-25 08:25:58 +01:00
2021-07-31 08:19:37 +02:00
2022-04-15 14:18:41 +02:00
2019-12-17 19:55:30 +01:00
2019-09-18 16:59:14 -07:00
2020-11-24 13:29:19 +01:00
2020-03-25 08:25:41 +01:00
2019-09-18 16:59:14 -07:00
2020-01-17 19:48:21 +01:00
2022-02-01 17:24:39 +01:00
2021-08-26 08:36:22 -04:00
2020-03-18 07:17:51 +01:00
2021-08-12 13:21:02 +02:00
2020-05-02 08:48:44 +02:00
2021-03-17 17:03:33 +01:00
2020-02-11 04:35:23 -08:00
2021-04-21 12:56:16 +02:00
2022-01-29 10:25:11 +01:00
2021-07-20 16:10:54 +02:00
2021-12-14 14:49:02 +01:00
2019-12-17 19:56:52 +01:00
2022-04-27 13:50:48 +02:00
2019-10-03 14:21:35 -07:00
2022-02-23 11:59:55 +01:00
2021-09-22 12:26:26 +02:00
2020-02-11 04:35:12 -08:00
2020-08-11 15:33:39 +02:00