syzbot


KASAN: use-after-free Read in __mark_inode_dirty

Status: auto-obsoleted due to no activity on 2023/04/26 22:39
Subsystems: fat
[Documentation on labels]
Reported-by: syzbot+23b6b8a58051480572ec@syzkaller.appspotmail.com
First crash: 700d, last: 686d
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in __mark_inode_dirty exfat 1 753d 748d 0/28 auto-obsoleted due to no activity on 2023/02/27 09:24
upstream BUG: corrupted list in __mark_inode_dirty reiserfs C error done 1 325d 516d 0/28 auto-obsoleted due to no activity on 2024/04/09 18:17

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in __list_add_valid+0x4c/0x100 lib/list_debug.c:27
Read of size 8 at addr ffff88816faac9c8 by task syz-executor.4/8124

CPU: 0 PID: 8124 Comm: syz-executor.4 Not tainted 5.15.78-syzkaller-00911-gc73b4619ad86 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x151/0x1b7 lib/dump_stack.c:106
 print_address_description+0x87/0x3d0 mm/kasan/report.c:256
 __kasan_report mm/kasan/report.c:435 [inline]
 kasan_report+0x1a6/0x1f0 mm/kasan/report.c:452
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report_generic.c:309
 __list_add_valid+0x4c/0x100 lib/list_debug.c:27
 __list_add include/linux/list.h:67 [inline]
 list_add include/linux/list.h:86 [inline]
 list_move include/linux/list.h:216 [inline]
 inode_io_list_move_locked+0x197/0x3d0 fs/fs-writeback.c:125
 __mark_inode_dirty+0x57d/0x9d0 fs/fs-writeback.c:2512
 mark_buffer_dirty+0x1df/0x310 fs/buffer.c:1112
 fat_set_state+0x25b/0x340 fs/fat/inode.c:708
 fat_fill_super+0x39b7/0x4b30 fs/fat/inode.c:1885
 msdos_fill_super+0x2e/0x40 fs/fat/namei_msdos.c:655
 mount_bdev+0x280/0x3b0 fs/super.c:1369
 msdos_mount+0x34/0x40 fs/fat/namei_msdos.c:662
 legacy_get_tree+0xf0/0x190 fs/fs_context.c:610
 vfs_get_tree+0x88/0x290 fs/super.c:1499
 do_new_mount+0x289/0xad0 fs/namespace.c:2994
 path_mount+0x60b/0x1050 fs/namespace.c:3324
 do_mount fs/namespace.c:3337 [inline]
 __do_sys_mount fs/namespace.c:3545 [inline]
 __se_sys_mount+0x2d2/0x3c0 fs/namespace.c:3522
 __x64_sys_mount+0xbf/0xd0 fs/namespace.c:3522
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x44/0xd0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x61/0xcb
RIP: 0033:0x7f173f4545fa
Code: 48 c7 c2 b8 ff ff ff f7 d8 64 89 02 b8 ff ff ff ff eb d2 e8 b8 04 00 00 0f 1f 84 00 00 00 00 00 49 89 ca b8 a5 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f173e1c5f88 EFLAGS: 00000202 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 0000000000000199 RCX: 00007f173f4545fa
RDX: 0000000020000040 RSI: 0000000020000000 RDI: 00007f173e1c5fe0
RBP: 00007f173e1c6020 R08: 00007f173e1c6020 R09: 0000000003a100c8
R10: 0000000003a100c8 R11: 0000000000000202 R12: 0000000020000040
R13: 0000000020000000 R14: 00007f173e1c5fe0 R15: 0000000020000100
 </TASK>

Allocated by task 8110:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track mm/kasan/common.c:45 [inline]
 set_alloc_info mm/kasan/common.c:433 [inline]
 __kasan_slab_alloc+0xb2/0xe0 mm/kasan/common.c:466
 kasan_slab_alloc include/linux/kasan.h:244 [inline]
 slab_post_alloc_hook mm/slab.h:550 [inline]
 slab_alloc_node mm/slub.c:3236 [inline]
 slab_alloc mm/slub.c:3244 [inline]
 kmem_cache_alloc+0x189/0x2f0 mm/slub.c:3249
 fat_alloc_inode+0x1d/0xa0 fs/fat/inode.c:748
 alloc_inode fs/inode.c:236 [inline]
 new_inode_pseudo+0x64/0x220 fs/inode.c:937
 new_inode+0x28/0x1c0 fs/inode.c:966
 fat_build_inode+0x1d9/0x3a0 fs/fat/inode.c:601
 msdos_create+0x480/0x580 fs/fat/namei_msdos.c:292
 lookup_open fs/namei.c:3334 [inline]
 open_last_lookups fs/namei.c:3404 [inline]
 path_openat+0x1323/0x2ea0 fs/namei.c:3612
 do_filp_open+0x277/0x4f0 fs/namei.c:3642
 do_sys_openat2+0x13b/0x500 fs/open.c:1234
 do_sys_open fs/open.c:1250 [inline]
 __do_sys_open fs/open.c:1258 [inline]
 __se_sys_open fs/open.c:1254 [inline]
 __x64_sys_open+0x221/0x270 fs/open.c:1254
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x44/0xd0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x61/0xcb

