================================================================== BUG: KASAN: slab-use-after-free in __release_resource+0x276/0x2c0 kernel/resource.c:221 Read of size 8 at addr ffff88802c3c7c38 by task syz.8.1165/10567 CPU: 0 UID: 0 PID: 10567 Comm: syz.8.1165 Tainted: G L syzkaller #0 PREEMPT(full) Tainted: [L]=SOFTLOCKUP Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 Call Trace: __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0x100/0x190 lib/dump_stack.c:120 print_address_description mm/kasan/report.c:378 [inline] print_report+0x13d/0x4b0 mm/kasan/report.c:482 kasan_report+0xdf/0x1c0 mm/kasan/report.c:595 __release_resource+0x276/0x2c0 kernel/resource.c:221 release_resource+0x26/0x40 kernel/resource.c:319 pci_free_resources drivers/pci/remove.c:16 [inline] pci_destroy_dev drivers/pci/remove.c:56 [inline] pci_remove_bus_device+0x2d3/0x3b0 drivers/pci/remove.c:110 pci_stop_and_remove_bus_device_locked+0x1a/0x20 drivers/pci/remove.c:136 remove_store+0x123/0x140 drivers/pci/pci-sysfs.c:523 dev_attr_store+0x58/0x80 drivers/base/core.c:2505 sysfs_kf_write+0xf2/0x150 fs/sysfs/file.c:145 kernfs_fop_write_iter+0x3e0/0x5f0 fs/kernfs/file.c:345 new_sync_write fs/read_write.c:595 [inline] vfs_write+0x6ac/0x1050 fs/read_write.c:687 ksys_write+0x12a/0x250 fs/read_write.c:739 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0x115/0x870 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7f395459de99 Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f3955481028 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 RAX: ffffffffffffffda RBX: 00007f3954825fa0 RCX: 00007f395459de99 RDX: 0000000000000001 RSI: 00002000000000c0 RDI: 0000000000000004 RBP: 00007f3954633eaf R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007f3954826038 R14: 00007f3954825fa0 R15: 00007ffe3674a188 Allocated by task 9538: kasan_save_stack+0x30/0x50 mm/kasan/common.c:57 kasan_save_track+0x14/0x30 mm/kasan/common.c:78 poison_kmalloc_redzone mm/kasan/common.c:398 [inline] __kasan_kmalloc+0xaa/0xb0 mm/kasan/common.c:415 kasan_kmalloc include/linux/kasan.h:263 [inline] __do_kmalloc_node mm/slub.c:5334 [inline] __kmalloc_node_track_caller_noprof+0x331/0x830 mm/slub.c:5471 kmemdup_noprof+0x29/0x60 mm/util.c:138 platform_device_add_resources+0x37/0x100 drivers/base/platform.c:657 dwc2_pci_probe+0x1d3/0x360 drivers/usb/dwc2/pci.c:94 local_pci_probe+0xdd/0x1b0 drivers/pci/pci-driver.c:332 pci_call_probe+0x176/0x800 drivers/pci/pci-driver.c:394 __pci_device_probe drivers/pci/pci-driver.c:455 [inline] pci_device_probe+0x1cd/0x370 drivers/pci/pci-driver.c:489 call_driver_probe drivers/base/dd.c:628 [inline] really_probe+0x241/0xa60 drivers/base/dd.c:706 __driver_probe_device+0x20e/0x450 drivers/base/dd.c:868 driver_probe_device+0x4a/0x140 drivers/base/dd.c:898 __driver_attach+0x21f/0x5b0 drivers/base/dd.c:1292 bus_for_each_dev+0x13e/0x1d0 drivers/base/bus.c:383 pci_add_dynid+0x2b5/0x370 drivers/pci/pci-driver.c:77 new_id_store+0x2a9/0x5b0 drivers/pci/pci-driver.c:249 drv_attr_store+0x74/0xb0 drivers/base/bus.c:125 sysfs_kf_write+0xf2/0x150 fs/sysfs/file.c:145 kernfs_fop_write_iter+0x3e0/0x5f0 fs/kernfs/file.c:345 new_sync_write fs/read_write.c:595 [inline] vfs_write+0x6ac/0x1050 fs/read_write.c:687 ksys_write+0x12a/0x250 fs/read_write.c:739 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0x115/0x870 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f Freed by task 10567: kasan_save_stack+0x30/0x50 mm/kasan/common.c:57 kasan_save_track+0x14/0x30 mm/kasan/common.c:78 kasan_save_free_info+0x3b/0x70 mm/kasan/generic.c:584 poison_slab_object mm/kasan/common.c:253 [inline] __kasan_slab_free+0x5f/0x80 mm/kasan/common.c:285 kasan_slab_free include/linux/kasan.h:235 [inline] slab_free_hook mm/slub.c:2677 [inline] slab_free mm/slub.c:6377 [inline] kfree+0x22b/0x6c0 mm/slub.c:6692 platform_device_release+0x8a/0xb0 drivers/base/platform.c:605 device_release+0xd2/0x270 drivers/base/core.c:2636 kobject_cleanup lib/kobject.c:689 [inline] kobject_release lib/kobject.c:720 [inline] kref_put include/linux/kref.h:65 [inline] kobject_put+0x1f7/0x640 lib/kobject.c:737 put_device+0x1f/0x30 drivers/base/core.c:3880 platform_device_put drivers/base/platform.c:593 [inline] platform_device_unregister+0x45/0x50 drivers/base/platform.c:840 dwc2_pci_remove+0x55/0xd0 drivers/usb/dwc2/pci.c:46 pci_device_remove+0xb2/0x1d0 drivers/pci/pci-driver.c:512 device_remove+0xcb/0x180 drivers/base/dd.c:616 __device_release_driver drivers/base/dd.c:1349 [inline] device_release_driver_internal+0x44e/0x620 drivers/base/dd.c:1372 pci_stop_dev drivers/pci/remove.c:27 [inline] pci_stop_bus_device+0x120/0x160 drivers/pci/remove.c:93 pci_stop_and_remove_bus_device+0x58/0xa0 drivers/pci/remove.c:128 pci_stop_and_remove_bus_device_locked+0x1a/0x20 drivers/pci/remove.c:136 remove_store+0x123/0x140 drivers/pci/pci-sysfs.c:523 dev_attr_store+0x58/0x80 drivers/base/core.c:2505 sysfs_kf_write+0xf2/0x150 fs/sysfs/file.c:145 kernfs_fop_write_iter+0x3e0/0x5f0 fs/kernfs/file.c:345 new_sync_write fs/read_write.c:595 [inline] vfs_write+0x6ac/0x1050 fs/read_write.c:687 ksys_write+0x12a/0x250 fs/read_write.c:739 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0x115/0x870 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f The buggy address belongs to the object at ffff88802c3c7c00 which belongs to the cache kmalloc-128 of size 128 The buggy address is located 56 bytes inside of freed 128-byte region [ffff88802c3c7c00, ffff88802c3c7c80) The buggy address belongs to the physical page: page: refcount:0 mapcount:0 mapping:0000000000000000 index:0xffff88802c3c7300 pfn:0x2c3c7 flags: 0xfff00000000200(workingset|node=0|zone=1|lastcpupid=0x7ff) page_type: f5(slab) raw: 00fff00000000200 ffff88801bc42a00 ffffea0000a9abd0 ffffea0000f37110 raw: ffff88802c3c7300 000000080010000e 00000000f5000000 0000000000000000 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 0, migratetype Unmovable, gfp_mask 0xd2cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 8497, tgid 8496 (syz.5.668), ts 129106615756, free_ts 126166365610 set_page_owner include/linux/page_owner.h:32 [inline] post_alloc_hook+0xfd/0x120 mm/page_alloc.c:1859 prep_new_page mm/page_alloc.c:1867 [inline] get_page_from_freelist+0xf48/0x3530 mm/page_alloc.c:3946 __alloc_frozen_pages_noprof+0x299/0x2dc0 mm/page_alloc.c:5304 alloc_slab_page mm/slub.c:3266 [inline] allocate_slab mm/slub.c:3380 [inline] new_slab+0xa2/0x640 mm/slub.c:3426 refill_objects+0xe3/0x410 mm/slub.c:7310 refill_sheaf mm/slub.c:2804 [inline] __pcs_replace_empty_main+0x376/0x680 mm/slub.c:4675 alloc_from_pcs mm/slub.c:4773 [inline] slab_alloc_node mm/slub.c:4905 [inline] __kmalloc_cache_noprof+0x479/0x6c0 mm/slub.c:5485 _kmalloc_noprof include/linux/slab.h:988 [inline] _kzalloc_noprof include/linux/slab.h:1309 [inline] nf_nat_masq_schedule.part.0+0x3bb/0x7a0 net/netfilter/nf_nat_masquerade.c:118 nf_nat_masq_schedule net/netfilter/nf_nat_masquerade.c:108 [inline] masq_device_event+0xfd/0x120 net/netfilter/nf_nat_masquerade.c:162 notifier_call_chain+0x99/0x3f0 kernel/notifier.c:85 call_netdevice_notifiers_info+0xbe/0x110 net/core/dev.c:2250 call_netdevice_notifiers_extack net/core/dev.c:2288 [inline] call_netdevice_notifiers net/core/dev.c:2302 [inline] netif_close_many+0x319/0x630 net/core/dev.c:1806 unregister_netdevice_many_notify+0x840/0x2140 net/core/dev.c:12416 rtnl_delete_link net/core/rtnetlink.c:3601 [inline] rtnl_dellink+0x472/0xb40 net/core/rtnetlink.c:3643 rtnetlink_rcv_msg+0x95e/0xe90 net/core/rtnetlink.c:7076 netlink_rcv_skb+0x159/0x420 net/netlink/af_netlink.c:2556 page last free pid 33 tgid 33 stack trace: reset_page_owner include/linux/page_owner.h:25 [inline] __free_pages_prepare mm/page_alloc.c:1406 [inline] __free_frozen_pages+0x79f/0x1090 mm/page_alloc.c:2950 __pagetable_free include/linux/mm.h:3695 [inline] pagetable_free include/linux/mm.h:3719 [inline] pagetable_dtor_free include/linux/mm.h:3818 [inline] __tlb_remove_table include/asm-generic/tlb.h:221 [inline] __tlb_remove_table_free mm/mmu_gather.c:228 [inline] tlb_remove_table_rcu+0x2cf/0x380 mm/mmu_gather.c:291 rcu_do_batch kernel/rcu/tree.c:2645 [inline] rcu_core+0x5a2/0x10d0 kernel/rcu/tree.c:2897 handle_softirqs+0x1ea/0x9b0 kernel/softirq.c:622 run_ksoftirqd kernel/softirq.c:1076 [inline] run_ksoftirqd+0x38/0x60 kernel/softirq.c:1068 smpboot_thread_fn+0x3d3/0xaa0 kernel/smpboot.c:160 kthread+0x370/0x450 kernel/kthread.c:436 ret_from_fork+0x72b/0xd50 arch/x86/kernel/process.c:158 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245 Memory state around the buggy address: ffff88802c3c7b00: 00 00 00 00 00 00 00 00 00 00 00 00 00 fc fc fc ffff88802c3c7b80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff88802c3c7c00: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88802c3c7c80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff88802c3c7d00: 00 00 00 00 00 00 00 00 00 00 00 00 00 fc fc fc ==================================================================