[ntfs?] KASAN: slab-out-of-bounds Read in ntfs_readdir

14 views
Skip to first unread message

syzbot

unread,
Dec 31, 2022, 2:18:40 PM12/31/22
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: c4215ee4771b Linux 4.14.302
git tree: linux-4.14.y
console output: https://syzkaller.appspot.com/x/log.txt?x=11233db8480000
kernel config: https://syzkaller.appspot.com/x/.config?x=4a9988fe055c9527
dashboard link: https://syzkaller.appspot.com/bug?extid=6b0c1e6cf3c7a9345fb1
compiler: gcc version 10.2.1 20210110 (Debian 10.2.1-6)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=158a3d44480000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=13e50692480000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/c93ba055d204/disk-c4215ee4.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/bfbc929a33c1/vmlinux-c4215ee4.xz
kernel image: https://storage.googleapis.com/syzbot-assets/444658051770/bzImage-c4215ee4.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/79e81ec5eb61/mount_0.gz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+6b0c1e...@syzkaller.appspotmail.com

ntfs: (device loop0): check_windows_hibernation_status(): Failed to find inode number for hiberfil.sys.
ntfs: (device loop0): load_system_files(): Failed to determine if Windows is hibernated. Will not be able to remount read-write. Run chkdsk.
ntfs: (device loop0): map_mft_record_page(): Attempt to read mft record 0x10000, which is beyond the end of the mft. This is probably a bug in the ntfs driver.
ntfs: (device loop0): map_mft_record(): Failed with error code 2.
==================================================================
BUG: KASAN: slab-out-of-bounds in ntfs_filldir fs/ntfs/dir.c:1034 [inline]
BUG: KASAN: slab-out-of-bounds in ntfs_readdir+0x2fd3/0x37f0 fs/ntfs/dir.c:1213
Read of size 1 at addr ffff8880b3f10971 by task syz-executor223/7964

CPU: 0 PID: 7964 Comm: syz-executor223 Not tainted 4.14.302-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
Call Trace:
__dump_stack lib/dump_stack.c:17 [inline]
dump_stack+0x1b2/0x281 lib/dump_stack.c:58
print_address_description.cold+0x54/0x1d3 mm/kasan/report.c:252
kasan_report_error.cold+0x8a/0x191 mm/kasan/report.c:351
kasan_report mm/kasan/report.c:409 [inline]
__asan_report_load1_noabort+0x68/0x70 mm/kasan/report.c:427
ntfs_filldir fs/ntfs/dir.c:1034 [inline]
ntfs_readdir+0x2fd3/0x37f0 fs/ntfs/dir.c:1213
iterate_dir+0x478/0x5e0 fs/readdir.c:54
SYSC_getdents64 fs/readdir.c:358 [inline]
SyS_getdents64+0x125/0x230 fs/readdir.c:339
do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x5e/0xd3
RIP: 0033:0x7fd4c153a789
RSP: 002b:00007ffca8591da8 EFLAGS: 00000246 ORIG_RAX: 00000000000000d9
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007fd4c153a789
RDX: 0000000000000098 RSI: 0000000020000080 RDI: 0000000000000004
RBP: 00007fd4c14fa020 R08: 0000000000000000 R09: 0000000000000000
R10: 000000000001e706 R11: 0000000000000246 R12: 00007fd4c14fa0b0
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 7964:
save_stack mm/kasan/kasan.c:447 [inline]
set_track mm/kasan/kasan.c:459 [inline]
kasan_kmalloc+0xeb/0x160 mm/kasan/kasan.c:551
__do_kmalloc mm/slab.c:3720 [inline]
__kmalloc+0x15a/0x400 mm/slab.c:3729
kmalloc include/linux/slab.h:493 [inline]
ntfs_readdir+0x37d/0x37f0 fs/ntfs/dir.c:1175
iterate_dir+0x478/0x5e0 fs/readdir.c:54
SYSC_getdents64 fs/readdir.c:358 [inline]
SyS_getdents64+0x125/0x230 fs/readdir.c:339
do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x5e/0xd3

Freed by task 17:
save_stack mm/kasan/kasan.c:447 [inline]
set_track mm/kasan/kasan.c:459 [inline]
kasan_slab_free+0xc3/0x1a0 mm/kasan/kasan.c:524
__cache_free mm/slab.c:3496 [inline]
kfree+0xc9/0x250 mm/slab.c:3815
__d_free_external+0x3f/0x60 fs/dcache.c:289
__rcu_reclaim kernel/rcu/rcu.h:195 [inline]
rcu_do_batch kernel/rcu/tree.c:2699 [inline]
invoke_rcu_callbacks kernel/rcu/tree.c:2962 [inline]
__rcu_process_callbacks kernel/rcu/tree.c:2929 [inline]
rcu_process_callbacks+0x780/0x1180 kernel/rcu/tree.c:2946
__do_softirq+0x24d/0x9ff kernel/softirq.c:288

The buggy address belongs to the object at ffff8880b3f10900
which belongs to the cache kmalloc-64 of size 64
The buggy address is located 49 bytes to the right of
64-byte region [ffff8880b3f10900, ffff8880b3f10940)
The buggy address belongs to the page:
page:ffffea0002cfc400 count:1 mapcount:0 mapping:ffff8880b3f10000 index:0x0
flags: 0xfff00000000100(slab)
raw: 00fff00000000100 ffff8880b3f10000 0000000000000000 0000000100000020
raw: ffffea0002a77620 ffffea0002598ea0 ffff88813fe74340 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8880b3f10800: 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc
ffff8880b3f10880: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
>ffff8880b3f10900: 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc fc
^
ffff8880b3f10980: 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc
ffff8880b3f10a00: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
==================================================================


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
syzbot can test patches for this issue, for details see:
https://goo.gl/tpsmEJ#testing-patches

