==================================================================
BUG: KASAN: slab-use-after-free in release_resource+0x64/0x140
Read of size 8 at addr ffff888109c3c338 by task syz.7.1960/16619

CPU: 1 UID: 0 PID: 16619 Comm: syz.7.1960 Tainted: G             L      syzkaller #0 PREEMPT(full) 
Tainted: [L]=SOFTLOCKUP
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.2-debian-1.16.2-1 04/01/2014
Call Trace:
 <TASK>
 dump_stack_lvl+0xe8/0x150
 print_report+0xba/0x230
 kasan_report+0x117/0x150
 release_resource+0x64/0x140
 pci_remove_bus_device+0x253/0x2a0
 pci_stop_and_remove_bus_device_locked+0x7f/0xb0
 remove_store+0xe5/0x150
 kernfs_fop_write_iter+0x3a4/0x540
 vfs_write+0x612/0xba0
 ksys_write+0x150/0x270
 do_syscall_64+0x170/0xf80
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f18aa99e019
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:00007f18ab929028 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007f18aac25fa0 RCX: 00007f18aa99e019
RDX: 0000000000000001 RSI: 0000200000000800 RDI: 0000000000000006
RBP: 00007f18aaa3500c R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007f18aac26038 R14: 00007f18aac25fa0 R15: 00007ffddb42b5f8
 </TASK>

Allocated by task 11700:
 kasan_save_track+0x3e/0x80
 __kasan_kmalloc+0x93/0xb0
 __kmalloc_node_track_caller_noprof+0x4d7/0x7b0
 kmemdup_array+0x3f/0x80
 platform_device_add_resources+0x34/0xf0
 dwc2_pci_probe+0x1da/0x400
 pci_device_probe+0x415/0xc70
 really_probe+0x254/0xae0
 __driver_probe_device+0x192/0x320
 device_driver_attach+0xdd/0x1d0
 bind_store+0x1d0/0x220
 kernfs_fop_write_iter+0x3a4/0x540
 vfs_write+0x612/0xba0
 ksys_write+0x150/0x270
 do_syscall_64+0x170/0xf80
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Freed by task 16619:
 kasan_save_track+0x3e/0x80
 kasan_save_free_info+0x40/0x50
 __kasan_slab_free+0x5c/0x80
 kfree+0x1c1/0x630
 platform_device_release+0x8b/0xc0
 device_release+0x9e/0x1d0
 kobject_put+0x222/0x550
 dwc2_pci_remove+0x5b/0xa0
 pci_device_remove+0x9d/0x240
 device_release_driver_internal+0x48b/0x880
 pci_stop_bus_device+0xf6/0x130
 pci_stop_and_remove_bus_device_locked+0x77/0xb0
 remove_store+0xe5/0x150
 kernfs_fop_write_iter+0x3a4/0x540
 vfs_write+0x612/0xba0
 ksys_write+0x150/0x270
 do_syscall_64+0x170/0xf80
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

The buggy address belongs to the object at ffff888109c3c300
 which belongs to the cache kmalloc-128 of size 128
The buggy address is located 56 bytes inside of
 freed 128-byte region [ffff888109c3c300, ffff888109c3c380)

The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x109c3c
flags: 0x17ff00000000000(node=0|zone=2|lastcpupid=0x7ff)
page_type: f5(slab)
raw: 017ff00000000000 ffff888100041a00 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 5038, tgid 5038 (udevd), ts 64018018006, free_ts 62522369481
 post_alloc_hook+0x231/0x280
 get_page_from_freelist+0x2503/0x25a0
 __alloc_frozen_pages_noprof+0x18d/0x380
 allocate_slab+0x77/0x660
 refill_objects+0x32e/0x3c0
 __pcs_replace_empty_main+0x2f9/0x5e0
 __kmalloc_cache_noprof+0x388/0x660
 kernfs_fop_open+0x7d9/0xce0
 do_dentry_open+0x816/0x1380
 vfs_open+0x3b/0x340
 path_openat+0x2e3b/0x3890
 do_file_open+0x23e/0x4a0
 do_sys_openat2+0x113/0x200
 __x64_sys_openat+0x138/0x170
 do_syscall_64+0x170/0xf80
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
page last free pid 5865 tgid 5864 stack trace:
 free_unref_folios+0xf29/0x1740
 folios_put_refs+0x795/0x8d0
 free_pages_and_swap_cache+0x2e6/0x590
 tlb_flush_mmu+0x6d3/0xa30
 unmap_page_range+0x3c70/0x48f0
 unmap_vmas+0x462/0x680
 exit_mmap+0x292/0xa20
 __mmput+0x118/0x420
 exit_mm+0x160/0x210
 do_exit+0x6cd/0x2460
 do_group_exit+0x22d/0x2f0
 get_signal+0x121b/0x12c0
 arch_do_signal_or_restart+0xbb/0x810
 exit_to_user_mode_loop+0xa3/0x5e0
 do_syscall_64+0x357/0xf80
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Memory state around the buggy address:
 ffff888109c3c200: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff888109c3c280: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff888109c3c300: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                        ^
 ffff888109c3c380: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff888109c3c400: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
==================================================================
