[syzbot] [bluetooth?] KASAN: slab-use-after-free Write in sco_conn_del

24 views
Skip to first unread message

syzbot

unread,
May 30, 2023, 3:30:07 AM5/30/23
to johan....@gmail.com, linux-b...@vger.kernel.org, linux-...@vger.kernel.org, luiz....@gmail.com, mar...@holtmann.org, net...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 878ecb0897f4 ipv6: Fix out-of-bounds access in ipv6_find_t..
git tree: net
console output: https://syzkaller.appspot.com/x/log.txt?x=17fc501e280000
kernel config: https://syzkaller.appspot.com/x/.config?x=9afc9b1b9107cdcd
dashboard link: https://syzkaller.appspot.com/bug?extid=6b9277cad941daf126a2
compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2

Unfortunately, I don't have any reproducer for this issue yet.

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/4f18f9fc3e6b/disk-878ecb08.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/fe938cc7c36c/vmlinux-878ecb08.xz
kernel image: https://storage.googleapis.com/syzbot-assets/2ae8899a247a/bzImage-878ecb08.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+6b9277...@syzkaller.appspotmail.com

==================================================================
BUG: KASAN: slab-use-after-free in instrument_atomic_read_write include/linux/instrumented.h:96 [inline]
BUG: KASAN: slab-use-after-free in atomic_fetch_add_relaxed include/linux/atomic/atomic-instrumented.h:116 [inline]
BUG: KASAN: slab-use-after-free in __refcount_add include/linux/refcount.h:193 [inline]
BUG: KASAN: slab-use-after-free in __refcount_inc include/linux/refcount.h:250 [inline]
BUG: KASAN: slab-use-after-free in refcount_inc include/linux/refcount.h:267 [inline]
BUG: KASAN: slab-use-after-free in sock_hold include/net/sock.h:775 [inline]
BUG: KASAN: slab-use-after-free in sco_conn_del+0xb9/0x2b0 net/bluetooth/sco.c:193
Write of size 4 at addr ffff88807c764080 by task syz-executor.0/21878

CPU: 1 PID: 21878 Comm: syz-executor.0 Not tainted 6.4.0-rc2-syzkaller-00209-g878ecb0897f4 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/16/2023
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0xd9/0x150 lib/dump_stack.c:106
print_address_description.constprop.0+0x2c/0x3c0 mm/kasan/report.c:351
print_report mm/kasan/report.c:462 [inline]
kasan_report+0x11c/0x130 mm/kasan/report.c:572
check_region_inline mm/kasan/generic.c:181 [inline]
kasan_check_range+0x141/0x190 mm/kasan/generic.c:187
instrument_atomic_read_write include/linux/instrumented.h:96 [inline]
atomic_fetch_add_relaxed include/linux/atomic/atomic-instrumented.h:116 [inline]
__refcount_add include/linux/refcount.h:193 [inline]
__refcount_inc include/linux/refcount.h:250 [inline]
refcount_inc include/linux/refcount.h:267 [inline]
sock_hold include/net/sock.h:775 [inline]
sco_conn_del+0xb9/0x2b0 net/bluetooth/sco.c:193
sco_disconn_cfm+0x75/0xb0 net/bluetooth/sco.c:1392
hci_disconn_cfm include/net/bluetooth/hci_core.h:1834 [inline]
hci_conn_hash_flush+0x114/0x230 net/bluetooth/hci_conn.c:2484
hci_dev_close_sync+0x5fb/0x1200 net/bluetooth/hci_sync.c:4941
hci_dev_do_close+0x31/0x70 net/bluetooth/hci_core.c:554
hci_unregister_dev+0x1ce/0x580 net/bluetooth/hci_core.c:2703
vhci_release+0x80/0xf0 drivers/bluetooth/hci_vhci.c:669
__fput+0x27c/0xa90 fs/file_table.c:321
task_work_run+0x16f/0x270 kernel/task_work.c:179
exit_task_work include/linux/task_work.h:38 [inline]
do_exit+0xad3/0x2960 kernel/exit.c:871
do_group_exit+0xd4/0x2a0 kernel/exit.c:1021
__do_sys_exit_group kernel/exit.c:1032 [inline]
__se_sys_exit_group kernel/exit.c:1030 [inline]
__x64_sys_exit_group+0x3e/0x50 kernel/exit.c:1030
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7fa76928c169
Code: Unable to access opcode bytes at 0x7fa76928c13f.
RSP: 002b:00007ffc9f4c2fb8 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7
RAX: ffffffffffffffda RBX: 0000000000000029 RCX: 00007fa76928c169
RDX: 00007fa76928d7ba RSI: 0000000000000000 RDI: 0000000000000007
RBP: 0000000000000007 R08: ff78736871746264 R09: 0000000000000029
R10: 00000000000003b8 R11: 0000000000000246 R12: 00007ffc9f4c3630
R13: 0000000000000003 R14: 00007ffc9f4c35cc R15: 00007fa769386660
</TASK>

