================================================================== BUG: KASAN: slab-use-after-free in __release_resource+0x276/0x2c0 kernel/resource.c:221 Read of size 8 at addr ffff88803c726c38 by task syz.0.2099/13806 CPU: 1 UID: 0 PID: 13806 Comm: syz.0.2099 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:0x7f3f52b9de99 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:00007f3f53b12028 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 RAX: ffffffffffffffda RBX: 00007f3f52e25fa0 RCX: 00007f3f52b9de99 RDX: 0000000000000001 RSI: 0000200000000140 RDI: 0000000000000003 RBP: 00007f3f52c33eaf R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007f3f52e26038 R14: 00007f3f52e25fa0 R15: 00007ffd1aadf238 Allocated by task 13828: 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 13806: 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 bus_remove_device+0x2bc/0x560 drivers/base/bus.c:664 device_del+0x376/0x9b0 drivers/base/core.c:3961 pci_destroy_dev drivers/pci/remove.c:46 [inline] pci_remove_bus_device+0x162/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 The buggy address belongs to the object at ffff88803c726c00 which belongs to the cache kmalloc-128 of size 128 The buggy address is located 56 bytes inside of freed 128-byte region [ffff88803c726c00, ffff88803c726c80) The buggy address belongs to the physical page: page: refcount:0 mapcount:0 mapping:0000000000000000 index:0xffff88803c726700 pfn:0x3c726 flags: 0xfff00000000200(workingset|node=0|zone=1|lastcpupid=0x7ff) page_type: f5(slab) raw: 00fff00000000200 ffff88801bc42a00 ffffea0000f70e10 ffffea00008c2510 raw: ffff88803c726700 000000080010000f 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 5736, tgid 5736 (syz-executor), ts 71152819596, free_ts 71152479976 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 __do_sys_clone+0xd9/0x120 kernel/fork.c:2889 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 page last free pid 5736 tgid 5736 stack trace: reset_page_owner include/linux/page_owner.h:25 [inline] __free_pages_prepare mm/page_alloc.c:1406 [inline] free_pages_prepare+0x586/0xd80 mm/page_alloc.c:1451 __free_contig_range_common+0x14f/0x250 mm/page_alloc.c:6897 __free_contig_range mm/page_alloc.c:6942 [inline] free_pages_bulk+0x12a/0x200 mm/page_alloc.c:5257 vm_area_free_pages+0xad/0x2b0 mm/vmalloc.c:3439 vfree mm/vmalloc.c:3488 [inline] vfree+0x107/0x750 mm/vmalloc.c:3462 copy_entries_to_user net/ipv6/netfilter/ip6_tables.c:880 [inline] get_entries net/ipv6/netfilter/ip6_tables.c:1037 [inline] do_ip6t_get_ctl+0xa0b/0xc30 net/ipv6/netfilter/ip6_tables.c:1678 nf_getsockopt+0x7c/0xe0 net/netfilter/nf_sockopt.c:116 ipv6_getsockopt+0x207/0x2a0 net/ipv6/ipv6_sockglue.c:1464 tcp_getsockopt+0xa1/0x110 net/ipv4/tcp.c:4864 do_sock_getsockopt+0x50a/0x6e0 net/socket.c:2474 __sys_getsockopt+0x148/0x260 net/socket.c:2505 __do_sys_getsockopt net/socket.c:2512 [inline] __se_sys_getsockopt net/socket.c:2509 [inline] __x64_sys_getsockopt+0xbd/0x160 net/socket.c:2509 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 Memory state around the buggy address: ffff88803c726b00: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88803c726b80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff88803c726c00: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88803c726c80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff88803c726d00: 00 00 00 00 00 00 00 00 00 00 00 00 00 fc fc fc ==================================================================