syzbot


KASAN: use-after-free Read in f2fs_remove_dirty_inode

Status: auto-obsoleted due to no activity on 2023/06/26 19:00
Bug presence: origin:lts
[Documentation on labels]
Reported-by: syzbot+6637150cd45525a8f6aa@syzkaller.appspotmail.com
First crash: 613d, last: 613d
Cause bisection: failed (error log, bisect log)
  
Fix bisection: failed (error log, bisect log)
  
Bug presence (2)
Date Name Commit Repro Result
2023/05/20 lts (merge base) d86dfc4d95cd C [report] KASAN: use-after-free Read in trylock_super
2023/05/20 upstream (ToT) d635f6cc934b C Didn't crash
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
android-5-10 KASAN: use-after-free Read in f2fs_remove_dirty_inode C error error 4 557d 613d 0/2 auto-obsoleted due to no activity on 2023/08/23 09:03
android-54 KASAN: use-after-free Read in f2fs_remove_dirty_inode 2 579d 593d 0/2 auto-obsoleted due to no activity on 2023/08/20 02:54
Last patch testing requests (1)
Created Duration User Patch Repo Result
2023/06/26 18:37 16m retest repro android13-5.15-lts OK log

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in __list_del_entry_valid+0x84/0x120 lib/list_debug.c:59
Read of size 8 at addr ffff8881165b2430 by task kworker/u4:4/678

CPU: 0 PID: 678 Comm: kworker/u4:4 Not tainted 5.15.94-syzkaller-03204-g5448b2fda85f #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/02/2023
Workqueue: writeback wb_workfn (flush-7:5)
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/0x3b0 mm/kasan/report.c:248
 __kasan_report mm/kasan/report.c:427 [inline]
 kasan_report+0x179/0x1c0 mm/kasan/report.c:444
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report_generic.c:309
 __list_del_entry_valid+0x84/0x120 lib/list_debug.c:59
 __list_del_entry include/linux/list.h:132 [inline]
 list_del_init include/linux/list.h:204 [inline]
 __remove_dirty_inode fs/f2fs/checkpoint.c:1031 [inline]
 f2fs_remove_dirty_inode+0x211/0x400 fs/f2fs/checkpoint.c:1067
 __f2fs_write_data_pages fs/f2fs/data.c:3232 [inline]
 f2fs_write_data_pages+0x2343/0x2bb0 fs/f2fs/data.c:3246
 do_writepages+0x40e/0x670 mm/page-writeback.c:2366
 __writeback_single_inode+0xdf/0xa70 fs/fs-writeback.c:1622
 writeback_sb_inodes+0xb2e/0x1910 fs/fs-writeback.c:1905
 wb_writeback+0x3b9/0x9e0 fs/fs-writeback.c:2079
 wb_do_writeback fs/fs-writeback.c:2222 [inline]
 wb_workfn+0x3d9/0x1110 fs/fs-writeback.c:2263
 process_one_work+0x6bb/0xc10 kernel/workqueue.c:2313
 worker_thread+0xad5/0x12a0 kernel/workqueue.c:2460
 kthread+0x421/0x510 kernel/kthread.c:319
 ret_from_fork+0x1f/0x30 <unknown>:298
 </TASK>

Allocated by task 618:
 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_kmalloc+0xdb/0x110 mm/kasan/common.c:512
 __kasan_kmalloc+0x9/0x10 mm/kasan/common.c:521
 kasan_kmalloc include/linux/kasan.h:227 [inline]
 kmem_cache_alloc_trace+0x115/0x210 mm/slub.c:3265
 kmalloc include/linux/slab.h:608 [inline]
 kzalloc include/linux/slab.h:738 [inline]
 uevent_show+0x160/0x310 drivers/base/core.c:2398
 dev_attr_show+0x56/0xd0 drivers/base/core.c:2105
 sysfs_kf_seq_show+0x265/0x3e0 fs/sysfs/file.c:61
 kernfs_seq_show+0x119/0x160 fs/kernfs/file.c:168
 seq_read_iter+0x430/0xd00 fs/seq_file.c:230
 kernfs_fop_read_iter+0x145/0x470 fs/kernfs/file.c:241
 call_read_iter include/linux/fs.h:2151 [inline]
 new_sync_read fs/read_write.c:404 [inline]
 vfs_read+0xa7e/0xd40 fs/read_write.c:485
 ksys_read+0x199/0x2c0 fs/read_write.c:623
 __do_sys_read fs/read_write.c:633 [inline]
 __se_sys_read fs/read_write.c:631 [inline]
 __x64_sys_read+0x7b/0x90 fs/read_write.c:631
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x61/0xcb