Allocated by task 1079:
kasan_save_stack+0x22/0x40 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 mm/kasan/common.c:333 [inline]
__kasan_kmalloc+0xa2/0xb0 mm/kasan/common.c:383
kasan_kmalloc include/linux/kasan.h:196 [inline]
__do_kmalloc_node mm/slab_common.c:966 [inline]
__kmalloc_node_track_caller+0x5f/0x1a0 mm/slab_common.c:986
kmalloc_reserve+0xf0/0x270 net/core/skbuff.c:585
pskb_expand_head+0x237/0x1170 net/core/skbuff.c:2054
netlink_trim+0x1ea/0x240 net/netlink/af_netlink.c:1321
netlink_broadcast+0x63/0xd90 net/netlink/af_netlink.c:1517
nlmsg_multicast include/net/netlink.h:1083 [inline]
nlmsg_notify+0x93/0x280 net/netlink/af_netlink.c:2589
rtnl_notify net/core/rtnetlink.c:771 [inline]
rtmsg_ifinfo_send net/core/rtnetlink.c:4016 [inline]
rtmsg_ifinfo_event net/core/rtnetlink.c:4032 [inline]
rtmsg_ifinfo_event net/core/rtnetlink.c:4019 [inline]
rtmsg_ifinfo+0x16e/0x1a0 net/core/rtnetlink.c:4038
__dev_notify_flags+0x240/0x2d0 net/core/dev.c:8601
rtnl_configure_link+0x181/0x260 net/core/rtnetlink.c:3273
veth_newlink+0x446/0x9d0 drivers/net/veth.c:1909
rtnl_newlink_create net/core/rtnetlink.c:3443 [inline]
__rtnl_newlink+0x10c2/0x1840 net/core/rtnetlink.c:3660
rtnl_newlink+0x68/0xa0 net/core/rtnetlink.c:3673
rtnetlink_rcv_msg+0x43d/0xd50 net/core/rtnetlink.c:6395
netlink_rcv_skb+0x165/0x440 net/netlink/af_netlink.c:2546
netlink_unicast_kernel net/netlink/af_netlink.c:1339 [inline]
netlink_unicast+0x547/0x7f0 net/netlink/af_netlink.c:1365
netlink_sendmsg+0x925/0xe30 net/netlink/af_netlink.c:1913
sock_sendmsg_nosec net/socket.c:724 [inline]
sock_sendmsg+0xde/0x190 net/socket.c:747
__sys_sendto+0x23a/0x340 net/socket.c:2144
__do_sys_sendto net/socket.c:2156 [inline]
__se_sys_sendto net/socket.c:2152 [inline]
__x64_sys_sendto+0xe1/0x1b0 net/socket.c:2152
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd

Last potentially related work creation:
kasan_save_stack+0x22/0x40 mm/kasan/common.c:45
__kasan_record_aux_stack+0xbc/0xd0 mm/kasan/generic.c:491
__call_rcu_common.constprop.0+0x99/0x7e0 kernel/rcu/tree.c:2627
netlink_release+0xcde/0x1e40 net/netlink/af_netlink.c:828
__sock_release+0xcd/0x290 net/socket.c:653
sock_close+0x1c/0x20 net/socket.c:1397
__fput+0x27c/0xa90 fs/file_table.c:321
task_work_run+0x16f/0x270 kernel/task_work.c:179
exit_task_work include/linux/task_work.h:38 [inline]
do_exit+0xad3/0x2960 kernel/exit.c:871
do_group_exit+0xd4/0x2a0 kernel/exit.c:1021
get_signal+0x2315/0x25b0 kernel/signal.c:2874
arch_do_signal_or_restart+0x79/0x5c0 arch/x86/kernel/signal.c:306
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+0x46/0xb0 arch/x86/entry/common.c:86
entry_SYSCALL_64_after_hwframe+0x63/0xcd

Second to last potentially related work creation:
kasan_save_stack+0x22/0x40 mm/kasan/common.c:45
__kasan_record_aux_stack+0xbc/0xd0 mm/kasan/generic.c:491
__call_rcu_common.constprop.0+0x99/0x7e0 kernel/rcu/tree.c:2627
netlink_release+0xcde/0x1e40 net/netlink/af_netlink.c:828
__sock_release+0xcd/0x290 net/socket.c:653
sock_close+0x1c/0x20 net/socket.c:1397
__fput+0x27c/0xa90 fs/file_table.c:321
task_work_run+0x16f/0x270 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+0x46/0xb0 arch/x86/entry/common.c:86
entry_SYSCALL_64_after_hwframe+0x63/0xcd

The buggy address belongs to the object at ffff88807c764000
which belongs to the cache kmalloc-2k of size 2048
The buggy address is located 128 bytes inside of
freed 2048-byte region [ffff88807c764000, ffff88807c764800)

