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