================================================================== BUG: KASAN: use-after-free in f2fs_available_free_memory+0x9db/0xa50 fs/f2fs/node.c:99 Read of size 4 at addr ffff8881eb779810 by task f2fs_discard-7:/427 CPU: 1 PID: 427 Comm: f2fs_discard-7: Not tainted 5.4.147-syzkaller-00015-g5b673be0c6b0 #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+0x18e/0x1de 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+0x9db/0xa50 fs/f2fs/node.c:99 issue_discard_thread+0x18d/0x17d0 fs/f2fs/segment.c:1761 kthread+0x30f/0x330 kernel/kthread.c:288 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:352 Allocated by task 412: 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:2849 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+0x6be0/0x97b0 fs/f2fs/super.c:3968 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:2843 [inline] do_mount+0x17be/0x2390 fs/namespace.c:3163 ksys_mount+0xc2/0xf0 fs/namespace.c:3372 __do_sys_mount fs/namespace.c:3386 [inline] __se_sys_mount fs/namespace.c:3383 [inline] __x64_sys_mount+0xb1/0xc0 fs/namespace.c:3383 do_syscall_64+0xcb/0x1e0 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x44/0xa9 Freed by task 412: 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:1455 [inline] slab_free_freelist_hook+0x7b/0x150 mm/slub.c:1493 slab_free mm/slub.c:3073 [inline] kfree+0xe0/0x660 mm/slub.c:4064 f2fs_destroy_node_manager+0xbab/0xce0 fs/f2fs/node.c:3295 f2fs_fill_super+0x7cbc/0x97b0 fs/f2fs/super.c:4179 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:2843 [inline] do_mount+0x17be/0x2390 fs/namespace.c:3163 ksys_mount+0xc2/0xf0 fs/namespace.c:3372 __do_sys_mount fs/namespace.c:3386 [inline] __se_sys_mount fs/namespace.c:3383 [inline] __x64_sys_mount+0xb1/0xc0 fs/namespace.c:3383 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 ffff8881eb779800 which belongs to the cache kmalloc-512 of size 512 The buggy address is located 16 bytes inside of 512-byte region [ffff8881eb779800, ffff8881eb779a00) The buggy address belongs to the page: page:ffffea0007adde00 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 0x1d20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL) 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+0x2d6/0x740 mm/page_alloc.c:4855 alloc_slab_page+0x39/0x3e0 mm/slub.c:343 allocate_slab mm/slub.c:1676 [inline] new_slab+0x97/0x460 mm/slub.c:1742 new_slab_objects mm/slub.c:2499 [inline] ___slab_alloc+0x330/0x4c0 mm/slub.c:2660 __slab_alloc mm/slub.c:2700 [inline] slab_alloc_node mm/slub.c:2785 [inline] slab_alloc mm/slub.c:2830 [inline] __kmalloc_track_caller+0x1d1/0x2e0 mm/slub.c:4442 __kmalloc_reserve net/core/skbuff.c:142 [inline] __alloc_skb+0xaf/0x4d0 net/core/skbuff.c:210 alloc_skb include/linux/skbuff.h:1060 [inline] alloc_skb_with_frags+0xad/0x5a0 net/core/skbuff.c:5809 sock_alloc_send_pskb+0x7f6/0xbc0 net/core/sock.c:2243 unix_dgram_sendmsg+0x5e9/0x2590 net/unix/af_unix.c:1691 sock_sendmsg_nosec net/socket.c:638 [inline] sock_sendmsg net/socket.c:658 [inline] sock_write_iter+0x284/0x380 net/socket.c:990 call_write_iter include/linux/fs.h:1976 [inline] new_sync_write fs/read_write.c:483 [inline] __vfs_write+0x506/0x6b0 fs/read_write.c:496 vfs_write+0x212/0x4e0 fs/read_write.c:558 ksys_write+0x13f/0x240 fs/read_write.c:611 do_syscall_64+0xcb/0x1e0 arch/x86/entry/common.c:290 page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1176 [inline] free_pcp_prepare+0x1a9/0x270 mm/page_alloc.c:1233 free_unref_page_prepare mm/page_alloc.c:3085 [inline] free_unref_page mm/page_alloc.c:3134 [inline] free_the_page mm/page_alloc.c:4915 [inline] __free_pages+0x54/0x1e0 mm/page_alloc.c:4923 __free_slab+0x237/0x2f0 mm/slub.c:1767 free_slab mm/slub.c:1782 [inline] discard_slab mm/slub.c:1788 [inline] unfreeze_partials+0x14f/0x180 mm/slub.c:2280 put_cpu_partial+0xb5/0x150 mm/slub.c:2316 __slab_free mm/slub.c:2964 [inline] do_slab_free mm/slub.c:3061 [inline] ___cache_free+0x352/0x4e0 mm/slub.c:3080 qlist_free_all mm/kasan/quarantine.c:167 [inline] quarantine_reduce+0x17a/0x1e0 mm/kasan/quarantine.c:260 __kasan_kmalloc+0x43/0x1e0 mm/kasan/common.c:507 slab_post_alloc_hook mm/slab.h:584 [inline] slab_alloc_node mm/slub.c:2822 [inline] slab_alloc mm/slub.c:2830 [inline] kmem_cache_alloc_trace+0x113/0x2b0 mm/slub.c:2847 kmalloc include/linux/slab.h:556 [inline] kzalloc include/linux/slab.h:690 [inline] ext4_htree_create_dir_info fs/ext4/dir.c:444 [inline] ext4_dx_readdir fs/ext4/dir.c:563 [inline] ext4_readdir+0x41a/0x3380 fs/ext4/dir.c:147 iterate_dir+0x29a/0x500 fs/readdir.c:67 ksys_getdents64+0x197/0x3f0 fs/readdir.c:374 __do_sys_getdents64 fs/readdir.c:395 [inline] __se_sys_getdents64 fs/readdir.c:392 [inline] __x64_sys_getdents64+0x76/0x80 fs/readdir.c:392 do_syscall_64+0xcb/0x1e0 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x44/0xa9 Memory state around the buggy address: ffff8881eb779700: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff8881eb779780: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff8881eb779800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff8881eb779880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8881eb779900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================