syzbot


KASAN: use-after-free Write in sco_chan_del

Status: closed as dup on 2020/08/18 06:37
Subsystems: bluetooth
[Documentation on labels]
Reported-by: syzbot+8f6017ee5c7fb9515782@syzkaller.appspotmail.com
First crash: 1571d, last: 1563d
Cause bisection: introduced by (bisect log) [release commit]:
commit c8d2bc9bc39ebea8437fd974fdbc21847bb897a3
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date: Sun Oct 2 23:24:33 2016 +0000

  Linux 4.8

Crash: general protection fault in batadv_iv_ogm_queue_add (log)
Repro: C syz .config
  
Duplicate of
Title Repro Cause bisect Fix bisect Count Last Reported
KASAN: use-after-free Write in __sco_sock_close bluetooth C done done 10 1474d 1571d
Discussions (1)
Title Replies (including bot) Last reply
KASAN: use-after-free Write in sco_chan_del 0 (1) 2020/08/03 05:05
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.19 KASAN: use-after-free Write in sco_chan_del C done 10 1447d 1571d 1/1 fixed on 2021/01/04 20:45

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in instrument_atomic_write include/linux/instrumented.h:71 [inline]
BUG: KASAN: use-after-free in atomic_dec_and_test include/asm-generic/atomic-instrumented.h:748 [inline]
BUG: KASAN: use-after-free in hci_conn_drop include/net/bluetooth/hci_core.h:1116 [inline]
BUG: KASAN: use-after-free in sco_chan_del+0xe6/0x430 net/bluetooth/sco.c:149
Write of size 4 at addr ffff88808de9e010 by task syz-executor493/7011

CPU: 0 PID: 7011 Comm: syz-executor493 Not tainted 5.8.0-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x18f/0x20d lib/dump_stack.c:118
 print_address_description.constprop.0.cold+0xae/0x497 mm/kasan/report.c:383
 __kasan_report mm/kasan/report.c:513 [inline]
 kasan_report.cold+0x1f/0x37 mm/kasan/report.c:530
 check_memory_region_inline mm/kasan/generic.c:186 [inline]
 check_memory_region+0x13d/0x180 mm/kasan/generic.c:192
 instrument_atomic_write include/linux/instrumented.h:71 [inline]
 atomic_dec_and_test include/asm-generic/atomic-instrumented.h:748 [inline]
 hci_conn_drop include/net/bluetooth/hci_core.h:1116 [inline]
 sco_chan_del+0xe6/0x430 net/bluetooth/sco.c:149
 __sco_sock_close+0x16e/0x5b0 net/bluetooth/sco.c:434
 sco_sock_close net/bluetooth/sco.c:448 [inline]
 sco_sock_release+0x69/0x290 net/bluetooth/sco.c:1053
 __sock_release+0xcd/0x280 net/socket.c:596
 sock_close+0x18/0x20 net/socket.c:1277
 __fput+0x285/0x920 fs/file_table.c:281
 task_work_run+0xdd/0x190 kernel/task_work.c:135
 exit_task_work include/linux/task_work.h:25 [inline]
 do_exit+0xb7d/0x29f0 kernel/exit.c:806
 do_group_exit+0x125/0x310 kernel/exit.c:903
 get_signal+0x40b/0x1ee0 kernel/signal.c:2743
 arch_do_signal+0x82/0x2520 arch/x86/kernel/signal.c:811
 exit_to_user_mode_loop kernel/entry/common.c:135 [inline]
 exit_to_user_mode_prepare+0x172/0x1d0 kernel/entry/common.c:166
 syscall_exit_to_user_mode+0x59/0x2b0 kernel/entry/common.c:241
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x446eb9
Code: Bad RIP value.
RSP: 002b:00007ffd4bc66bd8 EFLAGS: 00000246 ORIG_RAX: 000000000000002a
RAX: fffffffffffffffc RBX: 0000000000000003 RCX: 0000000000446eb9
RDX: 0000000000000008 RSI: 00000000200000c0 RDI: 0000000000000004
RBP: 0000000000000004 R08: 0000000000000002 R09: 00000000000400ff
R10: 0000000000000004 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000407b10 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 7011:
 kasan_save_stack+0x1b/0x40 mm/kasan/common.c:48
 kasan_set_track mm/kasan/common.c:56 [inline]
 __kasan_kmalloc.constprop.0+0xbf/0xd0 mm/kasan/common.c:461
 kmem_cache_alloc_trace+0x16e/0x2c0 mm/slab.c:3550
 kmalloc include/linux/slab.h:554 [inline]
 kzalloc include/linux/slab.h:666 [inline]
 hci_conn_add+0x53/0x1330 net/bluetooth/hci_conn.c:525
 hci_connect_sco+0x356/0x860 net/bluetooth/hci_conn.c:1283
 sco_connect net/bluetooth/sco.c:241 [inline]
 sco_sock_connect+0x308/0x980 net/bluetooth/sco.c:588
 __sys_connect_file+0x155/0x1a0 net/socket.c:1853
 __sys_connect+0x160/0x190 net/socket.c:1870
 __do_sys_connect net/socket.c:1881 [inline]
 __se_sys_connect net/socket.c:1878 [inline]
 __x64_sys_connect+0x6f/0xb0 net/socket.c:1878
 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

