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

32 views
Skip to first unread message

syzbot

unread,
Sep 1, 2023, 5:06:07 AM9/1/23
to johan....@gmail.com, linux-b...@vger.kernel.org, linux-...@vger.kernel.org, luiz....@gmail.com, mar...@holtmann.org, syzkall...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 6c1b980a7e79 Merge tag 'dma-mapping-6.6-2023-08-29' of git..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=1186462fa80000
kernel config: https://syzkaller.appspot.com/x/.config?x=2212484c18930a61
dashboard link: https://syzkaller.appspot.com/bug?extid=dec4d528fb7a7c5d8ce3
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40

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

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/6e2281f5cb6b/disk-6c1b980a.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/5fc2481dcded/vmlinux-6c1b980a.xz
kernel image: https://storage.googleapis.com/syzbot-assets/283bb76567da/bzImage-6c1b980a.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+dec4d5...@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_dec_and_test include/linux/atomic/atomic-instrumented.h:1375 [inline]
BUG: KASAN: slab-use-after-free in hci_conn_drop include/net/bluetooth/hci_core.h:1523 [inline]
BUG: KASAN: slab-use-after-free in __sco_sock_close+0x2bc/0x690 net/bluetooth/sco.c:444
Write of size 4 at addr ffff888019f84010 by task syz-executor.5/15739

CPU: 1 PID: 15739 Comm: syz-executor.5 Not tainted 6.5.0-syzkaller-04808-g6c1b980a7e79 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/26/2023
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_dec_and_test include/linux/atomic/atomic-instrumented.h:1375 [inline]
hci_conn_drop include/net/bluetooth/hci_core.h:1523 [inline]
__sco_sock_close+0x2bc/0x690 net/bluetooth/sco.c:444
sco_sock_close net/bluetooth/sco.c:469 [inline]
sco_sock_release+0x6f/0x2c0 net/bluetooth/sco.c:1246
__sock_release+0xae/0x260 net/socket.c:659
sock_close+0x1c/0x20 net/socket.c:1401
__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
RIP: 0033:0x7fba94e7b9da
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:00007ffcf2751f30 EFLAGS: 00000293 ORIG_RAX: 0000000000000003
RAX: ffffffffffffffda RBX: 0000000000000005 RCX: 00007fba94e7b9da
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000004
RBP: 00007fba94f9d980 R08: 0000001b30360000 R09: 0000000000000001
R10: 0000000000000000 R11: 0000000000000293 R12: 0000000000061f62
R13: ffffffffffffffff R14: 00007fba94a00000 R15: 0000000000061c21
</TASK>

Allocated by task 15740:
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
kmalloc include/linux/slab.h:599 [inline]
kzalloc include/linux/slab.h:720 [inline]
hci_conn_add+0xc2/0x1770 net/bluetooth/hci_conn.c:957
hci_connect_sco+0x3ac/0xf80 net/bluetooth/hci_conn.c:1692
sco_connect net/bluetooth/sco.c:266 [inline]
sco_sock_connect+0x2c7/0xa50 net/bluetooth/sco.c:591
__sys_connect_file+0x15b/0x1a0 net/socket.c:2032
__sys_connect+0x145/0x170 net/socket.c:2049
__do_sys_connect net/socket.c:2059 [inline]
__se_sys_connect net/socket.c:2056 [inline]
__x64_sys_connect+0x72/0xb0 net/socket.c:2056
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 5069:
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+0x15b/0x1b0 mm/kasan/common.c:200
kasan_slab_free include/linux/kasan.h:162 [inline]
slab_free_hook mm/slub.c:1800 [inline]
slab_free_freelist_hook+0x114/0x1e0 mm/slub.c:1826
slab_free mm/slub.c:3809 [inline]
__kmem_cache_free+0xb8/0x2f0 mm/slub.c:3822
device_release+0xa1/0x240 drivers/base/core.c:2484
kobject_cleanup lib/kobject.c:682 [inline]
kobject_release lib/kobject.c:713 [inline]
kref_put include/linux/kref.h:65 [inline]
kobject_put+0x1f7/0x5b0 lib/kobject.c:730
put_device+0x1f/0x30 drivers/base/core.c:3731
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:388
ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:145
ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:304

