syzbot


KASAN: use-after-free Read in f2fs_write_end_io

Status: auto-obsoleted due to no activity on 2024/07/06 04:33
Reported-by: syzbot+c7eda130c8c2b2cb05a5@syzkaller.appspotmail.com
First crash: 230d, last: 230d
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in f2fs_write_end_io f2fs 1 838d 830d 0/28 auto-obsoleted due to no activity on 2022/12/06 18:50

Sample crash report:
 kthread+0x34b/0x3d0 kernel/kthread.c:313
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:299
==================================================================
BUG: KASAN: use-after-free in instrument_atomic_read include/linux/instrumented.h:71 [inline]
BUG: KASAN: use-after-free in atomic_read include/asm-generic/atomic-instrumented.h:27 [inline]
BUG: KASAN: use-after-free in get_pages fs/f2fs/f2fs.h:2446 [inline]
BUG: KASAN: use-after-free in f2fs_write_end_io+0x8a2/0x990 fs/f2fs/data.c:369
Read of size 4 at addr ffff8881297e468c by task ksoftirqd/0/12

CPU: 0 PID: 12 Comm: ksoftirqd/0 Tainted: G        W         5.10.209-syzkaller-00001-ge7daca75b4c3 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/27/2024
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack_lvl+0x1e2/0x24b lib/dump_stack.c:118
 print_address_description+0x81/0x3b0 mm/kasan/report.c:248
 __kasan_report mm/kasan/report.c:435 [inline]
 kasan_report+0x179/0x1c0 mm/kasan/report.c:452
 kasan_check_range+0x293/0x2a0 mm/kasan/generic.c:189
 __kasan_check_read+0x11/0x20 mm/kasan/shadow.c:31
 instrument_atomic_read include/linux/instrumented.h:71 [inline]
 atomic_read include/asm-generic/atomic-instrumented.h:27 [inline]
 get_pages fs/f2fs/f2fs.h:2446 [inline]
 f2fs_write_end_io+0x8a2/0x990 fs/f2fs/data.c:369
 bio_endio+0x520/0x6a0 block/bio.c:1459
 req_bio_endio block/blk-core.c:263 [inline]
 blk_update_request+0x6e9/0x12b0 block/blk-core.c:1468
 blk_mq_end_request+0x43/0x80 block/blk-mq.c:569
 lo_complete_rq+0x154/0x2f0 drivers/block/loop.c:490
 blk_done_softirq+0x345/0x3d0 block/blk-mq.c:593
 __do_softirq+0x268/0x5bb kernel/softirq.c:309
 run_ksoftirqd+0x23/0x30 kernel/softirq.c:670
 smpboot_thread_fn+0x545/0x930 kernel/smpboot.c:164
 kthread+0x34b/0x3d0 kernel/kthread.c:313
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:299

Allocated by task 22706:
 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:430 [inline]
 ____kasan_kmalloc+0xdb/0x110 mm/kasan/common.c:509
 __kasan_kmalloc+0x9/0x10 mm/kasan/common.c:518
 kasan_kmalloc include/linux/kasan.h:254 [inline]
 kmem_cache_alloc_trace+0x18a/0x2e0 mm/slub.c:2974
 kmalloc include/linux/slab.h:552 [inline]
 kzalloc include/linux/slab.h:664 [inline]
 f2fs_fill_super+0xc5/0x7e30 fs/f2fs/super.c:4049
 mount_bdev+0x262/0x370 fs/super.c:1429
 f2fs_mount+0x34/0x40 fs/f2fs/super.c:4555
 legacy_get_tree+0xf1/0x190 fs/fs_context.c:593
 vfs_get_tree+0x88/0x290 fs/super.c:1559
 do_new_mount+0x2ba/0xb30 fs/namespace.c:2910
 path_mount+0x56f/0xcb0 fs/namespace.c:3240
 do_mount fs/namespace.c:3253 [inline]
 __do_sys_mount fs/namespace.c:3461 [inline]
 __se_sys_mount+0x2c4/0x3b0 fs/namespace.c:3438
 __x64_sys_mount+0xbf/0xd0 fs/namespace.c:3438
 do_syscall_64+0x34/0x70
 entry_SYSCALL_64_after_hwframe+0x61/0xc6

Freed by task 21857:
 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+0x121/0x160 mm/kasan/common.c:362
 __kasan_slab_free+0x11/0x20 mm/kasan/common.c:370
 kasan_slab_free include/linux/kasan.h:220 [inline]
 slab_free_hook mm/slub.c:1595 [inline]
 slab_free_freelist_hook+0xc0/0x190 mm/slub.c:1621
 slab_free mm/slub.c:3203 [inline]
 kfree+0xc3/0x270 mm/slub.c:4191
 f2fs_put_super+0xaa0/0xc10 fs/f2fs/super.c:1654
 generic_shutdown_super+0x14f/0x2d0 fs/super.c:465
 kill_block_super+0x7e/0xe0 fs/super.c:1456
 kill_f2fs_super+0x2f9/0x3c0 fs/f2fs/super.c:4587
 deactivate_locked_super+0xad/0x110 fs/super.c:335
 deactivate_super+0xbe/0xf0 fs/super.c:366
 cleanup_mnt+0x45c/0x510 fs/namespace.c:1118
 __cleanup_mnt+0x19/0x20 fs/namespace.c:1125
 task_work_run+0x129/0x190 kernel/task_work.c:164
 tracehook_notify_resume include/linux/tracehook.h:188 [inline]
 exit_to_user_mode_loop+0xbf/0xd0 kernel/entry/common.c:172
 exit_to_user_mode_prepare kernel/entry/common.c:199 [inline]
 syscall_exit_to_user_mode+0xc5/0x1d0 kernel/entry/common.c:274
 do_syscall_64+0x40/0x70 arch/x86/entry/common.c:56
 entry_SYSCALL_64_after_hwframe+0x61/0xc6

