================================================================== BUG: KASAN: use-after-free in __lock_acquire+0x3d86/0x54a0 kernel/locking/lockdep.c:4885 Read of size 8 at addr ffff88807c0090a0 by task kworker/1:3/6912 CPU: 1 PID: 6912 Comm: kworker/1:3 Not tainted 5.14.0-rc7-next-20210825-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: events l2cap_chan_timeout Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106 print_address_description.constprop.0.cold+0x6c/0x309 mm/kasan/report.c:256 __kasan_report mm/kasan/report.c:442 [inline] kasan_report.cold+0x83/0xdf mm/kasan/report.c:459 __lock_acquire+0x3d86/0x54a0 kernel/locking/lockdep.c:4885 lock_acquire kernel/locking/lockdep.c:5625 [inline] lock_acquire+0x1ab/0x510 kernel/locking/lockdep.c:5590 __raw_spin_lock_bh include/linux/spinlock_api_smp.h:135 [inline] _raw_spin_lock_bh+0x2f/0x40 kernel/locking/spinlock.c:178 spin_lock_bh include/linux/spinlock.h:373 [inline] lock_sock_nested+0x40/0x120 net/core/sock.c:3184 l2cap_sock_teardown_cb+0xa1/0x660 net/bluetooth/l2cap_sock.c:1528 l2cap_chan_del+0xbc/0xa80 net/bluetooth/l2cap_core.c:622 l2cap_chan_close+0x1b9/0xaf0 net/bluetooth/l2cap_core.c:825 l2cap_chan_timeout+0x17e/0x2f0 net/bluetooth/l2cap_core.c:436 process_one_work+0x9b2/0x1690 kernel/workqueue.c:2297 worker_thread+0x658/0x11f0 kernel/workqueue.c:2444 kthread+0x3e5/0x4d0 kernel/kthread.c:319 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295 Allocated by task 6957: kasan_save_stack+0x1b/0x40 mm/kasan/common.c:38 kasan_set_track mm/kasan/common.c:46 [inline] set_alloc_info mm/kasan/common.c:434 [inline] ____kasan_kmalloc mm/kasan/common.c:513 [inline] ____kasan_kmalloc mm/kasan/common.c:472 [inline] __kasan_kmalloc+0xa4/0xd0 mm/kasan/common.c:522 kmalloc include/linux/slab.h:599 [inline] sk_prot_alloc+0x110/0x290 net/core/sock.c:1822 sk_alloc+0x32/0xbc0 net/core/sock.c:1875 l2cap_sock_alloc.constprop.0+0x31/0x230 net/bluetooth/l2cap_sock.c:1813 l2cap_sock_create+0x123/0x1f0 net/bluetooth/l2cap_sock.c:1859 bt_sock_create+0x17c/0x340 net/bluetooth/af_bluetooth.c:130 __sock_create+0x353/0x790 net/socket.c:1461 sock_create net/socket.c:1512 [inline] __sys_socket+0xef/0x200 net/socket.c:1554 __do_sys_socket net/socket.c:1563 [inline] __se_sys_socket net/socket.c:1561 [inline] __x64_sys_socket+0x6f/0xb0 net/socket.c:1561 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae Freed by task 6957: kasan_save_stack+0x1b/0x40 mm/kasan/common.c:38 kasan_set_track+0x1c/0x30 mm/kasan/common.c:46 kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:360 ____kasan_slab_free mm/kasan/common.c:366 [inline] ____kasan_slab_free mm/kasan/common.c:328 [inline] __kasan_slab_free+0xff/0x130 mm/kasan/common.c:374 kasan_slab_free include/linux/kasan.h:230 [inline] slab_free_hook mm/slub.c:1681 [inline] slab_free_freelist_hook+0x81/0x190 mm/slub.c:1706 slab_free mm/slub.c:3459 [inline] kfree+0xe4/0x530 mm/slub.c:4519 sk_prot_free net/core/sock.c:1858 [inline] __sk_destruct+0x6a8/0x900 net/core/sock.c:1943 sk_destruct+0xbd/0xe0 net/core/sock.c:1958 __sk_free+0xef/0x3d0 net/core/sock.c:1969 sk_free+0x78/0xa0 net/core/sock.c:1980 sock_put include/net/sock.h:1815 [inline] l2cap_sock_kill+0x203/0x240 net/bluetooth/l2cap_sock.c:1227 l2cap_sock_release+0x184/0x200 net/bluetooth/l2cap_sock.c:1397 __sock_release+0xcd/0x280 net/socket.c:649 sock_close+0x18/0x20 net/socket.c:1311 __fput+0x288/0x9f0 fs/file_table.c:280 task_work_run+0xdd/0x1a0 kernel/task_work.c:164 get_signal+0x1b35/0x2160 kernel/signal.c:2619 arch_do_signal_or_restart+0x2a9/0x1c40 arch/x86/kernel/signal.c:865 handle_signal_work kernel/entry/common.c:148 [inline] exit_to_user_mode_loop kernel/entry/common.c:172 [inline] exit_to_user_mode_prepare+0x17d/0x290 kernel/entry/common.c:209 __syscall_exit_to_user_mode_work kernel/entry/common.c:291 [inline] syscall_exit_to_user_mode+0x19/0x60 kernel/entry/common.c:302 do_syscall_64+0x42/0xb0 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x44/0xae Last potentially related work creation: kasan_save_stack+0x1b/0x40 mm/kasan/common.c:38 kasan_record_aux_stack+0xe9/0x110 mm/kasan/generic.c:348 __call_rcu kernel/rcu/tree.c:2985 [inline] call_rcu+0xb1/0x740 kernel/rcu/tree.c:3065 netlink_release+0xdd4/0x1dd0 net/netlink/af_netlink.c:812 __sock_release+0xcd/0x280 net/socket.c:649 sock_close+0x18/0x20 net/socket.c:1311 __fput+0x288/0x9f0 fs/file_table.c:280 task_work_run+0xdd/0x1a0 kernel/task_work.c:164 exit_task_work include/linux/task_work.h:32 [inline] do_exit+0xbae/0x2a30 kernel/exit.c:825 do_group_exit+0x125/0x310 kernel/exit.c:922 __do_sys_exit_group kernel/exit.c:933 [inline] __se_sys_exit_group kernel/exit.c:931 [inline] __x64_sys_exit_group+0x3a/0x50 kernel/exit.c:931 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae Second to last potentially related work creation: kasan_save_stack+0x1b/0x40 mm/kasan/common.c:38 kasan_record_aux_stack+0xe9/0x110 mm/kasan/generic.c:348 insert_work+0x48/0x370 kernel/workqueue.c:1353 __queue_work+0x5ca/0xf30 kernel/workqueue.c:1519 queue_work_on+0xee/0x110 kernel/workqueue.c:1546 kref_put include/linux/kref.h:65 [inline] tty_kref_put drivers/tty/tty_io.c:1581 [inline] release_tty+0x4e9/0x610 drivers/tty/tty_io.c:1618 tty_release_struct+0xb4/0xe0 drivers/tty/tty_io.c:1717 tty_release+0xc70/0x1200 drivers/tty/tty_io.c:1878 __fput+0x288/0x9f0 fs/file_table.c:280 task_work_run+0xdd/0x1a0 kernel/task_work.c:164 tracehook_notify_resume include/linux/tracehook.h:189 [inline] exit_to_user_mode_loop kernel/entry/common.c:175 [inline] exit_to_user_mode_prepare+0x27e/0x290 kernel/entry/common.c:209 __syscall_exit_to_user_mode_work kernel/entry/common.c:291 [inline] syscall_exit_to_user_mode+0x19/0x60 kernel/entry/common.c:302 do_syscall_64+0x42/0xb0 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x44/0xae The buggy address belongs to the object at ffff88807c009000 which belongs to the cache kmalloc-2k of size 2048 The buggy address is located 160 bytes inside of 2048-byte region [ffff88807c009000, ffff88807c009800) The buggy address belongs to the page: page:ffffea0001f00200 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff88807c00f000 pfn:0x7c008 head:ffffea0001f00200 order:3 compound_mapcount:0 compound_pincount:0 flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000010200 ffffea0000497608 ffffea0001d9b008 ffff888010c42000 raw: ffff88807c00f000 0000000000080007 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 1, ts 16734088307, free_ts 13766727995 prep_new_page mm/page_alloc.c:2424 [inline] get_page_from_freelist+0xa72/0x2f80 mm/page_alloc.c:4151 __alloc_pages+0x1b2/0x500 mm/page_alloc.c:5373 alloc_pages+0x1a7/0x300 mm/mempolicy.c:2188 alloc_slab_page mm/slub.c:1744 [inline] allocate_slab mm/slub.c:1881 [inline] new_slab+0x319/0x490 mm/slub.c:1944 ___slab_alloc+0x9b6/0x1100 mm/slub.c:2970 __slab_alloc.constprop.0+0x4d/0xa0 mm/slub.c:3057 slab_alloc_node mm/slub.c:3148 [inline] slab_alloc mm/slub.c:3190 [inline] kmem_cache_alloc_trace+0x302/0x3c0 mm/slub.c:3207 kmalloc include/linux/slab.h:594 [inline] kzalloc include/linux/slab.h:731 [inline] alloc_tty_struct+0x95/0x920 drivers/tty/tty_io.c:3122 tty_init_dev.part.0+0x20/0x610 drivers/tty/tty_io.c:1422 tty_init_dev include/linux/err.h:36 [inline] tty_open_by_driver drivers/tty/tty_io.c:2098 [inline] tty_open+0xb16/0x1000 drivers/tty/tty_io.c:2146 chrdev_open+0x266/0x770 fs/char_dev.c:414 do_dentry_open+0x4c8/0x11d0 fs/open.c:822 do_open fs/namei.c:3426 [inline] path_openat+0x1c9a/0x2740 fs/namei.c:3559 do_filp_open+0x1aa/0x400 fs/namei.c:3586 do_sys_openat2+0x16d/0x4d0 fs/open.c:1200 do_sys_open fs/open.c:1216 [inline] __do_sys_open fs/open.c:1224 [inline] __se_sys_open fs/open.c:1220 [inline] __x64_sys_open+0x119/0x1c0 fs/open.c:1220 page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1338 [inline] free_pcp_prepare+0x373/0x860 mm/page_alloc.c:1389 free_unref_page_prepare mm/page_alloc.c:3315 [inline] free_unref_page+0x19/0x690 mm/page_alloc.c:3394 free_contig_range+0xa8/0xf0 mm/page_alloc.c:9264 destroy_args+0xa8/0x646 mm/debug_vm_pgtable.c:1016 debug_vm_pgtable+0x295b/0x29ed mm/debug_vm_pgtable.c:1329 do_one_initcall+0x103/0x650 init/main.c:1292 do_initcall_level init/main.c:1367 [inline] do_initcalls init/main.c:1383 [inline] do_basic_setup init/main.c:1402 [inline] kernel_init_freeable+0x6b1/0x73a init/main.c:1604 kernel_init+0x1a/0x1d0 init/main.c:1496 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295 Memory state around the buggy address: ffff88807c008f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff88807c009000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff88807c009080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88807c009100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88807c009180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================