syzbot


KASAN: use-after-free Write in sco_sock_timeout
Status: upstream: reported C repro on 2021/08/26 16:29
Reported-by: syzbot+2bef95d3ab4daa10155b@syzkaller.appspotmail.com
Fix commit: 7aa1e7d15f8a Bluetooth: fix dangling sco_conn and use-after-free in sco_sock_timeout
Patched on: [ci-qemu-upstream ci-qemu-upstream-386 ci-qemu2-arm32 ci-qemu2-arm64 ci-qemu2-arm64-compat ci-qemu2-arm64-mte ci-upstream-bpf-kasan-gce ci-upstream-bpf-next-kasan-gce ci-upstream-gce-leak ci-upstream-kasan-gce ci-upstream-kasan-gce-386 ci-upstream-kasan-gce-root ci-upstream-kasan-gce-selinux-root ci-upstream-kasan-gce-smack-root ci-upstream-linux-next-kasan-gce-root ci-upstream-net-kasan-gce ci-upstream-net-this-kasan-gce ci2-upstream-kcsan-gce], missing on: [ci-qemu2-riscv64 ci-upstream-kmsan-gce ci-upstream-kmsan-gce-386 ci2-upstream-usb]
First crash: 277d, last: 3d04h

Cause bisection: introduced by (bisect log) :
commit e1dee2c1de2b4dd00eb44004a4bda6326ed07b59
Author: Desmond Cheong Zhi Xi <desmondcheongzx@gmail.com>
Date: Tue Aug 10 04:14:10 2021 +0000

  Bluetooth: fix repeated calls to sco_sock_kill

Crash: KASAN: use-after-free Write in sco_sock_timeout (log)
Repro: syz .config
similar bugs (2):
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.14 KASAN: use-after-free Read in sco_sock_timeout C 17 8d09h 107d 0/1 upstream: reported C repro on 2022/02/10 13:41
linux-4.19 KASAN: use-after-free Read in sco_sock_timeout syz 73 16d 248d 0/1 upstream: reported syz repro on 2021/09/22 11:06
Patch testing requests:
Created Duration User Patch Repo Result
2022/02/27 07:40 11m hdanton@sina.com patch https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/ 922ea87ff6f2 OK
2022/02/27 06:08 10m hdanton@sina.com patch https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/ 922ea87ff6f2 report log
2022/02/27 03:27 10m hdanton@sina.com patch https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/ 922ea87ff6f2 report log
2022/02/27 02:56 9m hdanton@sina.com patch https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/ 922ea87ff6f2 report log
2022/02/26 18:02 8m phind.uet@gmail.com linux-next error
2021/08/29 18:34 16m desmondcheongzx@gmail.com patch git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git e3f30ab28ac8 OK
2021/08/29 08:29 15m hdanton@sina.com patch git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git e3f30ab28ac8 OK

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in instrument_atomic_read_write include/linux/instrumented.h:101 [inline]
BUG: KASAN: use-after-free in atomic_fetch_add_relaxed include/linux/atomic/atomic-instrumented.h:116 [inline]
BUG: KASAN: use-after-free in __refcount_add include/linux/refcount.h:193 [inline]
BUG: KASAN: use-after-free in __refcount_inc include/linux/refcount.h:250 [inline]
BUG: KASAN: use-after-free in refcount_inc include/linux/refcount.h:267 [inline]
BUG: KASAN: use-after-free in sock_hold include/net/sock.h:726 [inline]
BUG: KASAN: use-after-free in sco_sock_timeout+0x64/0x290 net/bluetooth/sco.c:89
Write of size 4 at addr ffff8880164c9080 by task kworker/0:3/3331