The buggy address belongs to the object at ffff8881297e4000
 which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 1676 bytes inside of
 4096-byte region [ffff8881297e4000, ffff8881297e5000)
The buggy address belongs to the page:
page:ffffea0004a5f800 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1297e0
head:ffffea0004a5f800 order:3 compound_mapcount:0 compound_pincount:0
flags: 0x4000000000010200(slab|head)
raw: 4000000000010200 ffffea000457a400 0000000300000003 ffff888100042c00
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 0x1d60c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_RETRY_MAYFAIL|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 9446, ts 345471777464, free_ts 345103708996
 set_page_owner include/linux/page_owner.h:35 [inline]
 post_alloc_hook mm/page_alloc.c:2456 [inline]
 prep_new_page+0x166/0x180 mm/page_alloc.c:2462
 get_page_from_freelist+0x2d8c/0x2f30 mm/page_alloc.c:4254
 __alloc_pages_nodemask+0x435/0xaf0 mm/page_alloc.c:5346
 allocate_slab mm/slub.c:1808 [inline]
 new_slab+0x80/0x400 mm/slub.c:1869
 new_slab_objects mm/slub.c:2627 [inline]
 ___slab_alloc+0x302/0x4b0 mm/slub.c:2791
 __slab_alloc+0x63/0xa0 mm/slub.c:2831
 slab_alloc_node mm/slub.c:2913 [inline]
 slab_alloc mm/slub.c:2955 [inline]
 __kmalloc+0x204/0x330 mm/slub.c:4029
 __kmalloc_node include/linux/slab.h:418 [inline]
 kmalloc_node include/linux/slab.h:575 [inline]
 kvmalloc_node+0x82/0x130 mm/util.c:612
 kvmalloc include/linux/mm.h:822 [inline]
 kvzalloc include/linux/mm.h:830 [inline]
 alloc_netdev_mqs+0x8e/0xcd0 net/core/dev.c:10506
 rtnl_create_link+0x240/0x950 net/core/rtnetlink.c:3192
 __rtnl_newlink net/core/rtnetlink.c:3469 [inline]
 rtnl_newlink+0x1399/0x2000 net/core/rtnetlink.c:3527
 rtnetlink_rcv_msg+0x955/0xc50 net/core/rtnetlink.c:5608
 netlink_rcv_skb+0x1cf/0x410 net/netlink/af_netlink.c:2497
 rtnetlink_rcv+0x1c/0x20 net/core/rtnetlink.c:5626
 netlink_unicast_kernel net/netlink/af_netlink.c:1322 [inline]
 netlink_unicast+0x8df/0xac0 net/netlink/af_netlink.c:1348
 netlink_sendmsg+0xa46/0xd00 net/netlink/af_netlink.c:1916
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:28 [inline]
 free_pages_prepare mm/page_alloc.c:1349 [inline]
 __free_pages_ok+0x82c/0x850 mm/page_alloc.c:1629
 free_the_page+0x76/0x370 mm/page_alloc.c:5407
 __free_pages+0x67/0xc0 mm/page_alloc.c:5416
 __free_slab+0xcf/0x190 mm/slub.c:1894
 free_slab mm/slub.c:1909 [inline]
 discard_slab+0x29/0x40 mm/slub.c:1915
 __slab_free+0x30d/0x3a0 mm/slub.c:3131
 do_slab_free mm/slub.c:3191 [inline]
 ___cache_free+0x111/0x130 mm/slub.c:3210
 qlink_free+0x50/0x90 mm/kasan/quarantine.c:157
 qlist_free_all+0x47/0xb0 mm/kasan/quarantine.c:176
 kasan_quarantine_reduce+0x15a/0x170 mm/kasan/quarantine.c:283
 __kasan_slab_alloc+0x2f/0xe0 mm/kasan/common.c:440
 kasan_slab_alloc include/linux/kasan.h:244 [inline]
 slab_post_alloc_hook+0x61/0x2f0 mm/slab.h:583
 slab_alloc_node mm/slub.c:2947 [inline]
 slab_alloc mm/slub.c:2955 [inline]
 kmem_cache_alloc+0x168/0x2e0 mm/slub.c:2960
 getname_flags+0xba/0x520 fs/namei.c:141
 getname+0x19/0x20 fs/namei.c:212
 do_sys_openat2+0xd7/0x6f0 fs/open.c:1211

Memory state around the buggy address:
 ffff8881297e4580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8881297e4600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8881297e4680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                      ^
 ffff8881297e4700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8881297e4780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/04/07 04:26 android13-5.10-lts e7daca75b4c3 ca620dd8 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-5-10 KASAN: use-after-free Read in f2fs_write_end_io
* Struck through repros no longer work on HEAD.