syzbot

unread,
Jan 4, 2023, 12:55:42 AM1/4/23
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 3f8a27f9e27b Linux 4.19.211
git tree: linux-4.19.y
console output: https://syzkaller.appspot.com/x/log.txt?x=173acc94480000
kernel config: https://syzkaller.appspot.com/x/.config?x=9b9277b418617afe
dashboard link: https://syzkaller.appspot.com/bug?extid=a7a8de33e535be82e40f
compiler: gcc version 10.2.1 20210110 (Debian 10.2.1-6)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1158e984480000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=10c08514480000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/98c0bdb4abb3/disk-3f8a27f9.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/ea228ff02669/vmlinux-3f8a27f9.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/0654d5e457dc/mount_0.gz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+a7a8de...@syzkaller.appspotmail.com

ntfs: (device loop0): map_mft_record_page(): Attempt to read mft record 0x10000, which is beyond the end of the mft. This is probably a bug in the ntfs driver.
ntfs: (device loop0): map_mft_record(): Failed with error code 2.
==================================================================
BUG: KASAN: slab-out-of-bounds in ntfs_filldir fs/ntfs/dir.c:1034 [inline]
BUG: KASAN: slab-out-of-bounds in ntfs_readdir+0x3ad2/0x4140 fs/ntfs/dir.c:1213
Read of size 1 at addr ffff8880a8e7eb71 by task syz-executor136/8089

CPU: 1 PID: 8089 Comm: syz-executor136 Not tainted 4.19.211-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x1fc/0x2ef lib/dump_stack.c:118
print_address_description.cold+0x54/0x219 mm/kasan/report.c:256
kasan_report_error.cold+0x8a/0x1b9 mm/kasan/report.c:354
kasan_report mm/kasan/report.c:412 [inline]
__asan_report_load1_noabort+0x88/0x90 mm/kasan/report.c:430
ntfs_filldir fs/ntfs/dir.c:1034 [inline]
ntfs_readdir+0x3ad2/0x4140 fs/ntfs/dir.c:1213
iterate_dir+0x1fe/0x5c0 fs/readdir.c:53
ksys_getdents64+0x175/0x2b0 fs/readdir.c:357
__do_sys_getdents64 fs/readdir.c:376 [inline]
__se_sys_getdents64 fs/readdir.c:373 [inline]
__x64_sys_getdents64+0x6f/0xb0 fs/readdir.c:373
do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x7f5a3bc00789
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 51 14 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 c0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffdef08f8f8 EFLAGS: 00000246 ORIG_RAX: 00000000000000d9
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f5a3bc00789
RDX: 0000000000000098 RSI: 0000000020000080 RDI: 0000000000000004
RBP: 00007f5a3bbc0020 R08: 0000000000000000 R09: 0000000000000000
R10: 000000000001e706 R11: 0000000000000246 R12: 00007f5a3bbc00b0
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 8089:
__do_kmalloc mm/slab.c:3727 [inline]
__kmalloc+0x15a/0x3c0 mm/slab.c:3736
kmalloc include/linux/slab.h:520 [inline]
ntfs_readdir+0x3d3/0x4140 fs/ntfs/dir.c:1175
iterate_dir+0x1fe/0x5c0 fs/readdir.c:53
ksys_getdents64+0x175/0x2b0 fs/readdir.c:357
__do_sys_getdents64 fs/readdir.c:376 [inline]
__se_sys_getdents64 fs/readdir.c:373 [inline]
__x64_sys_getdents64+0x6f/0xb0 fs/readdir.c:373
do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 4699:
__cache_free mm/slab.c:3503 [inline]
kfree+0xcc/0x210 mm/slab.c:3822
__d_free_external+0x3f/0x60 fs/dcache.c:276
__rcu_reclaim kernel/rcu/rcu.h:236 [inline]
rcu_do_batch kernel/rcu/tree.c:2584 [inline]
invoke_rcu_callbacks kernel/rcu/tree.c:2897 [inline]
__rcu_process_callbacks kernel/rcu/tree.c:2864 [inline]
rcu_process_callbacks+0x8ff/0x18b0 kernel/rcu/tree.c:2881
__do_softirq+0x265/0x980 kernel/softirq.c:292

The buggy address belongs to the object at ffff8880a8e7eb00
which belongs to the cache kmalloc-64 of size 64
The buggy address is located 49 bytes to the right of
64-byte region [ffff8880a8e7eb00, ffff8880a8e7eb40)
The buggy address belongs to the page:
page:ffffea0002a39f80 count:1 mapcount:0 mapping:ffff88813bff0340 index:0x0
flags: 0xfff00000000100(slab)
raw: 00fff00000000100 ffffea0002a7f788 ffffea0002a68748 ffff88813bff0340
raw: 0000000000000000 ffff8880a8e7e000 0000000100000020 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8880a8e7ea00: 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc
ffff8880a8e7ea80: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
>ffff8880a8e7eb00: 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc fc
^
ffff8880a8e7eb80: 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc
ffff8880a8e7ec00: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
Reply all
Reply to author
Forward
0 new messages