================================================================== BUG: KASAN: slab-use-after-free in software_node_notify_remove+0xa0/0xcc drivers/base/swnode.c:1106 Read at addr f1f0000004747ec8 by task syz.0.18/3498 Pointer tag: [f1], memory tag: [fe] CPU: 1 UID: 0 PID: 3498 Comm: syz.0.18 Not tainted 6.15.0-rc1-syzkaller-00065-g3b07108ada81 #0 PREEMPT Hardware name: linux,dummy-virt (DT) Call trace: show_stack+0x18/0x24 arch/arm64/kernel/stacktrace.c:466 (C) __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0x78/0x90 lib/dump_stack.c:120 print_address_description mm/kasan/report.c:408 [inline] print_report+0x108/0x630 mm/kasan/report.c:521 kasan_report+0x88/0xac mm/kasan/report.c:634 report_tag_fault arch/arm64/mm/fault.c:332 [inline] do_tag_recovery arch/arm64/mm/fault.c:344 [inline] __do_kernel_fault+0x170/0x1c8 arch/arm64/mm/fault.c:386 do_bad_area arch/arm64/mm/fault.c:486 [inline] do_tag_check_fault+0x78/0x8c arch/arm64/mm/fault.c:843 do_mem_abort+0x44/0x94 arch/arm64/mm/fault.c:919 el1_abort+0x40/0x60 arch/arm64/kernel/entry-common.c:432 el1h_64_sync_handler+ el1h_64_sync_handler+0xa4/0x120 arch/arm64/kernel/entry-common.c:510 el1h_64_sync+0x6c/0x70 arch/arm64/kernel/entry.S:595 software_node_notify_remove+0xa0/0xcc drivers/base/swnode.c:1106 (P) device_platform_notify_remove drivers/base/core.c:2387 [inline] device_del+0x164/0x384 drivers/base/core.c:3858 device_unregister+0x18/0x34 drivers/base/core.c:3896 mock_dev_destroy drivers/iommu/iommufd/selftest.c:960 [inline] iommufd_selftest_destroy+0x48/0x58 drivers/iommu/iommufd/selftest.c:1850 iommufd_fops_release+0x9c/0x158 drivers/iommu/iommufd/main.c:261 __fput+0xcc/0x2dc fs/file_table.c:465 ____fput+0x14/0x20 fs/file_table.c:493 task_work_run+0x78/0xd4 kernel/task_work.c:227 resume_user_mode_work include/linux/resume_user_mode.h:50 [inline] do_notify_resume+0x134/0x164 arch/arm64/kernel/entry-common.c:151 exit_to_user_mode_prepare arch/arm64/kernel/entry-common.c:169 [inline] exit_to_user_mode arch/arm64/kernel/entry-common.c:178 [inline] el0_svc+0xc0/0xe0 arch/arm64/kernel/entry-common.c:745 el0t_64_sync_handler+0x10c/0x138 arch/arm64/kernel/entry-common.c:762 el0t_64_sync+0x1a4/0x1a8 arch/arm64/kernel/entry.S:600 Allocated by task 3501: kasan_save_stack+0x3c/0x64 mm/kasan/common.c:47 save_stack_info+0x40/0x158 mm/kasan/tags.c:106 kasan_save_alloc_info+0x14/0x20 mm/kasan/tags.c:142 poison_kmalloc_redzone mm/kasan/common.c:377 [inline] poison_kmalloc_redzone mm/kasan/common.c:350 [inline] __kasan_kmalloc+0xb4/0xb8 mm/kasan/common.c:394 kasan_kmalloc include/linux/kasan.h:260 [inline] __kmalloc_cache_noprof+0x174/0x390 mm/slub.c:4362 kmalloc_noprof include/linux/slab.h:905 [inline] kzalloc_noprof include/linux/slab.h:1039 [inline] swnode_register+0x38/0x1d8 drivers/base/swnode.c:790 fwnode_create_software_node+0xb4/0x190 drivers/base/swnode.c:949 device_create_managed_software_node+0x88/0x108 drivers/base/swnode.c:1060 mock_dev_create drivers/iommu/iommufd/selftest.c:942 [inline] iommufd_test_mock_domain drivers/iommu/iommufd/selftest.c:989 [inline] iommufd_test+0x24c/0x14d8 drivers/iommu/iommufd/selftest.c:1866 iommufd_fops_ioctl+0x234/0x2a4 drivers/iommu/iommufd/main.c:419 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:906 [inline] __se_sys_ioctl fs/ioctl.c:892 [inline] __arm64_sys_ioctl+0xb4/0xe8 fs/ioctl.c:892 __invoke_syscall arch/arm64/kernel/syscall.c:35 [inline] invoke_syscall+0x48/0x110 arch/arm64/kernel/syscall.c:49 el0_svc_common.constprop.0+0x40/0xe0 arch/arm64/kernel/syscall.c:132 do_el0_svc+0x1c/0x28 arch/arm64/kernel/syscall.c:151 el0_svc+0x30/0xe0 arch/arm64/kernel/entry-common.c:744 el0t_64_sync_handler+0x10c/0x138 arch/arm64/kernel/entry-common.c:762 el0t_64_sync+0x1a4/0x1a8 arch/arm64/kernel/entry.S:600 Freed by task 3498: kasan_save_stack+0x3c/0x64 mm/kasan/common.c:47 save_stack_info+0x40/0x158 mm/kasan/tags.c:106 kasan_save_free_info+0x18/0x24 mm/kasan/tags.c:147 poison_slab_object mm/kasan/common.c:247 [inline] __kasan_slab_free+0x74/0x8c mm/kasan/common.c:264 kasan_slab_free include/linux/kasan.h:233 [inline] slab_free_hook mm/slub.c:2389 [inline] slab_free mm/slub.c:4646 [inline] kfree+0xfc/0x30c mm/slub.c:4845 software_node_release+0xd0/0xf0 drivers/base/swnode.c:775 kobject_cleanup lib/kobject.c:689 [inline] kobject_release lib/kobject.c:720 [inline] kref_put include/linux/kref.h:65 [inline] kobject_put+0xa4/0x114 lib/kobject.c:737 software_node_notify_remove+0xa0/0xcc drivers/base/swnode.c:1106 device_platform_notify_remove drivers/base/core.c:2387 [inline] device_del+0x164/0x384 drivers/base/core.c:3858 device_unregister+0x18/0x34 drivers/base/core.c:3896 mock_dev_destroy drivers/iommu/iommufd/selftest.c:960 [inline] iommufd_selftest_destroy+0x48/0x58 drivers/iommu/iommufd/selftest.c:1850 iommufd_fops_release+0x9c/0x158 drivers/iommu/iommufd/main.c:261 __fput+0xcc/0x2dc fs/file_table.c:465 ____fput+0x14/0x20 fs/file_table.c:493 task_work_run+0x78/0xd4 kernel/task_work.c:227 resume_user_mode_work include/linux/resume_user_mode.h:50 [inline] do_notify_resume+0x134/0x164 arch/arm64/kernel/entry-common.c:151 exit_to_user_mode_prepare arch/arm64/kernel/entry-common.c:169 [inline] exit_to_user_mode arch/arm64/kernel/entry-common.c:178 [inline] el0_svc+0xc0/0xe0 arch/arm64/kernel/entry-common.c:745 el0t_64_sync_handler+0x10c/0x138 arch/arm64/kernel/entry-common.c:762 el0t_64_sync+0x1a4/0x1a8 arch/arm64/kernel/entry.S:600 The buggy address belongs to the object at fff0000004747e00 which belongs to the cache kmalloc-256 of size 256 The buggy address is located 200 bytes inside of 256-byte region [fff0000004747e00, fff0000004747f00) The buggy address belongs to the physical page: page: refcount:0 mapcount:0 mapping:0000000000000000 index:0xf1f0000004747e00 pfn:0x44747 flags: 0x1ffc00000000000(node=0|zone=0|lastcpupid=0x7ff|kasantag=0x0) page_type: f5(slab) raw: 01ffc00000000000 f5f0000003001800 dead000000000122 0000000000000000 raw: f1f0000004747e00 000000008010000f 00000000f5000000 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: fff0000004747c00: f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 f1 fe fe fff0000004747d00: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 fe fe >fff0000004747e00: fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe ^ fff0000004747f00: fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe fff0000004748000: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ================================================================== ------------[ cut here ]------------ refcount_t: underflow; use-after-free. WARNING: CPU: 1 PID: 3498 at lib/refcount.c:28 refcount_warn_saturate+0xf4/0x144 lib/refcount.c:28 Modules linked in: CPU: 1 UID: 0 PID: 3498 Comm: syz.0.18 Tainted: G B 6.15.0-rc1-syzkaller-00065-g3b07108ada81 #0 PREEMPT Tainted: [B]=BAD_PAGE Hardware name: linux,dummy-virt (DT) pstate: 61402009 (nZCv daif +PAN -UAO -TCO +DIT -SSBS BTYPE=--) pc : refcount_warn_saturate+0xf4/0x144 lib/refcount.c:28 lr : refcount_warn_saturate+0xf4/0x144 lib/refcount.c:28 sp : ffff8000895d3c50 x29: ffff8000895d3c50 x28: faf00000098cb6c0 x27: 0000000000000000 x26: 0000000000000000 x25: 0000000000000000 x24: 0000000000000000 x23: 0000000000000000 x22: 0000000000400040 x21: ffff800082a5ac88 x20: fbf0000009885000 x19: f1f0000004747e00 x18: 00000000ffffffff x17: 0000000000000000 x16: 0000000000000000 x15: ffff8000895d3680 x14: 00000000ffffffea x13: ffff8000895d3a08 x12: ffff8000829a0b88 x11: 0000000000000001 x10: 0000000000000001 x9 : 000000000002ffe8 x8 : c0000000ffffdfff x7 : ffff8000828f0b00 x6 : 00000000000affa8 x5 : ffff8000829a0b30 x4 : 0000000000000000 x3 : 0000000000000000 x2 : 0000000000000000 x1 : 0000000000000000 x0 : faf00000098cb6c0 Call trace: refcount_warn_saturate+0xf4/0x144 lib/refcount.c:28 (P) __refcount_sub_and_test include/linux/refcount.h:400 [inline] __refcount_dec_and_test include/linux/refcount.h:432 [inline] refcount_dec_and_test include/linux/refcount.h:450 [inline] kref_put include/linux/kref.h:64 [inline] kobject_put+0x110/0x114 lib/kobject.c:737 software_node_notify_remove+0xbc/0xcc drivers/base/swnode.c:1110 device_platform_notify_remove drivers/base/core.c:2387 [inline] device_del+0x164/0x384 drivers/base/core.c:3858 device_unregister+0x18/0x34 drivers/base/core.c:3896 mock_dev_destroy drivers/iommu/iommufd/selftest.c:960 [inline] iommufd_selftest_destroy+0x48/0x58 drivers/iommu/iommufd/selftest.c:1850 iommufd_fops_release+0x9c/0x158 drivers/iommu/iommufd/main.c:261 __fput+0xcc/0x2dc fs/file_table.c:465 ____fput+0x14/0x20 fs/file_table.c:493 task_work_run+0x78/0xd4 kernel/task_work.c:227 resume_user_mode_work include/linux/resume_user_mode.h:50 [inline] do_notify_resume+0x134/0x164 arch/arm64/kernel/entry-common.c:151 exit_to_user_mode_prepare arch/arm64/kernel/entry-common.c:169 [inline] exit_to_user_mode arch/arm64/kernel/entry-common.c:178 [inline] el0_svc+0xc0/0xe0 arch/arm64/kernel/entry-common.c:745 el0t_64_sync_handler+0x10c/0x138 arch/arm64/kernel/entry-common.c:762 el0t_64_sync+0x1a4/0x1a8 arch/arm64/kernel/entry.S:600 ---[ end trace 0000000000000000 ]---