================================================================== BUG: KASAN: use-after-free in f2fs_available_free_memory+0xa98/0xb00 fs/f2fs/node.c:99 Read of size 4 at addr ffff88810b2d9010 by task f2fs_discard-7:/21553 CPU: 1 PID: 21553 Comm: f2fs_discard-7: Tainted: G W 5.10.100-syzkaller-00843-g86e6176a4240 #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_lvl+0x1e2/0x24b lib/dump_stack.c:118 print_address_description+0x8d/0x3d0 mm/kasan/report.c:233 __kasan_report+0x142/0x220 mm/kasan/report.c:419 kasan_report+0x51/0x70 mm/kasan/report.c:436 __asan_report_load4_noabort+0x14/0x20 mm/kasan/report_generic.c:308 f2fs_available_free_memory+0xa98/0xb00 fs/f2fs/node.c:99 issue_discard_thread+0x2dd/0x1b00 fs/f2fs/segment.c:1761 kthread+0x371/0x390 kernel/kthread.c:313 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:296 Allocated by task 21537: kasan_save_stack mm/kasan/common.c:38 [inline] kasan_set_track mm/kasan/common.c:46 [inline] set_alloc_info mm/kasan/common.c:428 [inline] ____kasan_kmalloc+0xdc/0x110 mm/kasan/common.c:507 __kasan_kmalloc+0x9/0x10 mm/kasan/common.c:516 kasan_kmalloc include/linux/kasan.h:269 [inline] kmem_cache_alloc_trace+0x210/0x3a0 mm/slub.c:2981 kmalloc include/linux/slab.h:552 [inline] f2fs_kmalloc fs/f2fs/f2fs.h:3246 [inline] f2fs_kzalloc fs/f2fs/f2fs.h:3252 [inline] f2fs_build_node_manager+0x57/0x13b0 fs/f2fs/node.c:3217 f2fs_fill_super+0x5f24/0x9260 fs/f2fs/super.c:4032 mount_bdev+0x25f/0x370 fs/super.c:1419 f2fs_mount+0x34/0x40 fs/f2fs/super.c:4302 legacy_get_tree+0xf0/0x190 fs/fs_context.c:592 vfs_get_tree+0x89/0x270 fs/super.c:1549 do_new_mount fs/namespace.c:2899 [inline] path_mount+0x1975/0x2ab0 fs/namespace.c:3229 do_mount fs/namespace.c:3242 [inline] __do_sys_mount fs/namespace.c:3450 [inline] __se_sys_mount+0x2f7/0x3b0 fs/namespace.c:3427 __x64_sys_mount+0xbf/0xd0 fs/namespace.c:3427 do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x44/0xa9 Freed by task 21537: kasan_save_stack mm/kasan/common.c:38 [inline] kasan_set_track+0x4c/0x80 mm/kasan/common.c:46 kasan_set_free_info+0x23/0x40 mm/kasan/generic.c:357 ____kasan_slab_free+0x133/0x170 mm/kasan/common.c:360 __kasan_slab_free+0x11/0x20 mm/kasan/common.c:368 kasan_slab_free include/linux/kasan.h:235 [inline] slab_free_hook mm/slub.c:1602 [inline] slab_free_freelist_hook+0xcc/0x1a0 mm/slub.c:1628 slab_free mm/slub.c:3210 [inline] kfree+0xd5/0x320 mm/slub.c:4198 f2fs_destroy_node_manager+0xe1d/0xf80 fs/f2fs/node.c:3310 f2fs_fill_super+0x729a/0x9260 fs/f2fs/super.c:4247 mount_bdev+0x25f/0x370 fs/super.c:1419 f2fs_mount+0x34/0x40 fs/f2fs/super.c:4302 legacy_get_tree+0xf0/0x190 fs/fs_context.c:592 vfs_get_tree+0x89/0x270 fs/super.c:1549 do_new_mount fs/namespace.c:2899 [inline] path_mount+0x1975/0x2ab0 fs/namespace.c:3229 do_mount fs/namespace.c:3242 [inline] __do_sys_mount fs/namespace.c:3450 [inline] __se_sys_mount+0x2f7/0x3b0 fs/namespace.c:3427 __x64_sys_mount+0xbf/0xd0 fs/namespace.c:3427 do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x44/0xa9 The buggy address belongs to the object at ffff88810b2d9000 which belongs to the cache kmalloc-512 of size 512 The buggy address is located 16 bytes inside of 512-byte region [ffff88810b2d9000, ffff88810b2d9200) The buggy address belongs to the page: page:ffffea00042cb600 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x10b2d8 head:ffffea00042cb600 order:2 compound_mapcount:0 compound_pincount:0 flags: 0x8000000000010200(slab|head) raw: 8000000000010200 ffffea00055b0200 0000000200000002 ffff888100043080 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), pid 1, ts 2071769641, free_ts 2070180131 set_page_owner include/linux/page_owner.h:35 [inline] post_alloc_hook mm/page_alloc.c:2385 [inline] prep_new_page mm/page_alloc.c:2391 [inline] get_page_from_freelist+0xa74/0xa90 mm/page_alloc.c:4063 __alloc_pages_nodemask+0x3c8/0x820 mm/page_alloc.c:5107 alloc_slab_page mm/slub.c:1813 [inline] allocate_slab+0x6b/0x350 mm/slub.c:1815 new_slab mm/slub.c:1876 [inline] new_slab_objects mm/slub.c:2635 [inline] ___slab_alloc+0x143/0x2f0 mm/slub.c:2798 __slab_alloc mm/slub.c:2838 [inline] slab_alloc_node mm/slub.c:2920 [inline] slab_alloc mm/slub.c:2962 [inline] __kmalloc_track_caller+0x299/0x3b0 mm/slub.c:4543 __kmalloc_reserve net/core/skbuff.c:143 [inline] __alloc_skb+0xb7/0x580 net/core/skbuff.c:211 alloc_skb include/linux/skbuff.h:1101 [inline] alloc_uevent_skb+0x7f/0x230 lib/kobject_uevent.c:290 uevent_net_broadcast_tagged lib/kobject_uevent.c:351 [inline] kobject_uevent_net_broadcast lib/kobject_uevent.c:412 [inline] kobject_uevent_env+0xbfb/0x1400 lib/kobject_uevent.c:593 kobject_uevent+0x1f/0x30 lib/kobject_uevent.c:642 device_add+0xfd4/0x1590 drivers/base/core.c:3221 netdev_register_kobject+0x179/0x320 net/core/net-sysfs.c:1997 register_netdevice+0x11b5/0x1ad0 net/core/dev.c:10114 register_netdev+0x3c/0x50 net/core/dev.c:10245 sit_init_net+0x243/0x480 net/ipv6/sit.c:1914 ops_init+0x199/0x380 net/core/net_namespace.c:152 __register_pernet_operations net/core/net_namespace.c:1162 [inline] register_pernet_operations+0x2de/0xa40 net/core/net_namespace.c:1239 page last free stack trace: reset_page_owner include/linux/page_owner.h:28 [inline] free_pages_prepare mm/page_alloc.c:1331 [inline] __free_pages_ok+0xbe7/0xc20 mm/page_alloc.c:1611 free_the_page mm/page_alloc.c:5168 [inline] __free_pages+0x2d6/0x4a0 mm/page_alloc.c:5174 free_pages+0x7c/0x90 mm/page_alloc.c:5185 stack_depot_save+0x431/0x480 lib/stackdepot.c:336 kasan_save_stack mm/kasan/common.c:40 [inline] kasan_set_track mm/kasan/common.c:46 [inline] set_alloc_info mm/kasan/common.c:428 [inline] __kasan_slab_alloc+0xc9/0xe0 mm/kasan/common.c:461 kasan_slab_alloc include/linux/kasan.h:259 [inline] slab_post_alloc_hook mm/slab.h:583 [inline] slab_alloc_node mm/slub.c:2954 [inline] slab_alloc mm/slub.c:2962 [inline] kmem_cache_alloc+0x1a2/0x380 mm/slub.c:2967 kmem_cache_zalloc include/linux/slab.h:654 [inline] __kernfs_new_node+0xdb/0x6e0 fs/kernfs/dir.c:627 kernfs_new_node+0x97/0x170 fs/kernfs/dir.c:689 __kernfs_create_file+0x4a/0x270 fs/kernfs/file.c:985 sysfs_add_file_mode_ns+0x274/0x320 fs/sysfs/file.c:306 create_files fs/sysfs/group.c:64 [inline] internal_create_group+0x560/0xf10 fs/sysfs/group.c:149 sysfs_create_group+0x1f/0x30 fs/sysfs/group.c:175 netdev_queue_add_kobject net/core/net-sysfs.c:1655 [inline] netdev_queue_update_kobjects+0x199/0x3c0 net/core/net-sysfs.c:1694 register_queue_kobjects net/core/net-sysfs.c:1755 [inline] netdev_register_kobject+0x270/0x320 net/core/net-sysfs.c:2001 register_netdevice+0x11b5/0x1ad0 net/core/dev.c:10114 register_netdev+0x3c/0x50 net/core/dev.c:10245 Memory state around the buggy address: ffff88810b2d8f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff88810b2d8f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff88810b2d9000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88810b2d9080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88810b2d9100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================