Freed by task 618:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track+0x4b/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:193 [inline]
 slab_free_hook mm/slub.c:1723 [inline]
 slab_free_freelist_hook+0xbd/0x190 mm/slub.c:1749
 slab_free mm/slub.c:3517 [inline]
 kfree+0xc8/0x220 mm/slub.c:4577
 uevent_show+0x1d6/0x310 drivers/base/core.c:2411
 dev_attr_show+0x56/0xd0 drivers/base/core.c:2105
 sysfs_kf_seq_show+0x265/0x3e0 fs/sysfs/file.c:61
 kernfs_seq_show+0x119/0x160 fs/kernfs/file.c:168
 seq_read_iter+0x430/0xd00 fs/seq_file.c:230
 kernfs_fop_read_iter+0x145/0x470 fs/kernfs/file.c:241
 call_read_iter include/linux/fs.h:2151 [inline]
 new_sync_read fs/read_write.c:404 [inline]
 vfs_read+0xa7e/0xd40 fs/read_write.c:485
 ksys_read+0x199/0x2c0 fs/read_write.c:623
 __do_sys_read fs/read_write.c:633 [inline]
 __se_sys_read fs/read_write.c:631 [inline]
 __x64_sys_read+0x7b/0x90 fs/read_write.c:631
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x61/0xcb

The buggy address belongs to the object at ffff8881165b2000
 which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 1072 bytes inside of
 4096-byte region [ffff8881165b2000, ffff8881165b3000)
The buggy address belongs to the page:
page:ffffea0004596c00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1165b0
head:ffffea0004596c00 order:3 compound_mapcount:0 compound_pincount:0
flags: 0x4000000000010200(slab|head|zone=1)
raw: 4000000000010200 0000000000000000 0000000200000001 ffff888100043380
raw: 0000000000000000 0000000000040004 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask 0x1d20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 746, ts 243244507820, free_ts 243225078486
 set_page_owner include/linux/page_owner.h:33 [inline]
 post_alloc_hook+0x1a3/0x1b0 mm/page_alloc.c:2502
 prep_new_page mm/page_alloc.c:2508 [inline]
 get_page_from_freelist+0x2c14/0x2cf0 mm/page_alloc.c:4291
 __alloc_pages+0x386/0x7b0 mm/page_alloc.c:5569
 allocate_slab mm/slub.c:1930 [inline]
 new_slab+0x92/0x490 mm/slub.c:1993
 ___slab_alloc+0x39e/0x830 mm/slub.c:3026
 __slab_alloc+0x4a/0x90 mm/slub.c:3113
 slab_alloc_node mm/slub.c:3204 [inline]
 slab_alloc mm/slub.c:3246 [inline]
 kmem_cache_alloc_trace+0x142/0x210 mm/slub.c:3263
 kmalloc include/linux/slab.h:608 [inline]
 copy_mount_options fs/namespace.c:3202 [inline]
 __do_sys_mount fs/namespace.c:3540 [inline]
 __se_sys_mount+0x156/0x3b0 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+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x61/0xcb
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:26 [inline]
 free_pages_prepare mm/page_alloc.c:1370 [inline]
 free_pcp_prepare mm/page_alloc.c:1442 [inline]
 free_unref_page_prepare+0x7c8/0x7d0 mm/page_alloc.c:3441
 free_unref_page+0xac/0x2c0 mm/page_alloc.c:3521
 free_the_page mm/page_alloc.c:711 [inline]
 __free_pages+0x61/0xf0 mm/page_alloc.c:5645
 __free_slab+0xec/0x1d0 mm/slub.c:2018
 free_slab mm/slub.c:2033 [inline]
 discard_slab mm/slub.c:2039 [inline]
 __unfreeze_partials+0x165/0x1a0 mm/slub.c:2525
 put_cpu_partial+0xc4/0x120 mm/slub.c:2605
 __slab_free+0x1c8/0x290 mm/slub.c:3386
 do_slab_free mm/slub.c:3505 [inline]
 ___cache_free+0x109/0x120 mm/slub.c:3524
 qlink_free+0x4d/0x90 mm/kasan/quarantine.c:157
 qlist_free_all+0x44/0xb0 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:217 [inline]
 slab_post_alloc_hook+0x53/0x2c0 mm/slab.h:550
 slab_alloc_node mm/slub.c:3238 [inline]
 slab_alloc mm/slub.c:3246 [inline]
 kmem_cache_alloc+0xf5/0x200 mm/slub.c:3251
 getname_flags+0xba/0x520 fs/namei.c:138
 user_path_at_empty+0x2d/0x1a0 fs/namei.c:2852

Memory state around the buggy address:
 ffff8881165b2300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8881165b2380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8881165b2400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                     ^
 ffff8881165b2480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8881165b2500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