The buggy address belongs to the physical page:
page:ffffea0001f1d800 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff88807c767000 pfn:0x7c760
head:ffffea0001f1d800 order:3 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
page_type: 0xffffffff()
raw: 00fff00000010200 ffff888012442000 ffffea00012ef410 ffffea0000ab4010
raw: ffff88807c767000 0000000000080001 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 0xd2820(GFP_ATOMIC|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 5035, tgid 5035 (syz-executor.4), ts 168058722686, free_ts 163150710676
set_page_owner include/linux/page_owner.h:31 [inline]
post_alloc_hook+0x2db/0x350 mm/page_alloc.c:1731
prep_new_page mm/page_alloc.c:1738 [inline]
get_page_from_freelist+0xf41/0x2c00 mm/page_alloc.c:3502
__alloc_pages+0x1cb/0x4a0 mm/page_alloc.c:4768
alloc_pages+0x1aa/0x270 mm/mempolicy.c:2279
alloc_slab_page mm/slub.c:1851 [inline]
allocate_slab+0x25f/0x390 mm/slub.c:1998
new_slab mm/slub.c:2051 [inline]
___slab_alloc+0xa91/0x1400 mm/slub.c:3192
__slab_alloc.constprop.0+0x56/0xa0 mm/slub.c:3291
__slab_alloc_node mm/slub.c:3344 [inline]
slab_alloc_node mm/slub.c:3441 [inline]
__kmem_cache_alloc_node+0x136/0x320 mm/slub.c:3490
__do_kmalloc_node mm/slab_common.c:965 [inline]
__kmalloc_node_track_caller+0x4f/0x1a0 mm/slab_common.c:986
kmalloc_reserve+0xf0/0x270 net/core/skbuff.c:585
pskb_expand_head+0x237/0x1170 net/core/skbuff.c:2054
netlink_trim+0x1ea/0x240 net/netlink/af_netlink.c:1321
netlink_broadcast+0x63/0xd90 net/netlink/af_netlink.c:1517
nlmsg_multicast include/net/netlink.h:1083 [inline]
nlmsg_notify+0x93/0x280 net/netlink/af_netlink.c:2589
rtnl_notify net/core/rtnetlink.c:771 [inline]
rtmsg_ifinfo_send net/core/rtnetlink.c:4016 [inline]
rtmsg_ifinfo_event net/core/rtnetlink.c:4032 [inline]
rtmsg_ifinfo_event net/core/rtnetlink.c:4019 [inline]
rtmsg_ifinfo+0x16e/0x1a0 net/core/rtnetlink.c:4038
__dev_notify_flags+0x240/0x2d0 net/core/dev.c:8601
page last free stack trace:
reset_page_owner include/linux/page_owner.h:24 [inline]
free_pages_prepare mm/page_alloc.c:1302 [inline]
free_unref_page_prepare+0x62e/0xcb0 mm/page_alloc.c:2564
free_unref_page+0x33/0x370 mm/page_alloc.c:2659
__unfreeze_partials+0x17c/0x1a0 mm/slub.c:2636
qlink_free mm/kasan/quarantine.c:166 [inline]
qlist_free_all+0x6a/0x170 mm/kasan/quarantine.c:185
kasan_quarantine_reduce+0x195/0x220 mm/kasan/quarantine.c:292
__kasan_slab_alloc+0x63/0x90 mm/kasan/common.c:305
kasan_slab_alloc include/linux/kasan.h:186 [inline]
slab_post_alloc_hook mm/slab.h:711 [inline]
slab_alloc_node mm/slub.c:3451 [inline]
kmem_cache_alloc_node+0x185/0x3e0 mm/slub.c:3496
__alloc_skb+0x288/0x330 net/core/skbuff.c:644
alloc_skb_fclone include/linux/skbuff.h:1338 [inline]
tcp_stream_alloc_skb+0x3c/0x580 net/ipv4/tcp.c:866
tcp_sendmsg_locked+0xc47/0x2960 net/ipv4/tcp.c:1329
tcp_sendmsg+0x2f/0x50 net/ipv4/tcp.c:1487
inet_sendmsg+0x9d/0xe0 net/ipv4/af_inet.c:825
sock_sendmsg_nosec net/socket.c:724 [inline]
sock_sendmsg+0xde/0x190 net/socket.c:747
sock_write_iter+0x295/0x3d0 net/socket.c:1140
call_write_iter include/linux/fs.h:1868 [inline]
new_sync_write fs/read_write.c:491 [inline]
vfs_write+0x945/0xd50 fs/read_write.c:584
ksys_write+0x1ec/0x250 fs/read_write.c:637

Memory state around the buggy address:
ffff88807c763f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff88807c764000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88807c764080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88807c764100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88807c764180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the bug is already fixed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want to change bug's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the bug is a duplicate of another bug, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

syzbot

unread,
Sep 4, 2023, 3:57:52 AM9/4/23
to johan....@gmail.com, linux-b...@vger.kernel.org, linux-...@vger.kernel.org, luiz....@gmail.com, mar...@holtmann.org, net...@vger.kernel.org, syzkall...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: bd6c11bc43c4 Merge tag 'net-next-6.6' of git://git.kernel...
git tree: net-next
console+strace: https://syzkaller.appspot.com/x/log.txt?x=109d2577a80000
kernel config: https://syzkaller.appspot.com/x/.config?x=634e05b4025da9da
dashboard link: https://syzkaller.appspot.com/bug?extid=6b9277cad941daf126a2
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=10f06d04680000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=107fdcd0680000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/218c4f124314/disk-bd6c11bc.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/cedb31a3cb2e/vmlinux-bd6c11bc.xz
kernel image: https://storage.googleapis.com/syzbot-assets/4aad3c744f9d/bzImage-bd6c11bc.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+6b9277...@syzkaller.appspotmail.com

==================================================================
BUG: KASAN: slab-use-after-free in instrument_atomic_read_write include/linux/instrumented.h:96 [inline]
BUG: KASAN: slab-use-after-free in atomic_fetch_add_relaxed include/linux/atomic/atomic-instrumented.h:252 [inline]
BUG: KASAN: slab-use-after-free in __refcount_add include/linux/refcount.h:193 [inline]
BUG: KASAN: slab-use-after-free in __refcount_inc include/linux/refcount.h:250 [inline]
BUG: KASAN: slab-use-after-free in refcount_inc include/linux/refcount.h:267 [inline]
BUG: KASAN: slab-use-after-free in sock_hold include/net/sock.h:777 [inline]
BUG: KASAN: slab-use-after-free in sco_conn_del+0xb9/0x2d0 net/bluetooth/sco.c:195
Write of size 4 at addr ffff88802153c080 by task kworker/u5:1/4439

CPU: 0 PID: 4439 Comm: kworker/u5:1 Not tainted 6.5.0-syzkaller-03967-gbd6c11bc43c4 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/26/2023
Workqueue: hci0 hci_cmd_sync_work
Call Trace:
<TASK>
__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
check_region_inline mm/kasan/generic.c:181 [inline]
kasan_check_range+0xef/0x190 mm/kasan/generic.c:187
instrument_atomic_read_write include/linux/instrumented.h:96 [inline]
atomic_fetch_add_relaxed include/linux/atomic/atomic-instrumented.h:252 [inline]
__refcount_add include/linux/refcount.h:193 [inline]
__refcount_inc include/linux/refcount.h:250 [inline]
refcount_inc include/linux/refcount.h:267 [inline]
sock_hold include/net/sock.h:777 [inline]
sco_conn_del+0xb9/0x2d0 net/bluetooth/sco.c:195
sco_connect_cfm+0x205/0xb70 net/bluetooth/sco.c:1361
hci_connect_cfm include/net/bluetooth/hci_core.h:1935 [inline]
hci_conn_failed+0x196/0x320 net/bluetooth/hci_conn.c:1251
hci_conn_cleanup_child net/bluetooth/hci_conn.c:1065 [inline]
hci_conn_unlink+0x6f9/0x9b0 net/bluetooth/hci_conn.c:1092
hci_conn_del+0x59/0xd10 net/bluetooth/hci_conn.c:1118
hci_abort_conn_sync+0xacb/0xe20 net/bluetooth/hci_sync.c:5435
abort_conn_sync+0x18e/0x3a0 net/bluetooth/hci_conn.c:2894
hci_cmd_sync_work+0x1a4/0x3c0 net/bluetooth/hci_sync.c:306
process_one_work+0xaa2/0x16f0 kernel/workqueue.c:2600
worker_thread+0x687/0x1110 kernel/workqueue.c:2751
kthread+0x33a/0x430 kernel/kthread.c:389
ret_from_fork+0x2c/0x70 arch/x86/kernel/process.c:145
ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:304
</TASK>

Allocated by task 7402:
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+0xa2/0xb0 mm/kasan/common.c:383
kasan_kmalloc include/linux/kasan.h:196 [inline]
__do_kmalloc_node mm/slab_common.c:985 [inline]
__kmalloc+0x5d/0x100 mm/slab_common.c:998
kmalloc include/linux/slab.h:586 [inline]
sk_prot_alloc+0x1a4/0x2a0 net/core/sock.c:2089
sk_alloc+0x3a/0x7f0 net/core/sock.c:2142
bt_sock_alloc+0x3b/0x3e0 net/bluetooth/af_bluetooth.c:148
sco_sock_alloc net/bluetooth/sco.c:495 [inline]
sco_sock_create+0xe3/0x3b0 net/bluetooth/sco.c:526
bt_sock_create+0x180/0x340 net/bluetooth/af_bluetooth.c:132
__sock_create+0x334/0x810 net/socket.c:1549
sock_create net/socket.c:1600 [inline]
__sys_socket_create net/socket.c:1637 [inline]
__sys_socket+0x14c/0x260 net/socket.c:1688
__do_sys_socket net/socket.c:1702 [inline]
__se_sys_socket net/socket.c:1700 [inline]
__x64_sys_socket+0x72/0xb0 net/socket.c:1700
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 7403:
kasan_save_stack+0x33/0x50 mm/kasan/common.c:45
kasan_set_track+0x25/0x30 mm/kasan/common.c:52
kasan_save_free_info+0x2b/0x40 mm/kasan/generic.c:522
____kasan_slab_free mm/kasan/common.c:236 [inline]
____kasan_slab_free+0x15e/0x1b0 mm/kasan/common.c:200
kasan_slab_free include/linux/kasan.h:162 [inline]
slab_free_hook mm/slub.c:1792 [inline]
slab_free_freelist_hook+0x10b/0x1e0 mm/slub.c:1818
slab_free mm/slub.c:3801 [inline]
__kmem_cache_free+0xb8/0x2f0 mm/slub.c:3814
sk_prot_free net/core/sock.c:2125 [inline]
__sk_destruct+0x5fc/0x770 net/core/sock.c:2217
sk_destruct+0xc2/0xf0 net/core/sock.c:2232
__sk_free+0xc4/0x3a0 net/core/sock.c:2243
sk_free+0x7c/0xa0 net/core/sock.c:2254
sock_put include/net/sock.h:1983 [inline]
sco_sock_kill net/bluetooth/sco.c:426 [inline]
sco_sock_kill+0x19d/0x1c0 net/bluetooth/sco.c:416
sco_sock_release+0x154/0x2c0 net/bluetooth/sco.c:1256
__sock_release+0xae/0x260 net/socket.c:657
sock_close+0x1c/0x20 net/socket.c:1399
__fput+0x3f7/0xa70 fs/file_table.c:384
task_work_run+0x14d/0x240 kernel/task_work.c:179
ptrace_notify+0x10c/0x130 kernel/signal.c:2376
ptrace_report_syscall include/linux/ptrace.h:411 [inline]
ptrace_report_syscall_exit include/linux/ptrace.h:473 [inline]
syscall_exit_work kernel/entry/common.c:251 [inline]
syscall_exit_to_user_mode_prepare+0x120/0x220 kernel/entry/common.c:278
__syscall_exit_to_user_mode_work kernel/entry/common.c:283 [inline]
syscall_exit_to_user_mode+0xd/0x60 kernel/entry/common.c:296
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+0xbc/0xd0 mm/kasan/generic.c:492
__call_rcu_common.constprop.0+0x9a/0x790 kernel/rcu/tree.c:2653
netlink_release+0xec0/0x20b0 net/netlink/af_netlink.c:831
__sock_release+0xae/0x260 net/socket.c:657
sock_close+0x1c/0x20 net/socket.c:1399
__fput+0x3f7/0xa70 fs/file_table.c:384
__fput_sync+0x47/0x50 fs/file_table.c:465
__do_sys_close fs/open.c:1572 [inline]
__se_sys_close fs/open.c:1557 [inline]
__x64_sys_close+0x87/0xf0 fs/open.c:1557
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 ffff88802153c000
which belongs to the cache kmalloc-2k of size 2048
The buggy address is located 128 bytes inside of
freed 2048-byte region [ffff88802153c000, ffff88802153c800)

The buggy address belongs to the physical page:
page:ffffea0000854e00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x21538
head:ffffea0000854e00 order:3 entire_mapcount:0 nr_pages_mapped:0 pincount:0
anon flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
page_type: 0xffffffff()
raw: 00fff00000010200 ffff888012842000 0000000000000000 dead000000000001
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 41, tgid 41 (kworker/u4:2), ts 12651061992, free_ts 0
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+0x1a9/0x270 mm/mempolicy.c:2298
alloc_slab_page mm/slub.c:1862 [inline]
allocate_slab+0x24e/0x380 mm/slub.c:2009
new_slab mm/slub.c:2062 [inline]
___slab_alloc+0x8bc/0x1570 mm/slub.c:3215
__slab_alloc.constprop.0+0x56/0xa0 mm/slub.c:3314
__slab_alloc_node mm/slub.c:3367 [inline]
slab_alloc_node mm/slub.c:3460 [inline]
__kmem_cache_alloc_node+0x137/0x350 mm/slub.c:3509
kmalloc_trace+0x25/0xe0 mm/slab_common.c:1076
kmalloc include/linux/slab.h:582 [inline]
kzalloc include/linux/slab.h:703 [inline]
bsg_register_queue+0x52/0x410 block/bsg.c:195
scsi_sysfs_add_sdev+0x295/0x540 drivers/scsi/scsi_sysfs.c:1436
scsi_sysfs_add_devices drivers/scsi/scsi_scan.c:1815 [inline]
scsi_finish_async_scan drivers/scsi/scsi_scan.c:1900 [inline]
do_scan_async+0x21d/0x540 drivers/scsi/scsi_scan.c:1943
async_run_entry_fn+0x9c/0x530 kernel/async.c:127
process_one_work+0xaa2/0x16f0 kernel/workqueue.c:2600
worker_thread+0x687/0x1110 kernel/workqueue.c:2751
kthread+0x33a/0x430 kernel/kthread.c:389
page_owner free stack trace missing

Memory state around the buggy address:
ffff88802153bf80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff88802153c000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88802153c080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88802153c100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88802153c180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================


---
If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.

Hillf Danton

unread,
Sep 4, 2023, 7:16:49 AM9/4/23
to syzbot, linux-...@vger.kernel.org, syzkall...@googlegroups.com
On Mon, 04 Sep 2023 00:57:50 -0700
> HEAD commit: bd6c11bc43c4 Merge tag 'net-next-6.6' of git://git.kernel...
> git tree: net-next
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=107fdcd0680000

Reset sco conn->sk upon killing sock.

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git bd6c11bc43c4

--- x/net/bluetooth/sco.c
+++ y/net/bluetooth/sco.c
@@ -415,6 +415,8 @@ static void sco_sock_cleanup_listen(stru
*/
static void sco_sock_kill(struct sock *sk)
{
+ struct sco_conn *conn;
+
if (!sock_flag(sk, SOCK_ZAPPED) || sk->sk_socket)
return;

@@ -423,6 +425,14 @@ static void sco_sock_kill(struct sock *s
/* Kill poor orphan */
bt_sock_unlink(&sco_sk_list, sk);
sock_set_flag(sk, SOCK_DEAD);
+
+ conn = sco_pi(sk)->conn;
+ if (conn) {
+ sco_conn_lock(conn);
+ conn->sk = NULL;
+ sco_pi(sk)->conn = NULL;
+ sco_conn_unlock(conn);
+ }
sock_put(sk);
}

--

syzbot

unread,
Sep 4, 2023, 8:31:24 AM9/4/23
to hda...@sina.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
KASAN: slab-use-after-free Write in sco_conn_del

Bluetooth: hci0: command 0x0409 tx timeout
==================================================================
BUG: KASAN: slab-use-after-free in instrument_atomic_read_write include/linux/instrumented.h:96 [inline]
BUG: KASAN: slab-use-after-free in atomic_fetch_add_relaxed include/linux/atomic/atomic-instrumented.h:252 [inline]
BUG: KASAN: slab-use-after-free in __refcount_add include/linux/refcount.h:193 [inline]
BUG: KASAN: slab-use-after-free in __refcount_inc include/linux/refcount.h:250 [inline]
BUG: KASAN: slab-use-after-free in refcount_inc include/linux/refcount.h:267 [inline]
BUG: KASAN: slab-use-after-free in sock_hold include/net/sock.h:777 [inline]
BUG: KASAN: slab-use-after-free in sco_conn_del+0xb9/0x2d0 net/bluetooth/sco.c:195
Write of size 4 at addr ffff88807c81d080 by task kworker/u5:0/49

CPU: 1 PID: 49 Comm: kworker/u5:0 Not tainted 6.5.0-syzkaller-03967-gbd6c11bc43c4-dirty #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/26/2023
Workqueue: hci0 hci_cmd_sync_work
Call Trace:
<TASK>
__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
check_region_inline mm/kasan/generic.c:181 [inline]
kasan_check_range+0xef/0x190 mm/kasan/generic.c:187
instrument_atomic_read_write include/linux/instrumented.h:96 [inline]
atomic_fetch_add_relaxed include/linux/atomic/atomic-instrumented.h:252 [inline]
__refcount_add include/linux/refcount.h:193 [inline]
__refcount_inc include/linux/refcount.h:250 [inline]
refcount_inc include/linux/refcount.h:267 [inline]
sock_hold include/net/sock.h:777 [inline]
sco_conn_del+0xb9/0x2d0 net/bluetooth/sco.c:195
sco_connect_cfm+0x205/0xb70 net/bluetooth/sco.c:1371
hci_connect_cfm include/net/bluetooth/hci_core.h:1935 [inline]
hci_conn_failed+0x196/0x320 net/bluetooth/hci_conn.c:1251
hci_conn_cleanup_child net/bluetooth/hci_conn.c:1065 [inline]
hci_conn_unlink+0x6f9/0x9b0 net/bluetooth/hci_conn.c:1092
hci_conn_del+0x59/0xd10 net/bluetooth/hci_conn.c:1118
hci_abort_conn_sync+0xacb/0xe20 net/bluetooth/hci_sync.c:5435
abort_conn_sync+0x18e/0x3a0 net/bluetooth/hci_conn.c:2894
hci_cmd_sync_work+0x1a4/0x3c0 net/bluetooth/hci_sync.c:306
process_one_work+0xaa2/0x16f0 kernel/workqueue.c:2600
worker_thread+0x687/0x1110 kernel/workqueue.c:2751
kthread+0x33a/0x430 kernel/kthread.c:389
ret_from_fork+0x2c/0x70 arch/x86/kernel/process.c:145
ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:304
</TASK>

Allocated by task 5692:
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+0xa2/0xb0 mm/kasan/common.c:383
kasan_kmalloc include/linux/kasan.h:196 [inline]
__do_kmalloc_node mm/slab_common.c:985 [inline]
__kmalloc+0x5d/0x100 mm/slab_common.c:998
kmalloc include/linux/slab.h:586 [inline]
sk_prot_alloc+0x1a4/0x2a0 net/core/sock.c:2089
sk_alloc+0x3a/0x7f0 net/core/sock.c:2142
bt_sock_alloc+0x3b/0x3e0 net/bluetooth/af_bluetooth.c:148
sco_sock_alloc net/bluetooth/sco.c:505 [inline]
sco_sock_create+0xe3/0x3b0 net/bluetooth/sco.c:536
bt_sock_create+0x180/0x340 net/bluetooth/af_bluetooth.c:132
__sock_create+0x334/0x810 net/socket.c:1549
sock_create net/socket.c:1600 [inline]
__sys_socket_create net/socket.c:1637 [inline]
__sys_socket+0x14c/0x260 net/socket.c:1688
__do_sys_socket net/socket.c:1702 [inline]
__se_sys_socket net/socket.c:1700 [inline]
__x64_sys_socket+0x72/0xb0 net/socket.c:1700
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 5693:
kasan_save_stack+0x33/0x50 mm/kasan/common.c:45
kasan_set_track+0x25/0x30 mm/kasan/common.c:52
kasan_save_free_info+0x2b/0x40 mm/kasan/generic.c:522
____kasan_slab_free mm/kasan/common.c:236 [inline]
____kasan_slab_free+0x15e/0x1b0 mm/kasan/common.c:200
kasan_slab_free include/linux/kasan.h:162 [inline]
slab_free_hook mm/slub.c:1792 [inline]
slab_free_freelist_hook+0x10b/0x1e0 mm/slub.c:1818
slab_free mm/slub.c:3801 [inline]
__kmem_cache_free+0xb8/0x2f0 mm/slub.c:3814
sk_prot_free net/core/sock.c:2125 [inline]
__sk_destruct+0x5fc/0x770 net/core/sock.c:2217
sk_destruct+0xc2/0xf0 net/core/sock.c:2232
__sk_free+0xc4/0x3a0 net/core/sock.c:2243
sk_free+0x7c/0xa0 net/core/sock.c:2254
sock_put include/net/sock.h:1983 [inline]
sco_sock_kill net/bluetooth/sco.c:436 [inline]
sco_sock_kill+0x23a/0x290 net/bluetooth/sco.c:416
sco_sock_release+0x154/0x2c0 net/bluetooth/sco.c:1266
__sock_release+0xae/0x260 net/socket.c:657
sock_close+0x1c/0x20 net/socket.c:1399
__fput+0x3f7/0xa70 fs/file_table.c:384
task_work_run+0x14d/0x240 kernel/task_work.c:179
get_signal+0x1075/0x2770 kernel/signal.c:2657
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:285 [inline]
syscall_exit_to_user_mode+0x1d/0x60 kernel/entry/common.c:296
do_syscall_64+0x44/0xb0 arch/x86/entry/common.c:86
entry_SYSCALL_64_after_hwframe+0x63/0xcd

The buggy address belongs to the object at ffff88807c81d000
which belongs to the cache kmalloc-2k of size 2048
The buggy address is located 128 bytes inside of
freed 2048-byte region [ffff88807c81d000, ffff88807c81d800)

The buggy address belongs to the physical page:
page:ffffea0001f20600 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x7c818
head:ffffea0001f20600 order:3 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
page_type: 0xffffffff()
raw: 00fff00000010200 ffff888012842000 dead000000000122 0000000000000000
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 0x1d20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 22, tgid 22 (kworker/1:0), ts 90926873259, free_ts 90560277193
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+0x1a9/0x270 mm/mempolicy.c:2298
alloc_slab_page mm/slub.c:1862 [inline]
allocate_slab+0x24e/0x380 mm/slub.c:2009
new_slab mm/slub.c:2062 [inline]
___slab_alloc+0x8bc/0x1570 mm/slub.c:3215
__slab_alloc.constprop.0+0x56/0xa0 mm/slub.c:3314
__slab_alloc_node mm/slub.c:3367 [inline]
slab_alloc_node mm/slub.c:3460 [inline]
__kmem_cache_alloc_node+0x137/0x350 mm/slub.c:3509
__do_kmalloc_node mm/slab_common.c:984 [inline]
__kmalloc_node_track_caller+0x4d/0x100 mm/slab_common.c:1005
kmalloc_reserve+0xef/0x270 net/core/skbuff.c:575
__alloc_skb+0x12b/0x330 net/core/skbuff.c:644
alloc_skb include/linux/skbuff.h:1286 [inline]
alloc_skb_with_frags+0xe4/0x710 net/core/skbuff.c:6299
sock_alloc_send_pskb+0x7c8/0x950 net/core/sock.c:2794
sock_alloc_send_skb include/net/sock.h:1879 [inline]
mld_newpack.isra.0+0x1ee/0x790 net/ipv6/mcast.c:1746
add_grhead+0x295/0x340 net/ipv6/mcast.c:1849
add_grec+0x10bb/0x1680 net/ipv6/mcast.c:1987
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+0x33/0x3b0 mm/page_alloc.c:2443
__unfreeze_partials+0x21d/0x240 mm/slub.c:2647
qlink_free mm/kasan/quarantine.c:166 [inline]
qlist_free_all+0x6a/0x170 mm/kasan/quarantine.c:185
kasan_quarantine_reduce+0x18b/0x1d0 mm/kasan/quarantine.c:292
__kasan_slab_alloc+0x65/0x90 mm/kasan/common.c:305
kasan_slab_alloc include/linux/kasan.h:186 [inline]
slab_post_alloc_hook mm/slab.h:762 [inline]
slab_alloc_node mm/slub.c:3470 [inline]
slab_alloc mm/slub.c:3478 [inline]
__kmem_cache_alloc_lru mm/slub.c:3485 [inline]
kmem_cache_alloc+0x172/0x3b0 mm/slub.c:3494
getname_flags.part.0+0x50/0x4d0 fs/namei.c:140
getname_flags+0x9c/0xf0 include/linux/audit.h:319
vfs_fstatat+0x77/0xb0 fs/stat.c:314
__do_sys_newfstatat+0x98/0x110 fs/stat.c:485
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

Memory state around the buggy address:
ffff88807c81cf80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff88807c81d000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88807c81d080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88807c81d100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88807c81d180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================


Tested on:

commit: bd6c11bc Merge tag 'net-next-6.6' of git://git.kernel...
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git
console output: https://syzkaller.appspot.com/x/log.txt?x=128e6447a80000
kernel config: https://syzkaller.appspot.com/x/.config?x=634e05b4025da9da
dashboard link: https://syzkaller.appspot.com/bug?extid=6b9277cad941daf126a2
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=14e42f38680000

Hillf Danton

unread,
Sep 5, 2023, 6:49:51 AM9/5/23
to syzbot, linux-...@vger.kernel.org, syzkall...@googlegroups.com
On Mon, 04 Sep 2023 00:57:50 -0700
> HEAD commit: bd6c11bc43c4 Merge tag 'net-next-6.6' of git://git.kernel...
> git tree: net-next
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=107fdcd0680000

Delete sco channel upon closing sock.

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git bd6c11bc43c4

--- x/net/bluetooth/sco.c
+++ y/net/bluetooth/sco.c
@@ -434,31 +434,9 @@ static void __sco_sock_close(struct sock
case BT_LISTEN:
sco_sock_cleanup_listen(sk);
break;
-
- case BT_CONNECTED:
- case BT_CONFIG:
- if (sco_pi(sk)->conn->hcon) {
- sk->sk_state = BT_DISCONN;
- sco_sock_set_timer(sk, SCO_DISCONN_TIMEOUT);
- sco_conn_lock(sco_pi(sk)->conn);
- hci_conn_drop(sco_pi(sk)->conn->hcon);
- sco_pi(sk)->conn->hcon = NULL;
- sco_conn_unlock(sco_pi(sk)->conn);
- } else
- sco_chan_del(sk, ECONNRESET);
- break;
-
- case BT_CONNECT2:
- case BT_CONNECT:
- case BT_DISCONN:
- sco_chan_del(sk, ECONNRESET);
- break;
-
- default:
- sock_set_flag(sk, SOCK_ZAPPED);
- break;
}

+ sco_chan_del(sk, ECONNRESET);
}

/* Must be called on unlocked socket. */
--

syzbot

unread,
Sep 5, 2023, 7:26:29 AM9/5/23
to hda...@sina.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
KASAN: slab-use-after-free Write in sco_conn_del

Bluetooth: hci0: command 0x0405 tx timeout
Bluetooth: hci0: command 0x0405 tx timeout
Bluetooth: hci0: command 0x0405 tx timeout
==================================================================
BUG: KASAN: slab-use-after-free in instrument_atomic_read_write include/linux/instrumented.h:96 [inline]
BUG: KASAN: slab-use-after-free in atomic_fetch_add_relaxed include/linux/atomic/atomic-instrumented.h:252 [inline]
BUG: KASAN: slab-use-after-free in __refcount_add include/linux/refcount.h:193 [inline]
BUG: KASAN: slab-use-after-free in __refcount_inc include/linux/refcount.h:250 [inline]
BUG: KASAN: slab-use-after-free in refcount_inc include/linux/refcount.h:267 [inline]
BUG: KASAN: slab-use-after-free in sock_hold include/net/sock.h:777 [inline]
BUG: KASAN: slab-use-after-free in sco_conn_del+0xb9/0x2d0 net/bluetooth/sco.c:195
Write of size 4 at addr ffff888068c19080 by task kworker/u5:2/5037

CPU: 0 PID: 5037 Comm: kworker/u5:2 Not tainted 6.5.0-syzkaller-03967-gbd6c11bc43c4-dirty #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/26/2023
Workqueue: hci0 hci_cmd_sync_work
Call Trace:
<TASK>
__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
check_region_inline mm/kasan/generic.c:181 [inline]
kasan_check_range+0xef/0x190 mm/kasan/generic.c:187
instrument_atomic_read_write include/linux/instrumented.h:96 [inline]
atomic_fetch_add_relaxed include/linux/atomic/atomic-instrumented.h:252 [inline]
__refcount_add include/linux/refcount.h:193 [inline]
__refcount_inc include/linux/refcount.h:250 [inline]
refcount_inc include/linux/refcount.h:267 [inline]
sock_hold include/net/sock.h:777 [inline]
sco_conn_del+0xb9/0x2d0 net/bluetooth/sco.c:195
sco_connect_cfm+0x205/0xb70 net/bluetooth/sco.c:1339
hci_connect_cfm include/net/bluetooth/hci_core.h:1935 [inline]
hci_conn_failed+0x196/0x320 net/bluetooth/hci_conn.c:1251
hci_conn_cleanup_child net/bluetooth/hci_conn.c:1065 [inline]
hci_conn_unlink+0x6f9/0x9b0 net/bluetooth/hci_conn.c:1092
hci_conn_del+0x59/0xd10 net/bluetooth/hci_conn.c:1118
hci_abort_conn_sync+0xacb/0xe20 net/bluetooth/hci_sync.c:5435
abort_conn_sync+0x18e/0x3a0 net/bluetooth/hci_conn.c:2894
hci_cmd_sync_work+0x1a4/0x3c0 net/bluetooth/hci_sync.c:306
process_one_work+0xaa2/0x16f0 kernel/workqueue.c:2600
worker_thread+0x687/0x1110 kernel/workqueue.c:2751
kthread+0x33a/0x430 kernel/kthread.c:389
ret_from_fork+0x2c/0x70 arch/x86/kernel/process.c:145
ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:304
</TASK>

Allocated by task 5848:
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+0xa2/0xb0 mm/kasan/common.c:383
kasan_kmalloc include/linux/kasan.h:196 [inline]
__do_kmalloc_node mm/slab_common.c:985 [inline]
__kmalloc+0x5d/0x100 mm/slab_common.c:998
kmalloc include/linux/slab.h:586 [inline]
sk_prot_alloc+0x1a4/0x2a0 net/core/sock.c:2089
sk_alloc+0x3a/0x7f0 net/core/sock.c:2142
bt_sock_alloc+0x3b/0x3e0 net/bluetooth/af_bluetooth.c:148
sco_sock_alloc net/bluetooth/sco.c:473 [inline]
sco_sock_create+0xe3/0x3b0 net/bluetooth/sco.c:504
bt_sock_create+0x180/0x340 net/bluetooth/af_bluetooth.c:132
__sock_create+0x334/0x810 net/socket.c:1549
sock_create net/socket.c:1600 [inline]
__sys_socket_create net/socket.c:1637 [inline]
__sys_socket+0x14c/0x260 net/socket.c:1688
__do_sys_socket net/socket.c:1702 [inline]
__se_sys_socket net/socket.c:1700 [inline]
__x64_sys_socket+0x72/0xb0 net/socket.c:1700
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 5849:
kasan_save_stack+0x33/0x50 mm/kasan/common.c:45
kasan_set_track+0x25/0x30 mm/kasan/common.c:52
kasan_save_free_info+0x2b/0x40 mm/kasan/generic.c:522
____kasan_slab_free mm/kasan/common.c:236 [inline]
____kasan_slab_free+0x15e/0x1b0 mm/kasan/common.c:200
kasan_slab_free include/linux/kasan.h:162 [inline]
slab_free_hook mm/slub.c:1792 [inline]
slab_free_freelist_hook+0x10b/0x1e0 mm/slub.c:1818
slab_free mm/slub.c:3801 [inline]
__kmem_cache_free+0xb8/0x2f0 mm/slub.c:3814
sk_prot_free net/core/sock.c:2125 [inline]
__sk_destruct+0x5fc/0x770 net/core/sock.c:2217
sk_destruct+0xc2/0xf0 net/core/sock.c:2232
__sk_free+0xc4/0x3a0 net/core/sock.c:2243
sk_free+0x7c/0xa0 net/core/sock.c:2254
sock_put include/net/sock.h:1983 [inline]
sco_sock_kill net/bluetooth/sco.c:426 [inline]
sco_sock_kill+0x19d/0x1c0 net/bluetooth/sco.c:416
sco_sock_release+0x154/0x2c0 net/bluetooth/sco.c:1234
__sock_release+0xae/0x260 net/socket.c:657
sock_close+0x1c/0x20 net/socket.c:1399
__fput+0x3f7/0xa70 fs/file_table.c:384
task_work_run+0x14d/0x240 kernel/task_work.c:179
get_signal+0x1075/0x2770 kernel/signal.c:2657
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:285 [inline]
syscall_exit_to_user_mode+0x1d/0x60 kernel/entry/common.c:296
do_syscall_64+0x44/0xb0 arch/x86/entry/common.c:86
entry_SYSCALL_64_after_hwframe+0x63/0xcd

The buggy address belongs to the object at ffff888068c19000
which belongs to the cache kmalloc-2k of size 2048
The buggy address is located 128 bytes inside of
freed 2048-byte region [ffff888068c19000, ffff888068c19800)

The buggy address belongs to the physical page:
page:ffffea0001a30600 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x68c18
head:ffffea0001a30600 order:3 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
page_type: 0xffffffff()
raw: 00fff00000010200 ffff888012842000 ffffea0001a30400 0000000000000002
raw: 0000000000000000 0000000000080008 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 0x1d20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 22, tgid 22 (kworker/1:0), ts 96674696674, free_ts 74879599637
__free_pages_ok+0x6b3/0xef0 mm/page_alloc.c:1300
kvfree+0x47/0x50 mm/util.c:650
proc_sys_call_handler+0x549/0x6c0 fs/proc/proc_sysctl.c:610
call_read_iter include/linux/fs.h:1979 [inline]
new_sync_read fs/read_write.c:389 [inline]
vfs_read+0x4e0/0x930 fs/read_write.c:470
ksys_read+0x12f/0x250 fs/read_write.c:613
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

Memory state around the buggy address:
ffff888068c18f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff888068c19000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888068c19080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888068c19100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888068c19180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================


Tested on:

commit: bd6c11bc Merge tag 'net-next-6.6' of git://git.kernel...
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git
console output: https://syzkaller.appspot.com/x/log.txt?x=1214c5ec680000
kernel config: https://syzkaller.appspot.com/x/.config?x=634e05b4025da9da
dashboard link: https://syzkaller.appspot.com/bug?extid=6b9277cad941daf126a2
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=130fd8afa80000

Hillf Danton

unread,
Sep 6, 2023, 8:49:30 AM9/6/23
to syzbot, linux-...@vger.kernel.org, syzkall...@googlegroups.com
On Mon, 04 Sep 2023 00:57:50 -0700
> HEAD commit: bd6c11bc43c4 Merge tag 'net-next-6.6' of git://git.kernel...
> git tree: net-next
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=107fdcd0680000

Hold sock for the lifespan of sco connection.

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git bd6c11bc43c4

--- x/net/bluetooth/sco.c
+++ y/net/bluetooth/sco.c
@@ -191,8 +191,6 @@ static void sco_conn_del(struct hci_conn
/* Kill socket */
sco_conn_lock(conn);
sk = conn->sk;
- if (sk)
- sock_hold(sk);
sco_conn_unlock(conn);

if (sk) {
@@ -217,6 +215,7 @@ static void __sco_chan_add(struct sco_co

sco_pi(sk)->conn = conn;
conn->sk = sk;
+ sock_hold(sk);

if (parent)
bt_accept_enqueue(parent, sk, true);
--

syzbot

unread,
Sep 6, 2023, 4:15:37 PM9/6/23
to hda...@sina.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-and-tested-by: syzbot+6b9277...@syzkaller.appspotmail.com

Tested on:

commit: bd6c11bc Merge tag 'net-next-6.6' of git://git.kernel...
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git
console output: https://syzkaller.appspot.com/x/log.txt?x=1325c2c8680000
kernel config: https://syzkaller.appspot.com/x/.config?x=634e05b4025da9da
dashboard link: https://syzkaller.appspot.com/bug?extid=6b9277cad941daf126a2
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=11989808680000

Note: testing is done by a robot and is best-effort only.

syzbot

unread,
Sep 22, 2023, 8:01:29 AM9/22/23
to da...@davemloft.net, edum...@google.com, hda...@sina.com, johan....@gmail.com, ku...@kernel.org, linux-b...@vger.kernel.org, linux-...@vger.kernel.org, luiz....@gmail.com, luiz.vo...@intel.com, mar...@holtmann.org, net...@vger.kernel.org, pab...@redhat.com, syzkall...@googlegroups.com
syzbot has bisected this issue to:

commit 9a8ec9e8ebb5a7c0cfbce2d6b4a6b67b2b78e8f3
Author: Luiz Augusto von Dentz <luiz.vo...@intel.com>
Date: Thu Mar 30 21:15:50 2023 +0000

Bluetooth: SCO: Fix possible circular locking dependency on sco_connect_cfm

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=10b66646680000
start commit: bd6c11bc43c4 Merge tag 'net-next-6.6' of git://git.kernel...
git tree: net-next
final oops: https://syzkaller.appspot.com/x/report.txt?x=12b66646680000
console output: https://syzkaller.appspot.com/x/log.txt?x=14b66646680000
Reported-by: syzbot+6b9277...@syzkaller.appspotmail.com
Fixes: 9a8ec9e8ebb5 ("Bluetooth: SCO: Fix possible circular locking dependency on sco_connect_cfm")

For information about bisection process see: https://goo.gl/tpsmEJ#bisection
Reply all
Reply to author
Forward
0 new messages