================================================================== BUG: KASAN: slab-use-after-free in __release_resource+0x276/0x2c0 kernel/resource.c:221 Read of size 8 at addr ffff888043774738 by task syz.2.1299/10504 CPU: 1 UID: 0 PID: 10504 Comm: syz.2.1299 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:0x7f744c19de99 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:00007f744d0c8028 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 RAX: ffffffffffffffda RBX: 00007f744c425fa0 RCX: 00007f744c19de99 RDX: 0000000000000001 RSI: 0000200000000140 RDI: 0000000000000005 RBP: 00007f744c233eaf R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007f744c426038 R14: 00007f744c425fa0 R15: 00007ffd4d0536e8 Allocated by task 8603: 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 device_driver_attach+0xd1/0x220 drivers/base/dd.c:1203 bind_store+0xf4/0x190 drivers/base/bus.c:267 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 10504: 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 ffff888043774700 which belongs to the cache kmalloc-128 of size 128 The buggy address is located 56 bytes inside of freed 128-byte region [ffff888043774700, ffff888043774780) The buggy address belongs to the physical page: page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x43774 flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff) page_type: f5(slab) raw: 00fff00000000000 ffff88801bc42a00 dead000000000100 dead000000000122 raw: 0000000000000000 0000000800100010 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 2, tgid 2 (kthreadd), ts 107447835183, free_ts 107447448635 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] __do_kmalloc_node mm/slub.c:5333 [inline] __kmalloc_noprof+0x66d/0x820 mm/slub.c:5359 _kmalloc_noprof include/linux/slab.h:992 [inline] _kzalloc_noprof include/linux/slab.h:1309 [inline] lsm_blob_alloc+0x68/0x90 security/security.c:218 lsm_task_alloc security/security.c:270 [inline] security_task_alloc+0x2a/0x260 security/security.c:2785 copy_process+0x2b94/0x8030 kernel/fork.c:2271 kernel_clone+0x176/0x9d0 kernel/fork.c:2748 kernel_thread+0xdb/0x120 kernel/fork.c:2809 create_kthread kernel/kthread.c:459 [inline] kthreadd+0x498/0x7a0 kernel/kthread.c:817 ret_from_fork+0x72b/0xd50 arch/x86/kernel/process.c:158 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245 page last free pid 8280 tgid 8279 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 selinux_genfs_get_sid security/selinux/hooks.c:1364 [inline] inode_doinit_with_dentry+0x99d/0x1320 security/selinux/hooks.c:1563 selinux_d_instantiate+0x26/0x40 security/selinux/hooks.c:6678 security_d_instantiate+0x14c/0x1b0 security/security.c:3704 d_make_persistent+0x64/0x180 fs/dcache.c:2970 __debugfs_create_file+0x25e/0x4f0 fs/debugfs/inode.c:450 debugfs_create_file_full+0x41/0x60 fs/debugfs/inode.c:460 ref_tracker_dir_debugfs+0x19e/0x2e0 lib/ref_tracker.c:440 ref_tracker_dir_init include/linux/ref_tracker.h:70 [inline] alloc_netdev_mqs+0x314/0x15c0 net/core/dev.c:12061 rtnl_create_link+0xc13/0xf80 net/core/rtnetlink.c:3721 rtnl_newlink_create net/core/rtnetlink.c:3903 [inline] __rtnl_newlink net/core/rtnetlink.c:4044 [inline] rtnl_newlink+0x13bd/0x2380 net/core/rtnetlink.c:4159 rtnetlink_rcv_msg+0x95e/0xe90 net/core/rtnetlink.c:7076 netlink_rcv_skb+0x159/0x420 net/netlink/af_netlink.c:2556 netlink_unicast_kernel net/netlink/af_netlink.c:1319 [inline] netlink_unicast+0x585/0x850 net/netlink/af_netlink.c:1345 netlink_sendmsg+0x8b0/0xda0 net/netlink/af_netlink.c:1900 sock_sendmsg_nosec net/socket.c:775 [inline] __sock_sendmsg net/socket.c:790 [inline] ____sys_sendmsg+0xa4d/0xbe0 net/socket.c:2684 Memory state around the buggy address: ffff888043774600: 00 00 00 00 00 00 00 00 00 00 00 00 00 fc fc fc ffff888043774680: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff888043774700: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff888043774780: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff888043774800: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ==================================================================