================================================================== BUG: KASAN: use-after-free in f2fs_available_free_memory+0xa92/0xb00 fs/f2fs/node.c:99 Read of size 4 at addr ffff8881e9739410 by task f2fs_discard-7:/29234 CPU: 1 PID: 29234 Comm: f2fs_discard-7: Not tainted 5.4.125-syzkaller-00006-gc0f594e44e6e #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x1d8/0x24e lib/dump_stack.c:118 print_address_description+0x9b/0x650 mm/kasan/report.c:384 __kasan_report+0x182/0x260 mm/kasan/report.c:516 kasan_report+0x30/0x60 mm/kasan/common.c:653 f2fs_available_free_memory+0xa92/0xb00 fs/f2fs/node.c:99 issue_discard_thread+0x2cd/0x1880 fs/f2fs/segment.c:1761 kthread+0x30f/0x330 kernel/kthread.c:268 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:352 Allocated by task 29225: save_stack mm/kasan/common.c:70 [inline] set_track mm/kasan/common.c:78 [inline] __kasan_kmalloc+0x137/0x1e0 mm/kasan/common.c:529 kmem_cache_alloc_trace+0x139/0x2b0 mm/slub.c:2848 kmalloc include/linux/slab.h:556 [inline] f2fs_kmalloc fs/f2fs/f2fs.h:3162 [inline] f2fs_kzalloc fs/f2fs/f2fs.h:3168 [inline] f2fs_build_node_manager+0x57/0x1ee0 fs/f2fs/node.c:3202 f2fs_fill_super+0x6f06/0x9c10 fs/f2fs/super.c:3959 mount_bdev+0x22d/0x340 fs/super.c:1417 legacy_get_tree+0xde/0x170 fs/fs_context.c:647 vfs_get_tree+0x83/0x260 fs/super.c:1547 do_new_mount fs/namespace.c:2825 [inline] do_mount+0x19d0/0x2670 fs/namespace.c:3145 ksys_mount+0xc2/0xf0 fs/namespace.c:3354 __do_sys_mount fs/namespace.c:3368 [inline] __se_sys_mount fs/namespace.c:3365 [inline] __x64_sys_mount+0xb1/0xc0 fs/namespace.c:3365 do_syscall_64+0xcb/0x1e0 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x44/0xa9 Freed by task 29225: save_stack mm/kasan/common.c:70 [inline] set_track mm/kasan/common.c:78 [inline] kasan_set_free_info mm/kasan/common.c:345 [inline] __kasan_slab_free+0x18a/0x240 mm/kasan/common.c:487 slab_free_hook mm/slub.c:1454 [inline] slab_free_freelist_hook+0x7b/0x150 mm/slub.c:1492 slab_free mm/slub.c:3072 [inline] kfree+0xe0/0x660 mm/slub.c:4061 f2fs_destroy_node_manager+0xc39/0xda0 fs/f2fs/node.c:3295 f2fs_fill_super+0x801d/0x9c10 fs/f2fs/super.c:4170 mount_bdev+0x22d/0x340 fs/super.c:1417 legacy_get_tree+0xde/0x170 fs/fs_context.c:647 vfs_get_tree+0x83/0x260 fs/super.c:1547 do_new_mount fs/namespace.c:2825 [inline] do_mount+0x19d0/0x2670 fs/namespace.c:3145 ksys_mount+0xc2/0xf0 fs/namespace.c:3354 __do_sys_mount fs/namespace.c:3368 [inline] __se_sys_mount fs/namespace.c:3365 [inline] __x64_sys_mount+0xb1/0xc0 fs/namespace.c:3365 do_syscall_64+0xcb/0x1e0 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x44/0xa9 The buggy address belongs to the object at ffff8881e9739400 which belongs to the cache kmalloc-512 of size 512 The buggy address is located 16 bytes inside of 512-byte region [ffff8881e9739400, ffff8881e9739600) The buggy address belongs to the page: page:ffffea0007a5ce00 refcount:1 mapcount:0 mapping:ffff8881f5c02500 index:0x0 compound_mapcount: 0 flags: 0x8000000000010200(slab|head) raw: 8000000000010200 dead000000000100 dead000000000122 ffff8881f5c02500 raw: 0000000000000000 0000000000100010 00000001ffffffff 0000000000000000 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 2, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC) set_page_owner include/linux/page_owner.h:31 [inline] post_alloc_hook mm/page_alloc.c:2165 [inline] prep_new_page+0x19a/0x380 mm/page_alloc.c:2171 get_page_from_freelist+0x550/0x8b0 mm/page_alloc.c:3794 __alloc_pages_nodemask+0x3a2/0x880 mm/page_alloc.c:4855 alloc_slab_page+0x39/0x3e0 mm/slub.c:342 allocate_slab mm/slub.c:1675 [inline] new_slab+0x97/0x460 mm/slub.c:1741 new_slab_objects mm/slub.c:2498 [inline] ___slab_alloc+0x330/0x4c0 mm/slub.c:2659 __slab_alloc mm/slub.c:2699 [inline] slab_alloc_node mm/slub.c:2784 [inline] slab_alloc mm/slub.c:2829 [inline] __kmalloc_track_caller+0x1d1/0x2e0 mm/slub.c:4439 kmemdup+0x21/0x50 mm/util.c:127 bpf_migrate_filter net/core/filter.c:1237 [inline] bpf_prepare_filter+0xcdd/0x1360 net/core/filter.c:1323 bpf_prog_create_from_user+0x2a1/0x3d0 net/core/filter.c:1417 seccomp_prepare_filter kernel/seccomp.c:628 [inline] seccomp_prepare_user_filter kernel/seccomp.c:665 [inline] seccomp_set_mode_filter kernel/seccomp.c:1626 [inline] do_seccomp+0x8ab/0x21e0 kernel/seccomp.c:1746 do_syscall_64+0xcb/0x1e0 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x44/0xa9 page_owner free stack trace missing Memory state around the buggy address: ffff8881e9739300: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff8881e9739380: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff8881e9739400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff8881e9739480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8881e9739500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================