================================================================== BUG: KASAN: slab-use-after-free in bt_accept_dequeue+0x88/0x530 Read of size 8 at addr ffff0000cc7ab500 by task krfcommd/4027 CPU: 0 PID: 4027 Comm: krfcommd Not tainted 6.10.0-rc7-syzkaller-gc912bf709078 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/07/2024 Call trace: dump_backtrace+0x1b8/0x1e4 arch/arm64/kernel/stacktrace.c:317 show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:324 __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xe4/0x150 lib/dump_stack.c:114 print_address_description mm/kasan/report.c:377 [inline] print_report+0x198/0x538 mm/kasan/report.c:488 kasan_report+0xd8/0x138 mm/kasan/report.c:601 __asan_report_load8_noabort+0x20/0x2c mm/kasan/report_generic.c:381 bt_accept_dequeue+0x88/0x530 l2cap_sock_accept+0x20c/0x484 net/bluetooth/l2cap_sock.c:351 kernel_accept+0x1b8/0x474 net/socket.c:3595 rfcomm_accept_connection net/bluetooth/rfcomm/core.c:1971 [inline] rfcomm_process_sessions net/bluetooth/rfcomm/core.c:2030 [inline] rfcomm_run+0x870/0x5c24 net/bluetooth/rfcomm/core.c:2126 kthread+0x288/0x310 kernel/kthread.c:389 ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:860 Allocated by task 5860: kasan_save_stack mm/kasan/common.c:47 [inline] kasan_save_track+0x40/0x78 mm/kasan/common.c:68 kasan_save_alloc_info+0x40/0x50 mm/kasan/generic.c:565 poison_kmalloc_redzone mm/kasan/common.c:370 [inline] __kasan_kmalloc+0xac/0xc4 mm/kasan/common.c:387 kasan_kmalloc include/linux/kasan.h:211 [inline] __do_kmalloc_node mm/slub.c:4123 [inline] __kmalloc_noprof+0x2a0/0x494 mm/slub.c:4136 kmalloc_noprof include/linux/slab.h:664 [inline] sk_prot_alloc+0xc4/0x1f0 net/core/sock.c:2080 sk_alloc+0x44/0x3f0 net/core/sock.c:2133 bt_sock_alloc+0x4c/0x304 net/bluetooth/af_bluetooth.c:148 l2cap_sock_alloc net/bluetooth/l2cap_sock.c:1877 [inline] l2cap_sock_new_connection_cb+0xe4/0x284 net/bluetooth/l2cap_sock.c:1468 l2cap_connect net/bluetooth/l2cap_core.c:3980 [inline] l2cap_connect_req net/bluetooth/l2cap_core.c:4080 [inline] l2cap_bredr_sig_cmd net/bluetooth/l2cap_core.c:4772 [inline] l2cap_sig_channel net/bluetooth/l2cap_core.c:5543 [inline] l2cap_recv_frame+0x2314/0xc934 net/bluetooth/l2cap_core.c:6824 l2cap_recv_acldata+0x4a8/0x15dc net/bluetooth/l2cap_core.c:7513 hci_acldata_packet net/bluetooth/hci_core.c:3810 [inline] hci_rx_work+0x2b8/0xa78 net/bluetooth/hci_core.c:4047 process_one_work+0x79c/0x15b8 kernel/workqueue.c:3248 process_scheduled_works kernel/workqueue.c:3329 [inline] worker_thread+0x938/0xecc kernel/workqueue.c:3409 kthread+0x288/0x310 kernel/kthread.c:389 ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:860 Freed by task 6302: kasan_save_stack mm/kasan/common.c:47 [inline] kasan_save_track+0x40/0x78 mm/kasan/common.c:68 kasan_save_free_info+0x54/0x6c mm/kasan/generic.c:579 poison_slab_object+0x128/0x180 mm/kasan/common.c:240 __kasan_slab_free+0x3c/0x70 mm/kasan/common.c:256 kasan_slab_free include/linux/kasan.h:184 [inline] slab_free_hook mm/slub.c:2196 [inline] slab_free mm/slub.c:4438 [inline] kfree+0x154/0x3e0 mm/slub.c:4559 sk_prot_free net/core/sock.c:2116 [inline] __sk_destruct+0x4b8/0x74c net/core/sock.c:2208 sk_destruct net/core/sock.c:2223 [inline] __sk_free+0x388/0x4f4 net/core/sock.c:2234 sk_free+0x60/0xc8 net/core/sock.c:2245 sock_put include/net/sock.h:1879 [inline] l2cap_sock_kill+0x12c/0x234 net/bluetooth/l2cap_sock.c:1250 l2cap_sock_close_cb+0x4c/0x64 net/bluetooth/l2cap_sock.c:1557 l2cap_conn_del+0x2f4/0x50c net/bluetooth/l2cap_core.c:1787 l2cap_connect_cfm+0x110/0xe24 net/bluetooth/l2cap_core.c:7240 hci_connect_cfm include/net/bluetooth/hci_core.h:1970 [inline] hci_conn_failed+0x1b8/0x350 net/bluetooth/hci_conn.c:1266 hci_abort_conn_sync+0x500/0xbac net/bluetooth/hci_sync.c:5463 abort_conn_sync+0x224/0x25c net/bluetooth/hci_conn.c:2918 hci_cmd_sync_work+0x1cc/0x34c net/bluetooth/hci_sync.c:323 process_one_work+0x79c/0x15b8 kernel/workqueue.c:3248 process_scheduled_works kernel/workqueue.c:3329 [inline] worker_thread+0x938/0xecc kernel/workqueue.c:3409 kthread+0x288/0x310 kernel/kthread.c:389 ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:860 The buggy address belongs to the object at ffff0000cc7ab000 which belongs to the cache kmalloc-2k of size 2048 The buggy address is located 1280 bytes inside of freed 2048-byte region [ffff0000cc7ab000, ffff0000cc7ab800) The buggy address belongs to the physical page: page: refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff0000cc7ad000 pfn:0x10c7a8 head: order:3 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0 flags: 0x5ffc00000000240(workingset|head|node=0|zone=2|lastcpupid=0x7ff) page_type: 0xffffefff(slab) raw: 05ffc00000000240 ffff0000c0002000 fffffdffc3aaee10 fffffdffc3098010 raw: ffff0000cc7ad000 0000000000080002 00000001ffffefff 0000000000000000 head: 05ffc00000000240 ffff0000c0002000 fffffdffc3aaee10 fffffdffc3098010 head: ffff0000cc7ad000 0000000000080002 00000001ffffefff 0000000000000000 head: 05ffc00000000003 fffffdffc331ea01 ffffffffffffffff 0000000000000000 head: 0000000000000008 0000000000000000 00000000ffffffff 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff0000cc7ab400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff0000cc7ab480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff0000cc7ab500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff0000cc7ab580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff0000cc7ab600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ================================================================== ------------[ cut here ]------------ refcount_t: addition on 0; use-after-free. WARNING: CPU: 1 PID: 4027 at lib/refcount.c:25 refcount_warn_saturate+0x1a8/0x20c lib/refcount.c:25 Modules linked in: CPU: 1 PID: 4027 Comm: krfcommd Tainted: G B 6.10.0-rc7-syzkaller-gc912bf709078 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/07/2024 pstate: 60400005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) pc : refcount_warn_saturate+0x1a8/0x20c lib/refcount.c:25 lr : refcount_warn_saturate+0x1a8/0x20c lib/refcount.c:25 sp : ffff80009fcd71e0 x29: ffff80009fcd71e0 x28: dfff800000000000 x27: 0000000000000000 x26: ffff0000cc7ab080 x25: ffff0000cc7ab500 x24: 0000000000000000 x23: ffff0000cc7ab500 x22: ffff0000d24a2518 x21: 0000000000000002 x20: ffff0000cc7ab080 x19: ffff80009228a000 x18: 0000000000000008 x17: 0000000000000000 x16: ffff80008af00270 x15: ffff700011e2e664 x14: 1ffff00011e2e664 x13: 0000000000000004 x12: ffffffffffffffff x11: 0000000000000002 x10: 0000000000ff0100 x9 : 35e30596d67b0b00 x8 : 35e30596d67b0b00 x7 : 0000000000000001 x6 : 0000000000000001 x5 : ffff80009fcd6938 x4 : ffff80008f1e5220 x3 : ffff800080369018 x2 : 0000000000000000 x1 : 0000000100000000 x0 : 0000000000000000 Call trace: refcount_warn_saturate+0x1a8/0x20c lib/refcount.c:25 __refcount_inc include/linux/refcount.h:241 [inline] refcount_inc include/linux/refcount.h:258 [inline] sock_hold include/net/sock.h:774 [inline] bt_accept_dequeue+0x2b4/0x530 net/bluetooth/af_bluetooth.c:253 l2cap_sock_accept+0x20c/0x484 net/bluetooth/l2cap_sock.c:351 kernel_accept+0x1b8/0x474 net/socket.c:3595 rfcomm_accept_connection net/bluetooth/rfcomm/core.c:1971 [inline] rfcomm_process_sessions net/bluetooth/rfcomm/core.c:2030 [inline] rfcomm_run+0x870/0x5c24 net/bluetooth/rfcomm/core.c:2126 kthread+0x288/0x310 kernel/kthread.c:389 ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:860 irq event stamp: 74789 hardirqs last enabled at (74789): [] raw_spin_rq_unlock_irq kernel/sched/sched.h:1418 [inline] hardirqs last enabled at (74789): [] finish_lock_switch+0xbc/0x1e4 kernel/sched/core.c:5162 hardirqs last disabled at (74788): [] __schedule+0x2bc/0x24d8 kernel/sched/core.c:6633 softirqs last enabled at (71744): [] softirq_handle_end kernel/softirq.c:400 [inline] softirqs last enabled at (71744): [] handle_softirqs+0xa3c/0xbfc kernel/softirq.c:582 softirqs last disabled at (68917): [] __do_softirq+0x14/0x20 kernel/softirq.c:588 ---[ end trace 0000000000000000 ]--- ------------[ cut here ]------------ refcount_t: underflow; use-after-free. WARNING: CPU: 0 PID: 4027 at lib/refcount.c:28 refcount_warn_saturate+0x1c8/0x20c lib/refcount.c:28 Modules linked in: CPU: 0 PID: 4027 Comm: krfcommd Tainted: G B W 6.10.0-rc7-syzkaller-gc912bf709078 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/07/2024 pstate: 60400005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) pc : refcount_warn_saturate+0x1c8/0x20c lib/refcount.c:28 lr : refcount_warn_saturate+0x1c8/0x20c lib/refcount.c:28 sp : ffff80009fcd71e0 x29: ffff80009fcd71e0 x28: dfff800000000000 x27: ffff0000cc7ab510 x26: ffff0000cc7ab080 x25: 00000000c0000000 x24: 0000000000000000 x23: ffff0000cc7ab500 x22: ffff0000d24a2518 x21: 0000000000000003 x20: ffff0000cc7ab080 x19: ffff80009228a000 x18: 0000000000000008 x17: 0000000000000000 x16: ffff80008af00270 x15: ffff700011e2e664 x14: 1ffff00011e2e664 x13: 0000000000000004 x12: ffffffffffffffff x11: 0000000000000002 x10: 0000000000ff0100 x9 : 35e30596d67b0b00 x8 : 35e30596d67b0b00 x7 : 0000000000000001 x6 : 0000000000000001 x5 : ffff80009fcd6938 x4 : ffff80008f1e5220 x3 : ffff800080369018 x2 : 0000000000000000 x1 : 0000000100000000 x0 : 0000000000000000 Call trace: refcount_warn_saturate+0x1c8/0x20c lib/refcount.c:28 __refcount_sub_and_test include/linux/refcount.h:275 [inline] __refcount_dec_and_test include/linux/refcount.h:307 [inline] refcount_dec_and_test include/linux/refcount.h:325 [inline] sock_put include/net/sock.h:1878 [inline] bt_accept_dequeue+0x2dc/0x530 net/bluetooth/af_bluetooth.c:262 l2cap_sock_accept+0x20c/0x484 net/bluetooth/l2cap_sock.c:351 kernel_accept+0x1b8/0x474 net/socket.c:3595 rfcomm_accept_connection net/bluetooth/rfcomm/core.c:1971 [inline] rfcomm_process_sessions net/bluetooth/rfcomm/core.c:2030 [inline] rfcomm_run+0x870/0x5c24 net/bluetooth/rfcomm/core.c:2126 kthread+0x288/0x310 kernel/kthread.c:389 ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:860 irq event stamp: 74789 hardirqs last enabled at (74789): [] raw_spin_rq_unlock_irq kernel/sched/sched.h:1418 [inline] hardirqs last enabled at (74789): [] finish_lock_switch+0xbc/0x1e4 kernel/sched/core.c:5162 hardirqs last disabled at (74788): [] __schedule+0x2bc/0x24d8 kernel/sched/core.c:6633 softirqs last enabled at (71744): [] softirq_handle_end kernel/softirq.c:400 [inline] softirqs last enabled at (71744): [] handle_softirqs+0xa3c/0xbfc kernel/softirq.c:582 softirqs last disabled at (68917): [] __do_softirq+0x14/0x20 kernel/softirq.c:588 ---[ end trace 0000000000000000 ]---