list_del corruption. prev->next should be ffff88812c3438e0, but was 0000000000000000
------------[ cut here ]------------
kernel BUG at lib/list_debug.c:61!
invalid opcode: 0000 [#1] PREEMPT SMP KASAN
CPU: 0 PID: 678 Comm: kworker/u4:4 Tainted: G    B             5.15.94-syzkaller-03204-g5448b2fda85f #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/02/2023
Workqueue: writeback wb_workfn (flush-7:5)
RIP: 0010:__list_del_entry_valid+0x10c/0x120 lib/list_debug.c:59
Code: 4c 89 f6 e8 fb d8 50 02 0f 0b 48 c7 c7 20 c3 62 85 4c 89 f6 e8 ea d8 50 02 0f 0b 48 c7 c7 80 c3 62 85 4c 89 f6 e8 d9 d8 50 02 <0f> 0b 48 c7 c7 e0 c3 62 85 4c 89 f6 e8 c8 d8 50 02 0f 0b cc 55 48
RSP: 0018:ffffc90000fb6fa0 EFLAGS: 00010246
RAX: 0000000000000054 RBX: ffff8881165b2430 RCX: 85b8886138699f00
RDX: 0000000000000000 RSI: 0000000000000001 RDI: 0000000000000000
RBP: ffffc90000fb6fc0 R08: ffffffff8156a435 R09: fffff520001f6d1d
R10: 0000000000000000 R11: dffffc0000000001 R12: dffffc0000000000
R13: ffff888110718470 R14: ffff88812c3438e0 R15: ffff8881165b2430
FS:  0000000000000000(0000) GS:ffff8881f7000000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000555555688728 CR3: 000000011f28f000 CR4: 00000000003506b0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 <TASK>
 __list_del_entry include/linux/list.h:132 [inline]
 list_del_init include/linux/list.h:204 [inline]
 __remove_dirty_inode fs/f2fs/checkpoint.c:1031 [inline]
 f2fs_remove_dirty_inode+0x211/0x400 fs/f2fs/checkpoint.c:1067
 __f2fs_write_data_pages fs/f2fs/data.c:3232 [inline]
 f2fs_write_data_pages+0x2343/0x2bb0 fs/f2fs/data.c:3246
 do_writepages+0x40e/0x670 mm/page-writeback.c:2366
 __writeback_single_inode+0xdf/0xa70 fs/fs-writeback.c:1622
 writeback_sb_inodes+0xb2e/0x1910 fs/fs-writeback.c:1905
 wb_writeback+0x3b9/0x9e0 fs/fs-writeback.c:2079
 wb_do_writeback fs/fs-writeback.c:2222 [inline]
 wb_workfn+0x3d9/0x1110 fs/fs-writeback.c:2263
 process_one_work+0x6bb/0xc10 kernel/workqueue.c:2313
 worker_thread+0xad5/0x12a0 kernel/workqueue.c:2460
 kthread+0x421/0x510 kernel/kthread.c:319
 ret_from_fork+0x1f/0x30 <unknown>:298
 </TASK>
Modules linked in:
---[ end trace 7827f0043540c08e ]---
RIP: 0010:__list_del_entry_valid+0x10c/0x120 lib/list_debug.c:59
Code: 4c 89 f6 e8 fb d8 50 02 0f 0b 48 c7 c7 20 c3 62 85 4c 89 f6 e8 ea d8 50 02 0f 0b 48 c7 c7 80 c3 62 85 4c 89 f6 e8 d9 d8 50 02 <0f> 0b 48 c7 c7 e0 c3 62 85 4c 89 f6 e8 c8 d8 50 02 0f 0b cc 55 48
RSP: 0018:ffffc90000fb6fa0 EFLAGS: 00010246
RAX: 0000000000000054 RBX: ffff8881165b2430 RCX: 85b8886138699f00
RDX: 0000000000000000 RSI: 0000000000000001 RDI: 0000000000000000
RBP: ffffc90000fb6fc0 R08: ffffffff8156a435 R09: fffff520001f6d1d
R10: 0000000000000000 R11: dffffc0000000001 R12: dffffc0000000000
R13: ffff888110718470 R14: ffff88812c3438e0 R15: ffff8881165b2430
FS:  0000000000000000(0000) GS:ffff8881f7000000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000555555688728 CR3: 000000011f28f000 CR4: 00000000003506b0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/03/18 16:40 android13-5.15-lts 5448b2fda85f 7939252e .config console log report syz [disk image] [vmlinux] [kernel image] [mounted in repro #1] [mounted in repro #2] ci2-android-5-15 KASAN: use-after-free Read in f2fs_remove_dirty_inode
* Struck through repros no longer work on HEAD.