Freed by task 182:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track+0x4c/0x70 mm/kasan/common.c:45
 kasan_set_free_info+0x23/0x40 mm/kasan/generic.c:370
 ____kasan_slab_free+0x126/0x160 mm/kasan/common.c:365
 __kasan_slab_free+0x11/0x20 mm/kasan/common.c:373
 kasan_slab_free include/linux/kasan.h:220 [inline]
 slab_free_hook mm/slub.c:1721 [inline]
 slab_free_freelist_hook+0xc9/0x1a0 mm/slub.c:1747
 slab_free mm/slub.c:3515 [inline]
 kmem_cache_free+0x11a/0x2e0 mm/slub.c:3531
 fat_free_inode+0x20/0x30 fs/fat/inode.c:765
 i_callback+0x4b/0x70 fs/inode.c:225
 rcu_do_batch+0x55b/0xbe0 kernel/rcu/tree.c:2509
 rcu_core+0x506/0x1000 kernel/rcu/tree.c:2749
 rcu_core_si+0x9/0x10 kernel/rcu/tree.c:2762
 __do_softirq+0x27e/0x5dc kernel/softirq.c:565

Last potentially related work creation:
 kasan_save_stack+0x3b/0x60 mm/kasan/common.c:38
 __kasan_record_aux_stack+0xd3/0xf0 mm/kasan/generic.c:348
 kasan_record_aux_stack_noalloc+0xb/0x10 mm/kasan/generic.c:358
 __call_rcu kernel/rcu/tree.c:2993 [inline]
 call_rcu+0x140/0x1400 kernel/rcu/tree.c:3073
 destroy_inode fs/inode.c:291 [inline]
 evict+0x5de/0x630 fs/inode.c:602
 iput_final fs/inode.c:1663 [inline]
 iput+0x61c/0x7d0 fs/inode.c:1689
 dentry_unlink_inode+0x349/0x430 fs/dcache.c:376
 __dentry_kill+0x3e2/0x5d0 fs/dcache.c:582
 dentry_kill+0xc0/0x2a0
 dput+0x175/0x320 fs/dcache.c:888
 __fput+0x65a/0x910 fs/file_table.c:288
 ____fput+0x15/0x20 fs/file_table.c:308
 task_work_run+0x147/0x1b0 kernel/task_work.c:164
 tracehook_notify_resume include/linux/tracehook.h:189 [inline]
 exit_to_user_mode_loop+0xfd/0x110 kernel/entry/common.c:175
 exit_to_user_mode_prepare kernel/entry/common.c:207 [inline]
 __syscall_exit_to_user_mode_work kernel/entry/common.c:289 [inline]
 syscall_exit_to_user_mode+0x79/0xc0 kernel/entry/common.c:300
 do_syscall_64+0x50/0xd0 arch/x86/entry/common.c:86
 entry_SYSCALL_64_after_hwframe+0x61/0xcb

Second to last potentially related work creation:
 kasan_save_stack+0x3b/0x60 mm/kasan/common.c:38
 __kasan_record_aux_stack+0xd3/0xf0 mm/kasan/generic.c:348
 kasan_record_aux_stack_noalloc+0xb/0x10 mm/kasan/generic.c:358
 __call_rcu kernel/rcu/tree.c:2993 [inline]
 call_rcu+0x140/0x1400 kernel/rcu/tree.c:3073
 destroy_inode fs/inode.c:291 [inline]
 evict+0x5de/0x630 fs/inode.c:602
 iput_final fs/inode.c:1663 [inline]
 iput+0x61c/0x7d0 fs/inode.c:1689
 fat_put_super+0x94/0xc0 fs/fat/inode.c:738
 generic_shutdown_super+0x157/0x2e0 fs/super.c:466
 kill_block_super+0x80/0xe0 fs/super.c:1396
 deactivate_locked_super+0xb0/0x100 fs/super.c:335
 deactivate_super+0xa5/0xd0 fs/super.c:366
 cleanup_mnt+0x45f/0x510 fs/namespace.c:1143
 __cleanup_mnt+0x19/0x20 fs/namespace.c:1150
 task_work_run+0x147/0x1b0 kernel/task_work.c:164
 tracehook_notify_resume include/linux/tracehook.h:189 [inline]
 exit_to_user_mode_loop+0xfd/0x110 kernel/entry/common.c:175
 exit_to_user_mode_prepare kernel/entry/common.c:207 [inline]
 __syscall_exit_to_user_mode_work kernel/entry/common.c:289 [inline]
 syscall_exit_to_user_mode+0x79/0xc0 kernel/entry/common.c:300
 do_syscall_64+0x50/0xd0 arch/x86/entry/common.c:86
 entry_SYSCALL_64_after_hwframe+0x61/0xcb