Freed by task 7009:
 kasan_save_stack+0x1b/0x40 mm/kasan/common.c:48
 kasan_set_track+0x1c/0x30 mm/kasan/common.c:56
 kasan_set_free_info+0x1b/0x30 mm/kasan/generic.c:355
 __kasan_slab_free+0xd8/0x120 mm/kasan/common.c:422
 __cache_free mm/slab.c:3418 [inline]
 kfree+0x103/0x2c0 mm/slab.c:3756
 device_release+0x71/0x200 drivers/base/core.c:1800
 kobject_cleanup lib/kobject.c:704 [inline]
 kobject_release lib/kobject.c:735 [inline]
 kref_put include/linux/kref.h:65 [inline]
 kobject_put+0x171/0x270 lib/kobject.c:752
 put_device+0x1b/0x30 drivers/base/core.c:3029
 hci_conn_del+0x27e/0x6a0 net/bluetooth/hci_conn.c:645
 hci_phy_link_complete_evt.isra.0+0x508/0x790 net/bluetooth/hci_event.c:4940
 hci_event_packet+0x4696/0x87a8 net/bluetooth/hci_event.c:6205
 hci_rx_work+0x22e/0xb50 net/bluetooth/hci_core.c:4889
 process_one_work+0x94c/0x1670 kernel/workqueue.c:2269
 worker_thread+0x64c/0x1120 kernel/workqueue.c:2415
 kthread+0x3b5/0x4a0 kernel/kthread.c:292
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294

The buggy address belongs to the object at ffff88808de9e000
 which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 16 bytes inside of
 4096-byte region [ffff88808de9e000, ffff88808de9f000)
The buggy address belongs to the page:
page:00000000c09a5339 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x8de9e
head:00000000c09a5339 order:1 compound_mapcount:0
flags: 0xfffe0000010200(slab|head)
raw: 00fffe0000010200 ffffea000223aa08 ffffea000250f288 ffff8880aa040900
raw: 0000000000000000 ffff88808de9e000 0000000100000001 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff88808de9df00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff88808de9df80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88808de9e000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                         ^
 ffff88808de9e080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88808de9e100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (29):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2020/08/08 20:55 upstream 449dc8c97089 f721e4a0 .config console log report syz C ci-upstream-kasan-gce-root
2020/08/08 19:14 upstream 449dc8c97089 f721e4a0 .config console log report syz C ci-upstream-kasan-gce-root
2020/08/07 16:50 upstream d6efb3ac3e6c cb436c69 .config console log report syz C ci-upstream-kasan-gce-root
2020/08/07 16:10 upstream d6efb3ac3e6c cb436c69 .config console log report syz C ci-upstream-kasan-gce-root
2020/08/07 05:00 upstream 47ec5303d73e 1f122f88 .config console log report syz C ci-upstream-kasan-gce-selinux-root
2020/08/07 03:20 upstream 47ec5303d73e 1f122f88 .config console log report syz C ci-upstream-kasan-gce-selinux-root
2020/08/06 20:25 upstream 47ec5303d73e 1f122f88 .config console log report syz C ci-upstream-kasan-gce-root
2020/08/06 17:16 upstream 47ec5303d73e 1f122f88 .config console log report syz C ci-upstream-kasan-gce-selinux-root
2020/08/06 17:09 upstream 47ec5303d73e 1f122f88 .config console log report syz C ci-upstream-kasan-gce-root
2020/08/06 16:36 upstream 47ec5303d73e 1f122f88 .config console log report syz C ci-upstream-kasan-gce-selinux-root
2020/08/06 03:18 upstream fffe3ae0ee84 0487ea6f .config console log report syz C ci-upstream-kasan-gce-root
2020/08/05 18:56 upstream 442489c21923 b7129355 .config console log report syz C ci-upstream-kasan-gce-root
2020/08/05 16:15 upstream 442489c21923 b7129355 .config console log report syz C ci-upstream-kasan-gce-root
2020/08/05 13:11 upstream 442489c21923 b7129355 .config console log report syz C ci-upstream-kasan-gce-selinux-root
2020/08/05 05:29 upstream c0842fbc1b18 80a06902 .config console log report syz C ci-upstream-kasan-gce-selinux-root
2020/08/04 17:46 upstream c0842fbc1b18 80a06902 .config console log report syz C ci-upstream-kasan-gce-selinux-root
2020/08/04 17:08 upstream c0842fbc1b18 80a06902 .config console log report syz C ci-upstream-kasan-gce-root
2020/08/03 23:23 upstream bcf876870b95 196277c4 .config console log report syz C ci-upstream-kasan-gce-selinux-root
2020/08/03 20:36 upstream bcf876870b95 196277c4 .config console log report syz C ci-upstream-kasan-gce-selinux-root
2020/08/02 23:15 upstream ac3a0c847296 63a73341 .config console log report syz C ci-upstream-kasan-gce-selinux-root
2020/08/11 00:10 linux-next f80535b9aa10 7adc7b65 .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2020/08/10 19:37 linux-next f80535b9aa10 7adc7b65 .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2020/08/10 05:10 linux-next 01830e6c042e 70301872 .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2020/08/10 04:30 linux-next 01830e6c042e 70301872 .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2020/08/09 03:18 linux-next 01830e6c042e f721e4a0 .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2020/08/08 22:52 linux-next 01830e6c042e f721e4a0 .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2020/08/08 02:16 linux-next 01830e6c042e cb436c69 .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2020/08/07 16:09 linux-next 01830e6c042e cb436c69 .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2020/08/06 18:54 linux-next 01830e6c042e 1f122f88 .config console log report syz C ci-upstream-linux-next-kasan-gce-root
* Struck through repros no longer work on HEAD.