The buggy address belongs to the object at ffff888019f84000
which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 16 bytes inside of
freed 4096-byte region [ffff888019f84000, ffff888019f85000)

The buggy address belongs to the physical page:
page:ffffea000067e000 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x19f80
head:ffffea000067e000 order:3 entire_mapcount:0 nr_pages_mapped:0 pincount:0
anon flags: 0xfff00000000840(slab|head|node=0|zone=1|lastcpupid=0x7ff)
page_type: 0xffffffff()
raw: 00fff00000000840 ffff888012842140 0000000000000000 dead000000000001
raw: 0000000000000000 0000000000040004 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 0x1d2040(__GFP_IO|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 8581, tgid 8581 (udevd), ts 361782857719, free_ts 361723087478
set_page_owner include/linux/page_owner.h:31 [inline]
post_alloc_hook+0x2cf/0x340 mm/page_alloc.c:1536
prep_new_page mm/page_alloc.c:1543 [inline]
get_page_from_freelist+0x10a9/0x31e0 mm/page_alloc.c:3183
__alloc_pages+0x1d0/0x4a0 mm/page_alloc.c:4439
alloc_pages+0x1a9/0x270 mm/mempolicy.c:2298
alloc_slab_page mm/slub.c:1870 [inline]
allocate_slab+0x251/0x380 mm/slub.c:2017
new_slab mm/slub.c:2070 [inline]
___slab_alloc+0x8be/0x1570 mm/slub.c:3223
__slab_alloc.constprop.0+0x56/0xa0 mm/slub.c:3322
__slab_alloc_node mm/slub.c:3375 [inline]
slab_alloc_node mm/slub.c:3468 [inline]
__kmem_cache_alloc_node+0x137/0x350 mm/slub.c:3517
__do_kmalloc_node mm/slab_common.c:1022 [inline]
__kmalloc+0x4f/0x100 mm/slab_common.c:1036
kmalloc include/linux/slab.h:603 [inline]
tomoyo_realpath_from_path+0xb9/0x710 security/tomoyo/realpath.c:251
tomoyo_get_realpath security/tomoyo/file.c:151 [inline]
tomoyo_check_open_permission+0x2aa/0x3b0 security/tomoyo/file.c:771
tomoyo_file_open security/tomoyo/tomoyo.c:332 [inline]
tomoyo_file_open+0xa8/0xd0 security/tomoyo/tomoyo.c:327
security_file_open+0x6a/0xe0 security/security.c:2811
do_dentry_open+0x538/0x1730 fs/open.c:916
do_open fs/namei.c:3639 [inline]
path_openat+0x19af/0x29c0 fs/namei.c:3796
do_filp_open+0x1de/0x430 fs/namei.c:3823
page last free stack trace:
reset_page_owner include/linux/page_owner.h:24 [inline]
free_pages_prepare mm/page_alloc.c:1136 [inline]
free_unref_page_prepare+0x476/0xa40 mm/page_alloc.c:2312
free_unref_page+0x33/0x3b0 mm/page_alloc.c:2405
__unfreeze_partials+0x21d/0x240 mm/slub.c:2655
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:3478 [inline]
slab_alloc mm/slub.c:3486 [inline]
__kmem_cache_alloc_lru mm/slub.c:3493 [inline]
kmem_cache_alloc+0x172/0x3b0 mm/slub.c:3502
getname_flags.part.0+0x50/0x4d0 fs/namei.c:140
getname_flags include/linux/audit.h:319 [inline]
getname+0x90/0xe0 fs/namei.c:219
do_sys_openat2+0x100/0x1e0 fs/open.c:1416
do_sys_open fs/open.c:1437 [inline]
__do_sys_openat fs/open.c:1453 [inline]
__se_sys_openat fs/open.c:1448 [inline]
__x64_sys_openat+0x175/0x210 fs/open.c:1448
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:
ffff888019f83f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff888019f83f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff888019f84000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888019f84080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888019f84100: 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 overwrite 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 1, 2023, 5:09:50 PM9/1/23
to johan....@gmail.com, linux-b...@vger.kernel.org, linux-...@vger.kernel.org, luiz....@gmail.com, mar...@holtmann.org, syzkall...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: 99d99825fc07 Merge tag 'nfs-for-6.6-1' of git://git.linux-..
git tree: upstream
console+strace: https://syzkaller.appspot.com/x/log.txt?x=1636e913a80000
kernel config: https://syzkaller.appspot.com/x/.config?x=988789167afa40d5
dashboard link: https://syzkaller.appspot.com/bug?extid=dec4d528fb7a7c5d8ce3
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=12e9ba2fa80000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=111affcba80000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/e43170401ca7/disk-99d99825.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/c2be4288f38f/vmlinux-99d99825.xz
kernel image: https://storage.googleapis.com/syzbot-assets/8a6478588fd9/bzImage-99d99825.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+dec4d5...@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_dec_and_test include/linux/atomic/atomic-instrumented.h:1375 [inline]
BUG: KASAN: slab-use-after-free in hci_conn_drop include/net/bluetooth/hci_core.h:1523 [inline]
BUG: KASAN: slab-use-after-free in __sco_sock_close+0x2bc/0x690 net/bluetooth/sco.c:444
Write of size 4 at addr ffff888079e5e010 by task syz-executor321/5276

CPU: 0 PID: 5276 Comm: syz-executor321 Not tainted 6.5.0-syzkaller-09276-g99d99825fc07 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/26/2023
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_dec_and_test include/linux/atomic/atomic-instrumented.h:1375 [inline]
hci_conn_drop include/net/bluetooth/hci_core.h:1523 [inline]
__sco_sock_close+0x2bc/0x690 net/bluetooth/sco.c:444
sco_sock_close net/bluetooth/sco.c:469 [inline]
sco_sock_release+0x6f/0x2c0 net/bluetooth/sco.c:1246
__sock_release+0xae/0x260 net/socket.c:659
sock_close+0x1c/0x20 net/socket.c:1401
__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:2387
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
RIP: 0033:0x7fe1bd28f279
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 11 19 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fe1bca4e218 EFLAGS: 00000246 ORIG_RAX: 000000000000002a
RAX: 0000000000000000 RBX: 00007fe1bd319328 RCX: 00007fe1bd28f279
RDX: 0000000000000008 RSI: 0000000020000040 RDI: 0000000000000004
RBP: 00007fe1bd319320 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000003
R13: 0000000000000004 R14: 00007fe1bca4e670 R15: 0000000000000000
</TASK>

Allocated by task 5276:
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
kmalloc include/linux/slab.h:599 [inline]
kzalloc include/linux/slab.h:720 [inline]
hci_conn_add+0xc2/0x1770 net/bluetooth/hci_conn.c:957
hci_connect_sco+0x3ac/0xf80 net/bluetooth/hci_conn.c:1692
sco_connect net/bluetooth/sco.c:266 [inline]
sco_sock_connect+0x2c7/0xa50 net/bluetooth/sco.c:591
__sys_connect_file+0x15b/0x1a0 net/socket.c:2032
__sys_connect+0x145/0x170 net/socket.c:2049
__do_sys_connect net/socket.c:2059 [inline]
__se_sys_connect net/socket.c:2056 [inline]
__x64_sys_connect+0x72/0xb0 net/socket.c:2056
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 5054:
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+0x15b/0x1b0 mm/kasan/common.c:200
kasan_slab_free include/linux/kasan.h:162 [inline]
slab_free_hook mm/slub.c:1800 [inline]
slab_free_freelist_hook+0x114/0x1e0 mm/slub.c:1826
slab_free mm/slub.c:3809 [inline]
__kmem_cache_free+0xb8/0x2f0 mm/slub.c:3822
device_release+0xa1/0x240 drivers/base/core.c:2484
kobject_cleanup lib/kobject.c:682 [inline]
kobject_release lib/kobject.c:713 [inline]
kref_put include/linux/kref.h:65 [inline]
kobject_put+0x1f7/0x5b0 lib/kobject.c:730
put_device+0x1f/0x30 drivers/base/core.c:3731
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:388
ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:147
ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:304

The buggy address belongs to the object at ffff888079e5e000
which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 16 bytes inside of
freed 4096-byte region [ffff888079e5e000, ffff888079e5f000)

The buggy address belongs to the physical page:
page:ffffea0001e79600 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x79e58
head:ffffea0001e79600 order:3 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0xfff00000000840(slab|head|node=0|zone=1|lastcpupid=0x7ff)
page_type: 0xffffffff()
raw: 00fff00000000840 ffff888012842140 dead000000000100 dead000000000122
raw: 0000000000000000 0000000000040004 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 0xd2040(__GFP_IO|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 4494, tgid 4494 (udevd), ts 25028304092, free_ts 25023027630
set_page_owner include/linux/page_owner.h:31 [inline]
post_alloc_hook+0x2cf/0x340 mm/page_alloc.c:1536
prep_new_page mm/page_alloc.c:1543 [inline]
get_page_from_freelist+0x10a9/0x31e0 mm/page_alloc.c:3183
__alloc_pages+0x1d0/0x4a0 mm/page_alloc.c:4439
alloc_pages+0x1a9/0x270 mm/mempolicy.c:2298
alloc_slab_page mm/slub.c:1870 [inline]
allocate_slab+0x251/0x380 mm/slub.c:2017
new_slab mm/slub.c:2070 [inline]
___slab_alloc+0x8be/0x1570 mm/slub.c:3223
__slab_alloc.constprop.0+0x56/0xa0 mm/slub.c:3322
__slab_alloc_node mm/slub.c:3375 [inline]
slab_alloc_node mm/slub.c:3468 [inline]
__kmem_cache_alloc_node+0x137/0x350 mm/slub.c:3517
__do_kmalloc_node mm/slab_common.c:1022 [inline]
__kmalloc+0x4f/0x100 mm/slab_common.c:1036
kmalloc include/linux/slab.h:603 [inline]
tomoyo_realpath_from_path+0xb9/0x710 security/tomoyo/realpath.c:251
tomoyo_get_realpath security/tomoyo/file.c:151 [inline]
tomoyo_path2_perm+0x2a1/0x710 security/tomoyo/file.c:922
tomoyo_path_rename+0x102/0x1b0 security/tomoyo/tomoyo.c:299
security_path_rename+0x148/0x230 security/security.c:1828
do_renameat2+0x78b/0xdc0 fs/namei.c:4999
__do_sys_rename fs/namei.c:5058 [inline]
__se_sys_rename fs/namei.c:5056 [inline]
__x64_sys_rename+0x81/0xa0 fs/namei.c:5056
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
page last free stack trace:
reset_page_owner include/linux/page_owner.h:24 [inline]
free_pages_prepare mm/page_alloc.c:1136 [inline]
free_unref_page_prepare+0x476/0xa40 mm/page_alloc.c:2312
free_unref_page+0x33/0x3b0 mm/page_alloc.c:2405
__unfreeze_partials+0x21d/0x240 mm/slub.c:2655
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:3478 [inline]
__kmem_cache_alloc_node+0x19b/0x350 mm/slub.c:3517
kmalloc_trace+0x25/0xe0 mm/slab_common.c:1114
kmalloc include/linux/slab.h:599 [inline]
kzalloc include/linux/slab.h:720 [inline]
kernfs_get_open_node fs/kernfs/file.c:572 [inline]
kernfs_fop_open+0xad1/0xe00 fs/kernfs/file.c:740
do_dentry_open+0x88b/0x1730 fs/open.c:929
do_open fs/namei.c:3639 [inline]
path_openat+0x19af/0x29c0 fs/namei.c:3796
do_filp_open+0x1de/0x430 fs/namei.c:3823
do_sys_openat2+0x176/0x1e0 fs/open.c:1422
do_sys_open fs/open.c:1437 [inline]
__do_sys_openat fs/open.c:1453 [inline]
__se_sys_openat fs/open.c:1448 [inline]
__x64_sys_openat+0x175/0x210 fs/open.c:1448
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:
ffff888079e5df00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff888079e5df80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff888079e5e000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888079e5e080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888079e5e100: 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 1, 2023, 8:42:49 PM9/1/23
to syzbot, linux-...@vger.kernel.org, syzkall...@googlegroups.com
On Fri, 01 Sep 2023 14:09:48 -0700
> syzbot has found a reproducer for the following issue on:
>
> HEAD commit: 99d99825fc07 Merge tag 'nfs-for-6.6-1' of git://git.linux-..
> git tree: upstream
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=111affcba80000

Put hcon instead of dropping it.

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master

--- x/net/bluetooth/sco.c
+++ y/net/bluetooth/sco.c
@@ -296,6 +296,7 @@ static int sco_connect(struct sock *sk)
sco_sock_set_timer(sk, sk->sk_sndtimeo);
}

+ hci_conn_get(hcon);
release_sock(sk);

unlock:
@@ -438,12 +439,15 @@ static void __sco_sock_close(struct sock
case BT_CONNECTED:
case BT_CONFIG:
if (sco_pi(sk)->conn->hcon) {
+ struct hci_conn *hcon = 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);
+
+ hci_conn_put(hcon);
} else
sco_chan_del(sk, ECONNRESET);
break;
--

syzbot

unread,
Sep 1, 2023, 9:41:28 PM9/1/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+dec4d5...@syzkaller.appspotmail.com

Tested on:

commit: 0468be89 Merge tag 'iommu-updates-v6.6' of git://git.k..
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
console output: https://syzkaller.appspot.com/x/log.txt?x=11642f9fa80000
kernel config: https://syzkaller.appspot.com/x/.config?x=3bd57a1ac08277b0
dashboard link: https://syzkaller.appspot.com/bug?extid=dec4d528fb7a7c5d8ce3
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=11b39898680000

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

Edward AD

unread,
Sep 1, 2023, 11:11:05 PM9/1/23
to syzbot+dec4d5...@syzkaller.appspotmail.com, syzkall...@googlegroups.com
please test uaf in __sco_sock_close

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 6c1b980a7e79

diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
index c736186aba26..2cd92c97ae02 100644
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -441,8 +441,10 @@ static void __sco_sock_close(struct sock *sk)
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;
+ if (sco_pi(sk)->conn->hcon) {
+ 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);

syzbot

unread,
Sep 1, 2023, 11:37:36 PM9/1/23
to ead...@sina.com, 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_sock_close

==================================================================
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_dec_and_test include/linux/atomic/atomic-instrumented.h:1375 [inline]
BUG: KASAN: slab-use-after-free in hci_conn_drop include/net/bluetooth/hci_core.h:1523 [inline]
BUG: KASAN: slab-use-after-free in __sco_sock_close+0x2c9/0x6a0 net/bluetooth/sco.c:445
Write of size 4 at addr ffff8880156b4010 by task syz-executor.4/5738

CPU: 1 PID: 5738 Comm: syz-executor.4 Not tainted 6.5.0-syzkaller-04808-g6c1b980a7e79-dirty #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/26/2023
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_dec_and_test include/linux/atomic/atomic-instrumented.h:1375 [inline]
hci_conn_drop include/net/bluetooth/hci_core.h:1523 [inline]
__sco_sock_close+0x2c9/0x6a0 net/bluetooth/sco.c:445
sco_sock_close net/bluetooth/sco.c:471 [inline]
sco_sock_release+0x6f/0x2c0 net/bluetooth/sco.c:1248
__sock_release+0xae/0x260 net/socket.c:659
sock_close+0x1c/0x20 net/socket.c:1401
__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
RIP: 0033:0x7f2afaa7b9da
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:00007fffce3a5d00 EFLAGS: 00000293 ORIG_RAX: 0000000000000003
RAX: ffffffffffffffda RBX: 0000000000000005 RCX: 00007f2afaa7b9da
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000004
RBP: 00007f2afab9d980 R08: 0000001b2c760000 R09: 0000000000000001
R10: 0000000000000000 R11: 0000000000000293 R12: 000000000001799b
R13: ffffffffffffffff R14: 00007f2afa600000 R15: 000000000001765a
</TASK>

Allocated by task 5739:
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
kmalloc include/linux/slab.h:599 [inline]
kzalloc include/linux/slab.h:720 [inline]
hci_conn_add+0xc2/0x1770 net/bluetooth/hci_conn.c:957
hci_connect_sco+0x3ac/0xf80 net/bluetooth/hci_conn.c:1692
sco_connect net/bluetooth/sco.c:266 [inline]
sco_sock_connect+0x2c7/0xa50 net/bluetooth/sco.c:593
__sys_connect_file+0x15b/0x1a0 net/socket.c:2032
__sys_connect+0x145/0x170 net/socket.c:2049
__do_sys_connect net/socket.c:2059 [inline]
__se_sys_connect net/socket.c:2056 [inline]
__x64_sys_connect+0x72/0xb0 net/socket.c:2056
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 4436:
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+0x15b/0x1b0 mm/kasan/common.c:200
kasan_slab_free include/linux/kasan.h:162 [inline]
slab_free_hook mm/slub.c:1800 [inline]
slab_free_freelist_hook+0x114/0x1e0 mm/slub.c:1826
slab_free mm/slub.c:3809 [inline]
__kmem_cache_free+0xb8/0x2f0 mm/slub.c:3822
device_release+0xa1/0x240 drivers/base/core.c:2484
kobject_cleanup lib/kobject.c:682 [inline]
kobject_release lib/kobject.c:713 [inline]
kref_put include/linux/kref.h:65 [inline]
kobject_put+0x1f7/0x5b0 lib/kobject.c:730
put_device+0x1f/0x30 drivers/base/core.c:3731
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:388
ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:145
ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:304

The buggy address belongs to the object at ffff8880156b4000
which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 16 bytes inside of
freed 4096-byte region [ffff8880156b4000, ffff8880156b5000)

The buggy address belongs to the physical page:
page:ffffea000055ac00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x156b0
head:ffffea000055ac00 order:3 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0xfff00000000840(slab|head|node=0|zone=1|lastcpupid=0x7ff)
page_type: 0xffffffff()
raw: 00fff00000000840 ffff888012842140 dead000000000122 0000000000000000
raw: 0000000000000000 0000000000040004 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 0x1d2040(__GFP_IO|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 5738, tgid 5738 (syz-executor.4), ts 95856753309, free_ts 95812544142
set_page_owner include/linux/page_owner.h:31 [inline]
post_alloc_hook+0x2cf/0x340 mm/page_alloc.c:1536
prep_new_page mm/page_alloc.c:1543 [inline]
get_page_from_freelist+0x10a9/0x31e0 mm/page_alloc.c:3183
__alloc_pages+0x1d0/0x4a0 mm/page_alloc.c:4439
alloc_pages+0x1a9/0x270 mm/mempolicy.c:2298
alloc_slab_page mm/slub.c:1870 [inline]
allocate_slab+0x251/0x380 mm/slub.c:2017
new_slab mm/slub.c:2070 [inline]
___slab_alloc+0x8be/0x1570 mm/slub.c:3223
__slab_alloc.constprop.0+0x56/0xa0 mm/slub.c:3322
__slab_alloc_node mm/slub.c:3375 [inline]
slab_alloc_node mm/slub.c:3468 [inline]
__kmem_cache_alloc_node+0x137/0x350 mm/slub.c:3517
__do_kmalloc_node mm/slab_common.c:1022 [inline]
__kmalloc+0x4f/0x100 mm/slab_common.c:1036
kmalloc include/linux/slab.h:603 [inline]
tomoyo_realpath_from_path+0xb9/0x710 security/tomoyo/realpath.c:251
tomoyo_get_realpath security/tomoyo/file.c:151 [inline]
tomoyo_path_perm+0x271/0x450 security/tomoyo/file.c:822
tomoyo_path_symlink+0x98/0xe0 security/tomoyo/tomoyo.c:211
security_path_symlink+0x101/0x160 security/security.c:1761
do_symlinkat+0x120/0x310 fs/namei.c:4504
__do_sys_symlinkat fs/namei.c:4522 [inline]
__se_sys_symlinkat fs/namei.c:4519 [inline]
__x64_sys_symlinkat+0x97/0xc0 fs/namei.c:4519
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80
page last free stack trace:
reset_page_owner include/linux/page_owner.h:24 [inline]
free_pages_prepare mm/page_alloc.c:1136 [inline]
free_unref_page_prepare+0x476/0xa40 mm/page_alloc.c:2312
free_unref_page+0x33/0x3b0 mm/page_alloc.c:2405
__unfreeze_partials+0x21d/0x240 mm/slub.c:2655
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:3478 [inline]
slab_alloc mm/slub.c:3486 [inline]
__kmem_cache_alloc_lru mm/slub.c:3493 [inline]
kmem_cache_alloc+0x172/0x3b0 mm/slub.c:3502
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:
ffff8880156b3f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff8880156b3f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff8880156b4000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8880156b4080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880156b4100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================


Tested on:

commit: 6c1b980a Merge tag 'dma-mapping-6.6-2023-08-29' of git..
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
console output: https://syzkaller.appspot.com/x/log.txt?x=16524210680000
kernel config: https://syzkaller.appspot.com/x/.config?x=7c3c5b0042a24b25
dashboard link: https://syzkaller.appspot.com/bug?extid=dec4d528fb7a7c5d8ce3
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=1553405fa80000

Edward AD

unread,
Sep 2, 2023, 12:37:37 AM9/2/23
to syzbot+dec4d5...@syzkaller.appspotmail.com, syzkall...@googlegroups.com
please test uaf in __sco_sock_close

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 6c1b980a7e79

diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index e6359f7346f1..d0a2993883af 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -1518,6 +1518,9 @@ static inline struct hci_conn *hci_conn_hold(struct hci_conn *conn)

static inline void hci_conn_drop(struct hci_conn *conn)
{
+ if (IS_ERR(conn))
+ return;
+
BT_DBG("hcon %p orig refcnt %d", conn, atomic_read(&conn->refcnt));

if (atomic_dec_and_test(&conn->refcnt)) {

syzbot

unread,
Sep 2, 2023, 1:23:27 AM9/2/23
to ead...@sina.com, 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_sock_close

==================================================================
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_dec_and_test include/linux/atomic/atomic-instrumented.h:1375 [inline]
BUG: KASAN: slab-use-after-free in hci_conn_drop include/net/bluetooth/hci_core.h:1526 [inline]
BUG: KASAN: slab-use-after-free in __sco_sock_close+0x2d9/0x700 net/bluetooth/sco.c:444
Write of size 4 at addr ffff888029f0c010 by task syz-executor.0/10975

CPU: 0 PID: 10975 Comm: syz-executor.0 Not tainted 6.5.0-syzkaller-04808-g6c1b980a7e79-dirty #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/26/2023
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_dec_and_test include/linux/atomic/atomic-instrumented.h:1375 [inline]
hci_conn_drop include/net/bluetooth/hci_core.h:1526 [inline]
__sco_sock_close+0x2d9/0x700 net/bluetooth/sco.c:444
sco_sock_close net/bluetooth/sco.c:469 [inline]
sco_sock_release+0x6f/0x2c0 net/bluetooth/sco.c:1246
__sock_release+0xae/0x260 net/socket.c:659
sock_close+0x1c/0x20 net/socket.c:1401
__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
RIP: 0033:0x7fe960a7b9da
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:00007fff2c9d3f30 EFLAGS: 00000293 ORIG_RAX: 0000000000000003
RAX: ffffffffffffffda RBX: 0000000000000005 RCX: 00007fe960a7b9da
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000004
RBP: 00007fe960b9d980 R08: 0000001b2d160000 R09: 0000000000000001
R10: 0000000000000000 R11: 0000000000000293 R12: 000000000003c477
R13: ffffffffffffffff R14: 00007fe960600000 R15: 000000000003c136
</TASK>

Allocated by task 10978:
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
kmalloc include/linux/slab.h:599 [inline]
kzalloc include/linux/slab.h:720 [inline]
hci_conn_add+0xc2/0x1770 net/bluetooth/hci_conn.c:957
hci_connect_sco+0x3ac/0xfa0 net/bluetooth/hci_conn.c:1692
sco_connect net/bluetooth/sco.c:266 [inline]
sco_sock_connect+0x2c7/0xa60 net/bluetooth/sco.c:591
The buggy address belongs to the object at ffff888029f0c000
which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 16 bytes inside of
freed 4096-byte region [ffff888029f0c000, ffff888029f0d000)

The buggy address belongs to the physical page:
page:ffffea0000a7c200 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x29f08
head:ffffea0000a7c200 order:3 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0xfff00000000840(slab|head|node=0|zone=1|lastcpupid=0x7ff)
page_type: 0xffffffff()
raw: 00fff00000000840 ffff888012842140 dead000000000122 0000000000000000
raw: 0000000000000000 0000000000040004 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 0x1d2040(__GFP_IO|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 10975, tgid 10975 (syz-executor.0), ts 246088589210, free_ts 246031226387
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:3478 [inline]
slab_alloc mm/slub.c:3486 [inline]
__kmem_cache_alloc_lru mm/slub.c:3493 [inline]
kmem_cache_alloc+0x172/0x3b0 mm/slub.c:3502
kmem_cache_zalloc include/linux/slab.h:710 [inline]
taskstats_tgid_alloc kernel/taskstats.c:583 [inline]
taskstats_exit+0x611/0xba0 kernel/taskstats.c:622
do_exit+0x839/0x2a20 kernel/exit.c:859
do_group_exit+0xd4/0x2a0 kernel/exit.c:1024
__do_sys_exit_group kernel/exit.c:1035 [inline]
__se_sys_exit_group kernel/exit.c:1033 [inline]
__x64_sys_exit_group+0x3e/0x50 kernel/exit.c:1033
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:
ffff888029f0bf00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff888029f0bf80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff888029f0c000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888029f0c080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888029f0c100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================


Tested on:

commit: 6c1b980a Merge tag 'dma-mapping-6.6-2023-08-29' of git..
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
console output: https://syzkaller.appspot.com/x/log.txt?x=172d7898680000
kernel config: https://syzkaller.appspot.com/x/.config?x=7c3c5b0042a24b25
dashboard link: https://syzkaller.appspot.com/bug?extid=dec4d528fb7a7c5d8ce3
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=10bff7dfa80000

syzbot

unread,
Sep 10, 2023, 6:43:40 PM9/10/23
to ead...@sina.com, hda...@sina.com, johan....@gmail.com, linux-b...@vger.kernel.org, linux-...@vger.kernel.org, luiz....@gmail.com, luiz.vo...@intel.com, mar...@holtmann.org, p...@iki.fi, syzkall...@googlegroups.com
syzbot has bisected this issue to:

commit 94d9ba9f9888b748d4abd2aa1547af56ae85f772
Author: Luiz Augusto von Dentz <luiz.vo...@intel.com>
Date: Wed Aug 9 23:49:33 2023 +0000

Bluetooth: hci_sync: Fix UAF in hci_disconnect_all_sync

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=124d6578680000
start commit: 99d99825fc07 Merge tag 'nfs-for-6.6-1' of git://git.linux-..
git tree: upstream
final oops: https://syzkaller.appspot.com/x/report.txt?x=114d6578680000
console output: https://syzkaller.appspot.com/x/log.txt?x=164d6578680000
Reported-by: syzbot+dec4d5...@syzkaller.appspotmail.com
Fixes: 94d9ba9f9888 ("Bluetooth: hci_sync: Fix UAF in hci_disconnect_all_sync")

For information about bisection process see: https://goo.gl/tpsmEJ#bisection

syzbot

unread,
Nov 27, 2023, 2:13:06 AM11/27/23
to da...@davemloft.net, ead...@sina.com, 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, p...@iki.fi, syzkall...@googlegroups.com, william.x...@huawei.com
syzbot suspects this issue was fixed by commit:

commit 181a42edddf51d5d9697ecdf365d72ebeab5afb0
Author: Ziyang Xuan <william.x...@huawei.com>
Date: Wed Oct 11 09:57:31 2023 +0000

Bluetooth: Make handle of hci_conn be unique

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=140ffa0ce80000
start commit: bd6c11bc43c4 Merge tag 'net-next-6.6' of git://git.kernel...
git tree: net-next
kernel config: https://syzkaller.appspot.com/x/.config?x=634e05b4025da9da
dashboard link: https://syzkaller.appspot.com/bug?extid=dec4d528fb7a7c5d8ce3
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=145586a8680000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=13bf8dffa80000

If the result looks correct, please mark the issue as fixed by replying with:

#syz fix: Bluetooth: Make handle of hci_conn be unique

syzbot

unread,
Apr 4, 2024, 4:24:17 AMApr 4
to syzkall...@googlegroups.com
Auto-closing this bug as obsolete.
No recent activity, existing reproducers are no longer triggering the issue.
Reply all
Reply to author
Forward
0 new messages