================================================================== BUG: KASAN: use-after-free in nfc_llcp_find_local net/nfc/llcp_core.c:287 [inline] BUG: KASAN: use-after-free in nfc_llcp_unregister_device+0x65/0x110 net/nfc/llcp_core.c:1611 Read of size 8 at addr ffff888078a7c010 by task syz-executor.0/25521 CPU: 0 PID: 25521 Comm: syz-executor.0 Not tainted 6.2.0-rc8-syzkaller-00151-g925cf0457d7e #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/21/2023 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x1e7/0x2d0 lib/dump_stack.c:106 print_address_description mm/kasan/report.c:306 [inline] print_report+0x163/0x4f0 mm/kasan/report.c:417 kasan_report+0x13a/0x170 mm/kasan/report.c:517 nfc_llcp_find_local net/nfc/llcp_core.c:287 [inline] nfc_llcp_unregister_device+0x65/0x110 net/nfc/llcp_core.c:1611 nfc_unregister_device+0x167/0x2a0 net/nfc/core.c:1179 virtual_ncidev_close+0x59/0x90 drivers/nfc/virtual_ncidev.c:163 __fput+0x3b7/0x890 fs/file_table.c:320 task_work_run+0x24a/0x300 kernel/task_work.c:179 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline] exit_to_user_mode_loop+0xd9/0x100 kernel/entry/common.c:171 exit_to_user_mode_prepare+0xb1/0x140 kernel/entry/common.c:203 __syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline] syscall_exit_to_user_mode+0x64/0x2e0 kernel/entry/common.c:296 do_syscall_64+0x4d/0xc0 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7f5c5da3dfab Code: 0f 05 48 3d 00 f0 ff ff 77 45 c3 0f 1f 40 00 48 83 ec 18 89 7c 24 0c e8 63 fc ff ff 8b 7c 24 0c 41 89 c0 b8 03 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 35 44 89 c7 89 44 24 0c e8 a1 fc ff ff 8b 44 RSP: 002b:00007ffe9863ad40 EFLAGS: 00000293 ORIG_RAX: 0000000000000003 RAX: 0000000000000000 RBX: 0000000000000004 RCX: 00007f5c5da3dfab RDX: 0000000000000000 RSI: 0000000000000001 RDI: 0000000000000003 RBP: 00007f5c5dbad980 R08: 0000000000000000 R09: 00007f5c5d6000b8 R10: 0000000000000000 R11: 0000000000000293 R12: 00000000000e4e40 R13: 00007ffe9863ae40 R14: 00007f5c5dbac050 R15: 0000000000000032 Allocated by task 25528: kasan_save_stack mm/kasan/common.c:45 [inline] kasan_set_track+0x4f/0x80 mm/kasan/common.c:52 ____kasan_kmalloc mm/kasan/common.c:374 [inline] __kasan_kmalloc+0x9b/0xb0 mm/kasan/common.c:383 kmalloc include/linux/slab.h:580 [inline] kzalloc include/linux/slab.h:720 [inline] nfc_llcp_register_device+0x55/0x800 net/nfc/llcp_core.c:1567 nfc_register_device+0x71/0x320 net/nfc/core.c:1124 nci_register_device+0x7c2/0x900 net/nfc/nci/core.c:1257 virtual_ncidev_open+0x13c/0x1b0 drivers/nfc/virtual_ncidev.c:148 misc_open+0x308/0x380 drivers/char/misc.c:165 chrdev_open+0x54e/0x630 fs/char_dev.c:414 do_dentry_open+0x7f9/0x10f0 fs/open.c:882 do_open fs/namei.c:3557 [inline] path_openat+0x2606/0x2e40 fs/namei.c:3714 do_filp_open+0x234/0x490 fs/namei.c:3741 do_sys_openat2+0x13f/0x500 fs/open.c:1310 do_sys_open fs/open.c:1326 [inline] __do_sys_openat fs/open.c:1342 [inline] __se_sys_openat fs/open.c:1337 [inline] __x64_sys_openat+0x247/0x290 fs/open.c:1337 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd Freed by task 25526: kasan_save_stack mm/kasan/common.c:45 [inline] kasan_set_track+0x4f/0x80 mm/kasan/common.c:52 kasan_save_free_info+0x2b/0x40 mm/kasan/generic.c:523 ____kasan_slab_free+0xd6/0x120 mm/kasan/common.c:236 kasan_slab_free include/linux/kasan.h:177 [inline] slab_free_hook mm/slub.c:1781 [inline] slab_free_freelist_hook mm/slub.c:1807 [inline] slab_free mm/slub.c:3787 [inline] __kmem_cache_free+0x264/0x3c0 mm/slub.c:3800 local_release net/nfc/llcp_core.c:174 [inline] kref_put include/linux/kref.h:65 [inline] nfc_llcp_local_put+0x150/0x180 net/nfc/llcp_core.c:182 nfc_unregister_device+0x167/0x2a0 net/nfc/core.c:1179 virtual_ncidev_close+0x59/0x90 drivers/nfc/virtual_ncidev.c:163 __fput+0x3b7/0x890 fs/file_table.c:320 task_work_run+0x24a/0x300 kernel/task_work.c:179 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline] exit_to_user_mode_loop+0xd9/0x100 kernel/entry/common.c:171 exit_to_user_mode_prepare+0xb1/0x140 kernel/entry/common.c:203 __syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline] syscall_exit_to_user_mode+0x64/0x2e0 kernel/entry/common.c:296 do_syscall_64+0x4d/0xc0 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x63/0xcd Last potentially related work creation: kasan_save_stack+0x3f/0x60 mm/kasan/common.c:45 __kasan_record_aux_stack+0xb0/0xc0 mm/kasan/generic.c:493 insert_work+0x54/0x3d0 kernel/workqueue.c:1358 __queue_work+0xb59/0xfc0 kernel/workqueue.c:1517 queue_work_on+0x14f/0x250 kernel/workqueue.c:1545 queue_work include/linux/workqueue.h:503 [inline] schedule_work include/linux/workqueue.h:564 [inline] rfkill_register+0x729/0x880 net/rfkill/core.c:1090 nfc_register_device+0x148/0x320 net/nfc/core.c:1132 nci_register_device+0x7c2/0x900 net/nfc/nci/core.c:1257 virtual_ncidev_open+0x13c/0x1b0 drivers/nfc/virtual_ncidev.c:148 misc_open+0x308/0x380 drivers/char/misc.c:165 chrdev_open+0x54e/0x630 fs/char_dev.c:414 do_dentry_open+0x7f9/0x10f0 fs/open.c:882 do_open fs/namei.c:3557 [inline] path_openat+0x2606/0x2e40 fs/namei.c:3714 do_filp_open+0x234/0x490 fs/namei.c:3741 do_sys_openat2+0x13f/0x500 fs/open.c:1310 do_sys_open fs/open.c:1326 [inline] __do_sys_openat fs/open.c:1342 [inline] __se_sys_openat fs/open.c:1337 [inline] __x64_sys_openat+0x247/0x290 fs/open.c:1337 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd Second to last potentially related work creation: kasan_save_stack+0x3f/0x60 mm/kasan/common.c:45 __kasan_record_aux_stack+0xb0/0xc0 mm/kasan/generic.c:493 insert_work+0x54/0x3d0 kernel/workqueue.c:1358 __queue_work+0xb59/0xfc0 kernel/workqueue.c:1517 queue_work_on+0x14f/0x250 kernel/workqueue.c:1545 queue_work include/linux/workqueue.h:503 [inline] schedule_work include/linux/workqueue.h:564 [inline] rfkill_register+0x729/0x880 net/rfkill/core.c:1090 nfc_register_device+0x148/0x320 net/nfc/core.c:1132 nci_register_device+0x7c2/0x900 net/nfc/nci/core.c:1257 virtual_ncidev_open+0x13c/0x1b0 drivers/nfc/virtual_ncidev.c:148 misc_open+0x308/0x380 drivers/char/misc.c:165 chrdev_open+0x54e/0x630 fs/char_dev.c:414 do_dentry_open+0x7f9/0x10f0 fs/open.c:882 do_open fs/namei.c:3557 [inline] path_openat+0x2606/0x2e40 fs/namei.c:3714 do_filp_open+0x234/0x490 fs/namei.c:3741 do_sys_openat2+0x13f/0x500 fs/open.c:1310 do_sys_open fs/open.c:1326 [inline] __do_sys_openat fs/open.c:1342 [inline] __se_sys_openat fs/open.c:1337 [inline] __x64_sys_openat+0x247/0x290 fs/open.c:1337 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd The buggy address belongs to the object at ffff888078a7c000 which belongs to the cache kmalloc-2k of size 2048 The buggy address is located 16 bytes inside of 2048-byte region [ffff888078a7c000, ffff888078a7c800) The buggy address belongs to the physical page: page:ffffea0001e29e00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x78a78 head:ffffea0001e29e00 order:3 compound_mapcount:0 subpages_mapcount:0 compound_pincount:0 flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000010200 ffff888012442000 ffffea0001bf8400 dead000000000002 raw: 0000000000000000 0000000080080008 00000001ffffffff 0000000000000000 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 3, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 5122, tgid 5122 (syz-executor.3), ts 794046744384, free_ts 793951151058 prep_new_page mm/page_alloc.c:2531 [inline] get_page_from_freelist+0x3449/0x35c0 mm/page_alloc.c:4283 __alloc_pages+0x291/0x7e0 mm/page_alloc.c:5549 alloc_slab_page+0x6a/0x160 mm/slub.c:1851 allocate_slab mm/slub.c:1998 [inline] new_slab+0x84/0x2f0 mm/slub.c:2051 ___slab_alloc+0xa85/0x10a0 mm/slub.c:3193 __slab_alloc mm/slub.c:3292 [inline] __slab_alloc_node mm/slub.c:3345 [inline] slab_alloc_node mm/slub.c:3442 [inline] __kmem_cache_alloc_node+0x1b8/0x2a0 mm/slub.c:3491 __do_kmalloc_node mm/slab_common.c:967 [inline] __kmalloc+0xa2/0x1a0 mm/slab_common.c:981 kmalloc include/linux/slab.h:584 [inline] kzalloc include/linux/slab.h:720 [inline] rfkill_alloc+0x98/0x250 net/rfkill/core.c:984 wiphy_new_nm+0x112c/0x1900 net/wireless/core.c:527 ieee80211_alloc_hw_nm+0x3d4/0x1fc0 net/mac80211/main.c:668 mac80211_hwsim_new_radio+0x18e/0x4000 drivers/net/wireless/mac80211_hwsim.c:4257 hwsim_new_radio_nl+0xcb6/0x1270 drivers/net/wireless/mac80211_hwsim.c:5176 genl_family_rcv_msg_doit net/netlink/genetlink.c:968 [inline] genl_family_rcv_msg net/netlink/genetlink.c:1048 [inline] genl_rcv_msg+0xc33/0xf90 net/netlink/genetlink.c:1065 netlink_rcv_skb+0x1df/0x430 net/netlink/af_netlink.c:2574 genl_rcv+0x28/0x40 net/netlink/genetlink.c:1076 netlink_unicast_kernel net/netlink/af_netlink.c:1339 [inline] netlink_unicast+0x7c3/0x990 net/netlink/af_netlink.c:1365 page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1446 [inline] free_pcp_prepare mm/page_alloc.c:1496 [inline] free_unref_page_prepare+0xf3a/0x1040 mm/page_alloc.c:3369 free_unref_page+0x37/0x3f0 mm/page_alloc.c:3464 discard_slab mm/slub.c:2098 [inline] __unfreeze_partials+0x1b1/0x1f0 mm/slub.c:2637 put_cpu_partial+0x116/0x180 mm/slub.c:2713 qlist_free_all+0x22/0x60 mm/kasan/quarantine.c:187 kasan_quarantine_reduce+0x15a/0x170 mm/kasan/quarantine.c:294 __kasan_slab_alloc+0x23/0x80 mm/kasan/common.c:305 kasan_slab_alloc include/linux/kasan.h:201 [inline] slab_post_alloc_hook+0x68/0x390 mm/slab.h:761 slab_alloc_node mm/slub.c:3452 [inline] slab_alloc mm/slub.c:3460 [inline] __kmem_cache_alloc_lru mm/slub.c:3467 [inline] kmem_cache_alloc_lru+0x127/0x270 mm/slub.c:3483 alloc_inode_sb include/linux/fs.h:3119 [inline] sock_alloc_inode+0x28/0xc0 net/socket.c:304 alloc_inode fs/inode.c:259 [inline] new_inode_pseudo+0x65/0x1d0 fs/inode.c:1018 sock_alloc net/socket.c:627 [inline] __sock_create+0x123/0x860 net/socket.c:1482 sock_create net/socket.c:1569 [inline] __sys_socket_create net/socket.c:1606 [inline] __sys_socket+0x13a/0x3a0 net/socket.c:1639 __do_sys_socket net/socket.c:1652 [inline] __se_sys_socket net/socket.c:1650 [inline] __x64_sys_socket+0x7a/0x90 net/socket.c:1650 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd Memory state around the buggy address: ffff888078a7bf00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff888078a7bf80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff888078a7c000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff888078a7c080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888078a7c100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================