CPU: 0 PID: 3331 Comm: kworker/0:3 Not tainted 5.18.0-syzkaller-02752-gfdaf9a5840ac #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: events sco_sock_timeout
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
 print_address_description.constprop.0.cold+0xeb/0x495 mm/kasan/report.c:313
 print_report mm/kasan/report.c:429 [inline]
 kasan_report.cold+0xf4/0x1c6 mm/kasan/report.c:491
 check_region_inline mm/kasan/generic.c:183 [inline]
 kasan_check_range+0x13d/0x180 mm/kasan/generic.c:189
 instrument_atomic_read_write include/linux/instrumented.h:101 [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:726 [inline]
 sco_sock_timeout+0x64/0x290 net/bluetooth/sco.c:89
 process_one_work+0x996/0x1610 kernel/workqueue.c:2289
 worker_thread+0x665/0x1080 kernel/workqueue.c:2436
 kthread+0x2e9/0x3a0 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:302
 </TASK>

Allocated by task 4352:
 kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38
 kasan_set_track mm/kasan/common.c:45 [inline]
 set_alloc_info mm/kasan/common.c:436 [inline]
 ____kasan_kmalloc mm/kasan/common.c:515 [inline]
 ____kasan_kmalloc mm/kasan/common.c:474 [inline]
 __kasan_kmalloc+0xa9/0xd0 mm/kasan/common.c:524
 kmalloc include/linux/slab.h:586 [inline]
 sk_prot_alloc+0x110/0x290 net/core/sock.c:1936
 sk_alloc+0x36/0x770 net/core/sock.c:1989
 sco_sock_alloc.constprop.0+0x31/0x330 net/bluetooth/sco.c:483
 sco_sock_create+0xd5/0x1b0 net/bluetooth/sco.c:522
 bt_sock_create+0x17c/0x340 net/bluetooth/af_bluetooth.c:130
 __sock_create+0x353/0x790 net/socket.c:1468
 sock_create net/socket.c:1519 [inline]
 __sys_socket_create net/socket.c:1556 [inline]
 __sys_socket_create net/socket.c:1541 [inline]
 __sys_socket+0x12f/0x240 net/socket.c:1589
 __do_sys_socket net/socket.c:1602 [inline]
 __se_sys_socket net/socket.c:1600 [inline]
 __x64_sys_socket+0x6f/0xb0 net/socket.c:1600
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x46/0xb0

Freed by task 4352:
 kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38
 kasan_set_track+0x21/0x30 mm/kasan/common.c:45
 kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:370
 ____kasan_slab_free mm/kasan/common.c:366 [inline]
 ____kasan_slab_free+0x166/0x1a0 mm/kasan/common.c:328
 kasan_slab_free include/linux/kasan.h:200 [inline]
 slab_free_hook mm/slub.c:1728 [inline]
 slab_free_freelist_hook+0x8b/0x1c0 mm/slub.c:1754
 slab_free mm/slub.c:3510 [inline]
 kfree+0xd6/0x4d0 mm/slub.c:4552
 sk_prot_free net/core/sock.c:1972 [inline]
 __sk_destruct+0x5e5/0x710 net/core/sock.c:2058
 sk_destruct+0x131/0x180 net/core/sock.c:2076
 __sk_free+0xef/0x3d0 net/core/sock.c:2087
 sk_free+0x78/0xa0 net/core/sock.c:2098
 sock_put include/net/sock.h:1926 [inline]
 sco_sock_kill+0x18d/0x1b0 net/bluetooth/sco.c:403
 sco_sock_release+0x155/0x2c0 net/bluetooth/sco.c:1259
 __sock_release+0xcd/0x280 net/socket.c:650
 sock_close+0x18/0x20 net/socket.c:1318
 __fput+0x277/0x9d0 fs/file_table.c:317
 task_work_run+0xdd/0x1a0 kernel/task_work.c:177
 ptrace_notify+0x114/0x140 kernel/signal.c:2372
 ptrace_report_syscall include/linux/ptrace.h:427 [inline]
 ptrace_report_syscall_exit include/linux/ptrace.h:489 [inline]
 syscall_exit_work kernel/entry/common.c:249 [inline]
 syscall_exit_to_user_mode_prepare+0xdb/0x230 kernel/entry/common.c:276
 __syscall_exit_to_user_mode_work kernel/entry/common.c:281 [inline]
 syscall_exit_to_user_mode+0x9/0x50 kernel/entry/common.c:294
 do_syscall_64+0x42/0xb0 arch/x86/entry/common.c:86
 entry_SYSCALL_64_after_hwframe+0x46/0xb0

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

The buggy address belongs to the physical page:
page:ffffea0000593200 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x164c8
head:ffffea0000593200 order:3 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 0000000000000000 dead000000000001 ffff888010c42000
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 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 1, tgid 1 (swapper/0), ts 1664297199, free_ts 0
 prep_new_page mm/page_alloc.c:2441 [inline]
 get_page_from_freelist+0xba2/0x3e00 mm/page_alloc.c:4182
 __alloc_pages+0x1b2/0x500 mm/page_alloc.c:5408
 alloc_page_interleave+0x1e/0x200 mm/mempolicy.c:2104
 alloc_pages+0x2b1/0x310 mm/mempolicy.c:2267
 alloc_slab_page mm/slub.c:1799 [inline]
 allocate_slab+0x26c/0x3c0 mm/slub.c:1944
 new_slab mm/slub.c:2004 [inline]
 ___slab_alloc+0x8df/0xf20 mm/slub.c:3005
 __slab_alloc.constprop.0+0x4d/0xa0 mm/slub.c:3092
 slab_alloc_node mm/slub.c:3183 [inline]
 slab_alloc mm/slub.c:3225 [inline]
 __kmalloc+0x318/0x350 mm/slub.c:4410
 kmalloc include/linux/slab.h:586 [inline]
 kzalloc include/linux/slab.h:714 [inline]
 acpi_os_allocate_zeroed include/acpi/platform/aclinuxex.h:57 [inline]
 acpi_ds_build_internal_package_obj+0x2a8/0x9ab drivers/acpi/acpica/dspkginit.c:112
 acpi_ds_eval_data_object_operands+0x351/0x48c drivers/acpi/acpica/dsopcode.c:638
 acpi_ds_exec_end_op+0xa82/0xe4a drivers/acpi/acpica/dswexec.c:615
 acpi_ps_parse_loop+0x10d0/0x1402 drivers/acpi/acpica/psloop.c:525
 acpi_ps_parse_aml+0x212/0x8cc drivers/acpi/acpica/psparse.c:475
 acpi_ps_execute_table+0x356/0x3eb drivers/acpi/acpica/psxface.c:295
 acpi_ns_execute_table+0x3c9/0x47e drivers/acpi/acpica/nsparse.c:116
 acpi_ns_load_table+0x60/0x116 drivers/acpi/acpica/nsload.c:71
page_owner free stack trace missing

Memory state around the buggy address:
 ffff8880164c8f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff8880164c9000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8880164c9080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                   ^
 ffff8880164c9100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880164c9180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (272):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-kasan-gce-root 2022/05/25 18:03 upstream fdaf9a5840ac 647c0e27 .config log report syz C KASAN: use-after-free Write in sco_sock_timeout
ci-upstream-kasan-gce-selinux-root 2022/03/14 18:07 upstream 09688c0166e7 9e8eaa75 .config log report syz C KASAN: use-after-free Write in sco_sock_timeout
ci-upstream-net-this-kasan-gce 2022/03/16 01:14 net 0f74b29a4f53 9e8eaa75 .config log report syz C KASAN: use-after-free Write in sco_sock_timeout
ci-upstream-net-kasan-gce 2022/03/14 20:24 net-next d96657dc9238 9e8eaa75 .config log report syz C KASAN: use-after-free Write in sco_sock_timeout
ci-upstream-net-kasan-gce 2022/02/27 06:46 net-next 0cc70c6eecf1 45a13a73 .config log report syz C KASAN: use-after-free Write in sco_sock_timeout
ci-upstream-net-kasan-gce 2022/02/23 16:14 net-next 922ea87ff6f2 6e821dbf .config log report syz C KASAN: use-after-free Write in sco_sock_timeout
ci-upstream-kasan-gce-root 2021/09/23 01:23 upstream cf1d2c3e7e2f 8cac236e .config log report syz KASAN: use-after-free Write in sco_sock_timeout
ci-upstream-net-kasan-gce 2021/08/25 20:55 net-next e3f30ab28ac8 b599f2fc .config log report syz KASAN: use-after-free Write in sco_sock_timeout
ci-upstream-kasan-gce-smack-root 2022/05/13 08:18 upstream f3f19f939c11 9ad6612a .config log report info KASAN: use-after-free Write in sco_sock_timeout
ci-upstream-kasan-gce-smack-root 2022/05/12 21:08 upstream 0ac824f379fb 9ad6612a .config log report info KASAN: use-after-free Write in sco_sock_timeout
ci-upstream-kasan-gce-smack-root 2022/05/08 20:55 upstream 379c72654524 e60b1103 .config log report info KASAN: use-after-free Write in sco_sock_timeout
ci-upstream-kasan-gce-root 2022/05/01 18:38 upstream b2da7df52e16 2df221f6 .config log report info KASAN: use-after-free Write in sco_sock_timeout
ci-upstream-kasan-gce-root 2022/04/29 17:39 upstream 38d741cb70b3 44a5ca63 .config log report info KASAN: use-after-free Write in sco_sock_timeout
ci-upstream-kasan-gce-root 2022/04/25 17:30 upstream af2d861d4cd2 c889aef9 .config log report info KASAN: use-after-free Write in sco_sock_timeout
ci-upstream-kasan-gce-selinux-root 2022/04/12 06:45 upstream ce522ba9ef7e af01ee7d .config log report info KASAN: use-after-free Write in sco_sock_timeout
ci-upstream-kasan-gce-root 2022/04/10 10:49 upstream e1f700ebd6be e22c3da3 .config log report info KASAN: use-after-free Write in sco_sock_timeout
ci-upstream-kasan-gce-selinux-root 2022/04/01 04:24 upstream b4a5ea09b293 68fc921a .config log report info KASAN: use-after-free Write in sco_sock_timeout
ci-upstream-kasan-gce-root 2022/03/26 09:57 upstream 52d543b5497c 89bc8608 .config log report info KASAN: use-after-free Write in sco_sock_timeout
ci-upstream-kasan-gce-smack-root 2022/03/26 03:50 upstream 34af78c4e616 89bc8608 .config log report info KASAN: use-after-free Write in sco_sock_timeout
ci-upstream-kasan-gce-smack-root 2022/03/21 23:55 upstream f443e374ae13 e2d91b1d .config log report info KASAN: use-after-free Write in sco_sock_timeout
ci-upstream-kasan-gce-smack-root 2022/03/16 17:07 upstream 56e337f2cf13 dfa9a8ed .config log report info KASAN: use-after-free Write in sco_sock_timeout
ci-upstream-kasan-gce-root 2022/03/15 05:04 upstream 09688c0166e7 9e8eaa75 .config log report info KASAN: use-after-free Write in sco_sock_timeout
ci-upstream-kasan-gce-smack-root 2022/03/15 03:43 upstream 09688c0166e7 9e8eaa75 .config log report info KASAN: use-after-free Write in sco_sock_timeout
ci-upstream-kasan-gce-root 2022/03/11 06:27 upstream dda64ead7e82 9e8eaa75 .config log report info KASAN: use-after-free Write in sco_sock_timeout
ci-upstream-kasan-gce-smack-root 2022/03/05 22:21 upstream 0014404f9c18 7bdd8b2c .config log report info KASAN: use-after-free Write in sco_sock_timeout
ci-upstream-kasan-gce-smack-root 2022/03/01 23:55 upstream 575115360652 45a13a73 .config log report info KASAN: use-after-free Write in sco_sock_timeout
ci-qemu-upstream 2022/01/15 10:29 upstream 112450df61b7 723cfaf0 .config log report info KASAN: use-after-free Write in sco_sock_timeout
ci-qemu-upstream-386 2022/05/16 10:43 upstream 42226c989789 744a39e2 .config log report info KASAN: use-after-free Write in sco_sock_timeout
ci-qemu-upstream-386 2022/05/06 01:10 upstream 0f5d752b1395 efeff0a5 .config log report info KASAN: use-after-free Write in sco_sock_timeout
ci-qemu-upstream-386 2022/04/26 05:23 upstream d615b5416f8a 152baedd .config log report info KASAN: use-after-free Write in sco_sock_timeout
ci-qemu-upstream-386 2022/04/07 01:56 upstream 3e732ebf7316 97582466 .config log report info KASAN: use-after-free Write in sco_sock_timeout
ci-qemu-upstream-386 2022/03/01 13:09 upstream 719fce7539cd 45a13a73 .config log report info KASAN: use-after-free Write in sco_sock_timeout
ci-upstream-net-this-kasan-gce 2022/05/13 01:38 net 810c2f0a3f86 9ad6612a .config log report info KASAN: use-after-free Write in sco_sock_timeout
ci-upstream-net-this-kasan-gce 2022/04/24 02:57 net 165e3e17fe8f 131df97d .config log report info KASAN: use-after-free Write in sco_sock_timeout
ci-upstream-net-this-kasan-gce 2022/04/21 09:51 net 5e6242151d7f d4befee1 .config log report info KASAN: use-after-free Write in sco_sock_timeout
ci-upstream-net-this-kasan-gce 2022/04/20 21:11 net 234901de2bc6 160a3f31 .config log report info KASAN: use-after-free Write in sco_sock_timeout
ci-upstream-net-this-kasan-gce 2022/04/18 16:18 net d94ef51d5b96 8bcc32a6 .config log report info KASAN: use-after-free Write in sco_sock_timeout
ci-upstream-net-this-kasan-gce 2022/04/14 18:02 net 00fa91bc9cc2 b17b2923 .config log report info KASAN: use-after-free Write in sco_sock_timeout
ci-upstream-net-this-kasan-gce 2022/03/21 21:55 net ed32641e06c6 e2d91b1d .config log report info KASAN: use-after-free Write in sco_sock_timeout
ci-upstream-net-this-kasan-gce 2022/03/19 07:09 net 6bd0c76bd704 e2d91b1d .config log report info KASAN: use-after-free Write in sco_sock_timeout
ci-upstream-net-this-kasan-gce 2022/03/18 02:23 net cb0b430b4e3a e2d91b1d .config log report info KASAN: use-after-free Write in sco_sock_timeout
ci-upstream-net-this-kasan-gce 2022/03/17 20:36 net cb0b430b4e3a e2d91b1d .config log report info KASAN: use-after-free Write in sco_sock_timeout
ci-upstream-net-this-kasan-gce 2022/03/08 09:59 net c70c453abcbf 7bdd8b2c .config log report info KASAN: use-after-free Write in sco_sock_timeout
ci-upstream-net-this-kasan-gce 2022/03/04 05:57 net b949c21fc23e 45a13a73 .config log report info KASAN: use-after-free Write in sco_sock_timeout
ci-upstream-net-kasan-gce 2022/05/20 20:44 net-next b6d261449e6e bd37ad7e .config log report info KASAN: use-after-free Write in sco_sock_timeout
ci-upstream-net-kasan-gce 2022/04/20 08:31 net-next cc4bdef26ecd 7d7bc738 .config log report info KASAN: use-after-free Write in sco_sock_timeout
ci-upstream-net-kasan-gce 2022/04/18 14:04 net-next 843f77407eeb 8bcc32a6 .config log report info KASAN: use-after-free Write in sco_sock_timeout
ci-upstream-net-kasan-gce 2022/04/17 07:28 net-next 0339d25a2807 8bcc32a6 .config log report info KASAN: use-after-free Write in sco_sock_timeout
ci-upstream-net-kasan-gce 2022/04/16 23:37 net-next 0339d25a2807 8bcc32a6 .config log report info KASAN: use-after-free Write in sco_sock_timeout
ci-upstream-net-kasan-gce 2022/04/16 09:41 net-next 0339d25a2807 8bcc32a6 .config log report info KASAN: use-after-free Write in sco_sock_timeout
ci-upstream-net-kasan-gce 2022/04/03 11:10 net-next 2975dbdc3989 79a2a8fc .config log report info KASAN: use-after-free Write in sco_sock_timeout
ci-upstream-net-kasan-gce 2022/03/30 11:09 net-next d717e4cae0fe 6bdac766 .config log report info KASAN: use-after-free Write in sco_sock_timeout
ci-upstream-net-kasan-gce 2022/03/28 23:23 net-next 169e77764adc ee339263 .config log report info KASAN: use-after-free Write in sco_sock_timeout
ci-upstream-net-kasan-gce 2022/03/25 01:45 net-next 169e77764adc 89bc8608 .config log report info KASAN: use-after-free Write in sco_sock_timeout
ci-upstream-net-kasan-gce 2022/03/01 09:00 net-next f2b77012ddd5 45a13a73 .config log report info KASAN: use-after-free Write in sco_sock_timeout
ci-upstream-net-kasan-gce 2021/08/24 12:27 net-next faf482ca196a b599f2fc .config log report info KASAN: use-after-free Write in sco_sock_timeout
ci-upstream-linux-next-kasan-gce-root 2022/03/02 23:49 linux-next e6ada6df471f 45a13a73 .config log report info KASAN: use-after-free Write in sco_sock_timeout
ci-upstream-net-kasan-gce 2022/05/14 19:48 net-next d9713088158b 744a39e2 .config log report info KASAN: slab-out-of-bounds Write in sco_sock_timeout