================================================================== BUG: KASAN: slab-use-after-free in nfc_llcp_remove_local net/nfc/llcp_core.c:304 [inline] BUG: KASAN: slab-use-after-free in nfc_llcp_unregister_device+0x25e/0x2c0 net/nfc/llcp_core.c:1646 Read of size 8 at addr ffff88807a9c3000 by task syz-executor.3/12294 CPU: 1 PID: 12294 Comm: syz-executor.3 Not tainted 6.5.0-rc5-syzkaller-00029-g14f9643dc90a #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/26/2023 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xd9/0x1b0 lib/dump_stack.c:106 print_address_description mm/kasan/report.c:364 [inline] print_report+0xc4/0x620 mm/kasan/report.c:475 kasan_report+0xda/0x110 mm/kasan/report.c:588 nfc_llcp_remove_local net/nfc/llcp_core.c:304 [inline] nfc_llcp_unregister_device+0x25e/0x2c0 net/nfc/llcp_core.c:1646 nfc_unregister_device+0x194/0x330 net/nfc/core.c:1179 virtual_ncidev_close+0x51/0xa0 drivers/nfc/virtual_ncidev.c:163 __fput+0x3f7/0xac0 fs/file_table.c:384 task_work_run+0x14d/0x240 kernel/task_work.c:179 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline] exit_to_user_mode_loop kernel/entry/common.c:171 [inline] exit_to_user_mode_prepare+0x210/0x240 kernel/entry/common.c:204 __syscall_exit_to_user_mode_work kernel/entry/common.c:286 [inline] syscall_exit_to_user_mode+0x1d/0x50 kernel/entry/common.c:297 do_syscall_64+0x44/0xb0 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7f3f0727b9da Code: 48 3d 00 f0 ff ff 77 48 c3 0f 1f 80 00 00 00 00 48 83 ec 18 89 7c 24 0c e8 03 7f 02 00 8b 7c 24 0c 89 c2 b8 03 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 36 89 d7 89 44 24 0c e8 63 7f 02 00 8b 44 24 RSP: 002b:00007ffdc4f0e810 EFLAGS: 00000293 ORIG_RAX: 0000000000000003 RAX: 0000000000000000 RBX: 0000000000000004 RCX: 00007f3f0727b9da RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000003 RBP: 00007f3f0739d980 R08: 0000001b2eb20000 R09: 00000000000000a4 R10: 0000000081710cc1 R11: 0000000000000293 R12: 00000000000eca85 R13: ffffffffffffffff R14: 00007f3f06e00000 R15: 00000000000ec744 Allocated by task 12303: kasan_save_stack+0x33/0x50 mm/kasan/common.c:45 kasan_set_track+0x25/0x30 mm/kasan/common.c:52 ____kasan_kmalloc mm/kasan/common.c:374 [inline] __kasan_kmalloc+0xa3/0xb0 mm/kasan/common.c:383 kmalloc include/linux/slab.h:582 [inline] kzalloc include/linux/slab.h:703 [inline] nfc_llcp_register_device+0x47/0x9d0 net/nfc/llcp_core.c:1602 nfc_register_device+0x6d/0x3c0 net/nfc/core.c:1124 nci_register_device+0x7f4/0xb80 net/nfc/nci/core.c:1257 virtual_ncidev_open+0x147/0x220 drivers/nfc/virtual_ncidev.c:148 misc_open+0x3da/0x4c0 drivers/char/misc.c:165 chrdev_open+0x277/0x700 fs/char_dev.c:414 do_dentry_open+0x88b/0x1780 fs/open.c:914 do_open fs/namei.c:3636 [inline] path_openat+0x19af/0x29c0 fs/namei.c:3793 do_filp_open+0x1de/0x430 fs/namei.c:3820 do_sys_openat2+0x176/0x1e0 fs/open.c:1407 do_sys_open fs/open.c:1422 [inline] __do_sys_openat fs/open.c:1438 [inline] __se_sys_openat fs/open.c:1433 [inline] __x64_sys_openat+0x175/0x210 fs/open.c:1433 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd Freed by task 12289: kasan_save_stack+0x33/0x50 mm/kasan/common.c:45 kasan_set_track+0x25/0x30 mm/kasan/common.c:52 kasan_save_free_info+0x28/0x40 mm/kasan/generic.c:522 ____kasan_slab_free mm/kasan/common.c:236 [inline] ____kasan_slab_free+0x13f/0x190 mm/kasan/common.c:200 kasan_slab_free include/linux/kasan.h:162 [inline] __cache_free mm/slab.c:3370 [inline] __do_kmem_cache_free mm/slab.c:3557 [inline] __kmem_cache_free+0xcc/0x2d0 mm/slab.c:3564 local_release net/nfc/llcp_core.c:175 [inline] kref_put include/linux/kref.h:65 [inline] nfc_llcp_local_put.part.0+0x88/0xb0 net/nfc/llcp_core.c:183 nfc_llcp_local_put net/nfc/llcp_core.c:180 [inline] nfc_llcp_unregister_device+0x1db/0x2c0 net/nfc/llcp_core.c:1655 nfc_unregister_device+0x194/0x330 net/nfc/core.c:1179 virtual_ncidev_close+0x51/0xa0 drivers/nfc/virtual_ncidev.c:163 __fput+0x3f7/0xac0 fs/file_table.c:384 task_work_run+0x14d/0x240 kernel/task_work.c:179 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline] exit_to_user_mode_loop kernel/entry/common.c:171 [inline] exit_to_user_mode_prepare+0x210/0x240 kernel/entry/common.c:204 __syscall_exit_to_user_mode_work kernel/entry/common.c:286 [inline] syscall_exit_to_user_mode+0x1d/0x50 kernel/entry/common.c:297 do_syscall_64+0x44/0xb0 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x63/0xcd Last potentially related work creation: kasan_save_stack+0x33/0x50 mm/kasan/common.c:45 __kasan_record_aux_stack+0x78/0x80 mm/kasan/generic.c:492 insert_work+0x4a/0x330 kernel/workqueue.c:1556 __queue_work+0x5f5/0x1040 kernel/workqueue.c:1717 queue_work_on+0xed/0x110 kernel/workqueue.c:1747 queue_work include/linux/workqueue.h:506 [inline] schedule_work include/linux/workqueue.h:567 [inline] rfkill_register+0x67f/0xb00 net/rfkill/core.c:1090 nfc_register_device+0x11f/0x3c0 net/nfc/core.c:1132 nci_register_device+0x7f4/0xb80 net/nfc/nci/core.c:1257 virtual_ncidev_open+0x147/0x220 drivers/nfc/virtual_ncidev.c:148 misc_open+0x3da/0x4c0 drivers/char/misc.c:165 chrdev_open+0x277/0x700 fs/char_dev.c:414 do_dentry_open+0x88b/0x1780 fs/open.c:914 do_open fs/namei.c:3636 [inline] path_openat+0x19af/0x29c0 fs/namei.c:3793 do_filp_open+0x1de/0x430 fs/namei.c:3820 do_sys_openat2+0x176/0x1e0 fs/open.c:1407 do_sys_open fs/open.c:1422 [inline] __do_sys_openat fs/open.c:1438 [inline] __se_sys_openat fs/open.c:1433 [inline] __x64_sys_openat+0x175/0x210 fs/open.c:1433 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd Second to last potentially related work creation: kasan_save_stack+0x33/0x50 mm/kasan/common.c:45 __kasan_record_aux_stack+0x78/0x80 mm/kasan/generic.c:492 insert_work+0x4a/0x330 kernel/workqueue.c:1556 __queue_work+0x5f5/0x1040 kernel/workqueue.c:1717 queue_work_on+0xed/0x110 kernel/workqueue.c:1747 queue_work include/linux/workqueue.h:506 [inline] schedule_work include/linux/workqueue.h:567 [inline] rfkill_register+0x67f/0xb00 net/rfkill/core.c:1090 nfc_register_device+0x11f/0x3c0 net/nfc/core.c:1132 nci_register_device+0x7f4/0xb80 net/nfc/nci/core.c:1257 virtual_ncidev_open+0x147/0x220 drivers/nfc/virtual_ncidev.c:148 misc_open+0x3da/0x4c0 drivers/char/misc.c:165 chrdev_open+0x277/0x700 fs/char_dev.c:414 do_dentry_open+0x88b/0x1780 fs/open.c:914 do_open fs/namei.c:3636 [inline] path_openat+0x19af/0x29c0 fs/namei.c:3793 do_filp_open+0x1de/0x430 fs/namei.c:3820 do_sys_openat2+0x176/0x1e0 fs/open.c:1407 do_sys_open fs/open.c:1422 [inline] __do_sys_openat fs/open.c:1438 [inline] __se_sys_openat fs/open.c:1433 [inline] __x64_sys_openat+0x175/0x210 fs/open.c:1433 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd The buggy address belongs to the object at ffff88807a9c3000 which belongs to the cache kmalloc-2k of size 2048 The buggy address is located 0 bytes inside of freed 2048-byte region [ffff88807a9c3000, ffff88807a9c3800) The buggy address belongs to the physical page: page:ffffea0001ea70c0 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x7a9c3 flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff) page_type: 0x1() raw: 00fff00000000200 ffff888012840800 ffffea0001da6590 ffffea00008fc210 raw: 0000000000000000 ffff88807a9c3000 0000000100000001 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 0x3420c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_COMP|__GFP_HARDWALL|__GFP_THISNODE), pid 4457, tgid 4457 (klogd), ts 398553263953, free_ts 397628038320 set_page_owner include/linux/page_owner.h:31 [inline] post_alloc_hook+0x2d2/0x350 mm/page_alloc.c:1570 prep_new_page mm/page_alloc.c:1577 [inline] get_page_from_freelist+0x10a9/0x31e0 mm/page_alloc.c:3221 __alloc_pages+0x1d0/0x4a0 mm/page_alloc.c:4477 __alloc_pages_node include/linux/gfp.h:237 [inline] kmem_getpages mm/slab.c:1356 [inline] cache_grow_begin+0x99/0x3a0 mm/slab.c:2550 cache_alloc_refill+0x294/0x3a0 mm/slab.c:2923 ____cache_alloc mm/slab.c:2999 [inline] ____cache_alloc mm/slab.c:2982 [inline] __do_cache_alloc mm/slab.c:3182 [inline] slab_alloc_node mm/slab.c:3230 [inline] __kmem_cache_alloc_node+0x3c9/0x470 mm/slab.c:3521 kmalloc_trace+0x25/0xe0 mm/slab_common.c:1076 kmalloc include/linux/slab.h:582 [inline] syslog_print+0xf9/0x5d0 kernel/printk/printk.c:1553 do_syslog+0x2d4/0x580 kernel/printk/printk.c:1732 __do_sys_syslog kernel/printk/printk.c:1824 [inline] __se_sys_syslog kernel/printk/printk.c:1822 [inline] __x64_sys_syslog+0x74/0xb0 kernel/printk/printk.c:1822 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1161 [inline] free_unref_page_prepare+0x508/0xb90 mm/page_alloc.c:2348 free_unref_page_list+0xe6/0xb30 mm/page_alloc.c:2489 release_pages+0x32a/0x14e0 mm/swap.c:1042 tlb_batch_pages_flush+0x9a/0x190 mm/mmu_gather.c:97 tlb_flush_mmu_free mm/mmu_gather.c:292 [inline] tlb_flush_mmu mm/mmu_gather.c:299 [inline] tlb_finish_mmu+0x14b/0x7e0 mm/mmu_gather.c:391 exit_mmap+0x2db/0x960 mm/mmap.c:3215 __mmput+0x12a/0x4d0 kernel/fork.c:1348 mmput+0x62/0x70 kernel/fork.c:1370 exit_mm kernel/exit.c:567 [inline] do_exit+0x9b4/0x2a20 kernel/exit.c:861 do_group_exit+0xd4/0x2a0 kernel/exit.c:1024 get_signal+0x23ea/0x2770 kernel/signal.c:2881 arch_do_signal_or_restart+0x89/0x5f0 arch/x86/kernel/signal.c:308 exit_to_user_mode_loop kernel/entry/common.c:168 [inline] exit_to_user_mode_prepare+0x11f/0x240 kernel/entry/common.c:204 __syscall_exit_to_user_mode_work kernel/entry/common.c:286 [inline] syscall_exit_to_user_mode+0x1d/0x50 kernel/entry/common.c:297 do_syscall_64+0x44/0xb0 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x63/0xcd Memory state around the buggy address: ffff88807a9c2f00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff88807a9c2f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >ffff88807a9c3000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88807a9c3080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88807a9c3100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================