The buggy address belongs to the object at ffff88816faac820
 which belongs to the cache fat_inode_cache of size 912
The buggy address is located 424 bytes inside of
 912-byte region [ffff88816faac820, ffff88816faacbb0)
The buggy address belongs to the page:
page:ffffea0005beab00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x16faac
head:ffffea0005beab00 order:2 compound_mapcount:0 compound_pincount:0
flags: 0x4000000000010200(slab|head|zone=1)
raw: 4000000000010200 0000000000000000 dead000000000122 ffff888108580300
raw: 0000000000000000 00000000800f000f 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 2, migratetype Reclaimable, gfp_mask 0x1d2050(__GFP_IO|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL|__GFP_RECLAIMABLE), pid 1915, ts 225912451636, free_ts 225003807270
 set_page_owner include/linux/page_owner.h:33 [inline]
 post_alloc_hook+0x1ab/0x1b0 mm/page_alloc.c:2495
 prep_new_page mm/page_alloc.c:2501 [inline]
 get_page_from_freelist+0x38b/0x400 mm/page_alloc.c:4281
 __alloc_pages+0x3a8/0x7c0 mm/page_alloc.c:5548
 allocate_slab+0x62/0x580 mm/slub.c:1928
 new_slab mm/slub.c:1991 [inline]
 ___slab_alloc+0x2e2/0x6f0 mm/slub.c:3024
 __slab_alloc+0x4a/0x90 mm/slub.c:3111
 slab_alloc_node mm/slub.c:3202 [inline]
 slab_alloc mm/slub.c:3244 [inline]
 kmem_cache_alloc+0x205/0x2f0 mm/slub.c:3249
 fat_alloc_inode+0x1d/0xa0 fs/fat/inode.c:748
 alloc_inode fs/inode.c:236 [inline]
 new_inode_pseudo+0x64/0x220 fs/inode.c:937
 new_inode+0x28/0x1c0 fs/inode.c:966
 fat_fill_super+0x32c2/0x4b30 fs/fat/inode.c:1846
 msdos_fill_super+0x2e/0x40 fs/fat/namei_msdos.c:655
 mount_bdev+0x280/0x3b0 fs/super.c:1369
 msdos_mount+0x34/0x40 fs/fat/namei_msdos.c:662
 legacy_get_tree+0xf0/0x190 fs/fs_context.c:610
 vfs_get_tree+0x88/0x290 fs/super.c:1499
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:26 [inline]
 free_pages_prepare mm/page_alloc.c:1364 [inline]
 free_pcp_prepare+0x448/0x450 mm/page_alloc.c:1435
 free_unref_page_prepare mm/page_alloc.c:3433 [inline]
 free_unref_page+0x9c/0x370 mm/page_alloc.c:3513
 free_the_page mm/page_alloc.c:706 [inline]
 __free_pages+0xd8/0x100 mm/page_alloc.c:5621
 __free_slab+0xf0/0x1d0 mm/slub.c:2016
 free_slab mm/slub.c:2031 [inline]
 discard_slab+0x29/0x40 mm/slub.c:2037
 __slab_free+0x238/0x2f0 mm/slub.c:3420
 do_slab_free mm/slub.c:3503 [inline]
 ___cache_free+0x112/0x130 mm/slub.c:3522
 qlink_free+0x4d/0x90 mm/kasan/quarantine.c:157
 qlist_free_all+0x4c/0xc0 mm/kasan/quarantine.c:176
 kasan_quarantine_reduce+0x15a/0x180 mm/kasan/quarantine.c:283
 __kasan_slab_alloc+0x2f/0xe0 mm/kasan/common.c:443
 kasan_slab_alloc include/linux/kasan.h:244 [inline]
 slab_post_alloc_hook mm/slab.h:550 [inline]
 slab_alloc_node mm/slub.c:3236 [inline]
 slab_alloc mm/slub.c:3244 [inline]
 kmem_cache_alloc+0x189/0x2f0 mm/slub.c:3249
 getname_flags+0xba/0x510 fs/namei.c:138
 user_path_at_empty+0x2e/0x1b0 fs/namei.c:2852
 do_readlinkat+0x11b/0x3b0 fs/stat.c:442
 __do_sys_readlink fs/stat.c:475 [inline]
 __se_sys_readlink fs/stat.c:472 [inline]
 __x64_sys_readlink+0x7f/0x90 fs/stat.c:472

Memory state around the buggy address:
 ffff88816faac880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88816faac900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88816faac980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                              ^
 ffff88816faaca00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88816faaca80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/01/05 00:19 android13-5.15-lts c73b4619ad86 1dac8c7a .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-5-15 KASAN: use-after-free Read in __mark_inode_dirty
2022/12/21 21:42 android13-5.15-lts c73b4619ad86 4067838e .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-5-15 KASAN: use-after-free Read in __mark_inode_dirty
* Struck through repros no longer work on HEAD.