syzbot


KASAN: use-after-free Read in do_garbage_collect

Status: fixed on 2023/04/04 21:07
Reported-by: syzbot+dc39c9c8520061d40d17@syzkaller.appspotmail.com
Fix commit: 97ccfffcc061 f2fs: fix to do sanity check on i_extra_isize in is_alive()
First crash: 762d, last: 601d
Cause bisection: failed (error log, bisect log)
  
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
android-54 KASAN: use-after-free Read in do_garbage_collect C 4 733d 762d 2/2 fixed on 2023/04/04 21:06
upstream KASAN: use-after-free Read in do_garbage_collect f2fs C inconclusive 2 739d 738d 22/28 fixed on 2023/02/24 13:50
Last patch testing requests (8)
Created Duration User Patch Repo Result
2023/04/04 09:13 35m tudor.ambarus@linaro.org https://android.googlesource.com/kernel/common 97ccfffcc061e54ce87e4a51a40e2e9cb0b7076a log
2023/04/03 15:13 13m tudor.ambarus@linaro.org https://android.googlesource.com/kernel/common 7f2e600bf63a9cda882a6c86de04183e5061e8ee report log
2023/04/03 14:22 18m tudor.ambarus@linaro.org git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git 64fa364ad3245508d393e16ed4886f92d7eb423c log
2023/04/03 13:57 16m tudor.ambarus@linaro.org git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git 97ccfffcc061e54ce87e4a51a40e2e9cb0b7076a log
2022/12/23 07:16 12m tudor.ambarus@linaro.org android13-5.15-lts log
2022/12/22 11:17 13m tudor.ambarus@linaro.org upstream log
2022/12/09 15:51 11m tudor.ambarus@linaro.org git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git linux-5.15.y log
2022/12/09 15:51 12m tudor.ambarus@linaro.org upstream log
Fix bisection attempts (3)
Created Duration User Patch Repo Result
2023/03/31 04:16 29m bisect fix android13-5.15-lts OK (0) job log log
2023/02/25 18:10 31m (2) bisect fix android13-5.15-lts OK (0) job log log
2023/01/25 09:36 27m bisect fix android13-5.15-lts OK (0) job log log

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in data_blkaddr fs/f2fs/f2fs.h:2849 [inline]
BUG: KASAN: use-after-free in is_alive fs/f2fs/gc.c:1050 [inline]
BUG: KASAN: use-after-free in gc_data_segment fs/f2fs/gc.c:1468 [inline]
BUG: KASAN: use-after-free in do_garbage_collect+0x4f59/0x6370 fs/f2fs/gc.c:1673
Read of size 4 at addr ffff88811b2de150 by task kworker/u4:0/8

CPU: 1 PID: 8 Comm: kworker/u4:0 Not tainted 5.15.74-syzkaller-04383-g7f2e600bf63a #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/22/2022
Workqueue: writeback wb_workfn (flush-7:0)
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_load4_noabort+0x14/0x20 mm/kasan/report_generic.c:308
 data_blkaddr fs/f2fs/f2fs.h:2849 [inline]
 is_alive fs/f2fs/gc.c:1050 [inline]
 gc_data_segment fs/f2fs/gc.c:1468 [inline]
 do_garbage_collect+0x4f59/0x6370 fs/f2fs/gc.c:1673
 f2fs_gc+0x8aa/0x17c0 fs/f2fs/gc.c:1766
 f2fs_balance_fs+0x339/0x3e0 fs/f2fs/segment.c:531
 f2fs_write_inode+0x4fc/0x580 fs/f2fs/inode.c:734
 write_inode+0xf5/0x2a0 fs/fs-writeback.c:1475
 __writeback_single_inode+0x38b/0x6d0 fs/fs-writeback.c:1680
 writeback_sb_inodes+0xb1d/0x1910 fs/fs-writeback.c:1892
 wb_writeback+0x401/0x9e0 fs/fs-writeback.c:2066
 wb_do_writeback+0x222/0xbd0 fs/fs-writeback.c:2209
 wb_workfn+0xf8/0x3e0 fs/fs-writeback.c:2250
 process_one_work+0x6db/0xc00 kernel/workqueue.c:2313
 worker_thread+0xb3e/0x1340 kernel/workqueue.c:2460
 kthread+0x41c/0x500 kernel/kthread.c:319
 ret_from_fork+0x1f/0x30
 </TASK>

The buggy address belongs to the page:
page:ffffea00046cb780 refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x11b2de
flags: 0x4000000000000000(zone=1)
raw: 4000000000000000 ffffea00046cb7c8 ffffea00046cb6c8 0000000000000000
raw: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as freed
page last allocated via order 0, migratetype Unmovable, gfp_mask 0x500cc2(GFP_HIGHUSER|__GFP_ACCOUNT), pid 319, ts 12366895923, free_ts 12367377157
 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
 __alloc_pages_node include/linux/gfp.h:591 [inline]
 alloc_pages_node include/linux/gfp.h:605 [inline]
 alloc_pages include/linux/gfp.h:618 [inline]
 pipe_write+0x560/0x18c0 fs/pipe.c:495
 call_write_iter include/linux/fs.h:2129 [inline]
 new_sync_write fs/read_write.c:507 [inline]
 vfs_write+0xc8d/0x1050 fs/read_write.c:594
 ksys_write+0x198/0x2c0 fs/read_write.c:647
 __do_sys_write fs/read_write.c:659 [inline]
 __se_sys_write fs/read_write.c:656 [inline]
 __x64_sys_write+0x7b/0x90 fs/read_write.c:656
 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
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
 __put_single_page mm/swap.c:98 [inline]
 __put_page+0xb0/0xd0 mm/swap.c:129
 put_page include/linux/mm.h:1288 [inline]
 anon_pipe_buf_release+0x17b/0x1e0 fs/pipe.c:137
 pipe_buf_release include/linux/pipe_fs_i.h:203 [inline]
 pipe_read+0x5c1/0x1060 fs/pipe.c:323
 call_read_iter include/linux/fs.h:2123 [inline]
 new_sync_read fs/read_write.c:404 [inline]
 vfs_read+0xabc/0xd80 fs/read_write.c:485
 ksys_read+0x198/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+0x44/0xd0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x61/0xcb

Memory state around the buggy address:
 ffff88811b2de000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ffff88811b2de080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>ffff88811b2de100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
                                                 ^
 ffff88811b2de180: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ffff88811b2de200: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
==================================================================

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2022/10/20 17:58 android13-5.15-lts 7f2e600bf63a b31320fc .config strace log report syz C [disk image] [vmlinux] [mounted in repro] ci2-android-5-15 KASAN: use-after-free Read in do_garbage_collect
2022/11/13 10:47 android13-5.15-lts 7f2e600bf63a f42ee5d8 .config console log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro] ci2-android-5-15 KASAN: slab-out-of-bounds Read in do_garbage_collect
* Struck through repros no longer work on HEAD.