syzbot


linux-next test error: KASAN: use-after-free Read in l2cap_sock_release

Status: fixed on 2020/05/10 10:41
Subsystems: bluetooth
[Documentation on labels]
Reported-by: syzbot+c3c5bdea7863886115dc@syzkaller.appspotmail.com
Fix commit: 2a154903cec2 Bluetooth: prefetch channel before killing sock
First crash: 1603d, last: 1601d
Discussions (13)
Title Replies (including bot) Last reply
[PATCH 4.19 000/245] 4.19.149-rc1 review 255 (255) 2020/10/01 11:14
[PATCH 4.9 000/121] 4.9.238-rc1 review 128 (128) 2020/10/01 09:01
[PATCH 4.4 00/85] 4.4.238-rc1 review 90 (90) 2020/10/01 01:45
[PATCH 4.14 000/166] 4.14.200-rc1 review 170 (170) 2020/10/01 01:33
[PATCH 5.4 000/388] 5.4.69-rc1 review 392 (392) 2020/09/30 14:29
[PATCH AUTOSEL 4.9 01/90] scsi: aacraid: fix illegal IO beyond last LBA 95 (95) 2020/09/29 17:39
[PATCH AUTOSEL 4.14 001/127] mm: fix double page fault on arm64 if PTE_AF is cleared 129 (129) 2020/09/28 22:01
[PATCH AUTOSEL 4.4 01/64] scsi: aacraid: fix illegal IO beyond last LBA 66 (66) 2020/09/28 22:00
[PATCH AUTOSEL 5.4 001/330] drm/v3d: don't leak bin job if v3d_job_init fails. 341 (341) 2020/09/24 20:54
[PATCH AUTOSEL 4.19 001/206] selinux: allow labeling before policy is loaded 208 (208) 2020/09/18 18:46
Re: [PATCH] Bluetooth: prefetch channel before killing sock 1 (1) 2020/02/05 08:06
Re: KASAN: use-after-free Read in l2cap_sock_release 1 (1) 2020/02/04 14:59
linux-next test error: KASAN: use-after-free Read in l2cap_sock_release 0 (1) 2020/02/03 19:38

Sample crash report:
can: request_module (can-proto-0) failed.
can: request_module (can-proto-0) failed.
can: request_module (can-proto-0) failed.
==================================================================
BUG: KASAN: use-after-free in l2cap_sock_release+0x24c/0x290 net/bluetooth/l2cap_sock.c:1212
Read of size 8 at addr ffff88809eaa34a0 by task syz-fuzzer/10009

CPU: 0 PID: 10009 Comm: syz-fuzzer Not tainted 5.5.0-next-20200205-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+0x197/0x210 lib/dump_stack.c:118
 print_address_description.constprop.0.cold+0xd4/0x30b mm/kasan/report.c:374
 __kasan_report.cold+0x1b/0x32 mm/kasan/report.c:506
 kasan_report+0x12/0x20 mm/kasan/common.c:641
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/generic_report.c:135
 l2cap_sock_release+0x24c/0x290 net/bluetooth/l2cap_sock.c:1212
 __sock_release+0xce/0x280 net/socket.c:605
 sock_close+0x1e/0x30 net/socket.c:1283
 __fput+0x2ff/0x890 fs/file_table.c:280
 ____fput+0x16/0x20 fs/file_table.c:313
 task_work_run+0x145/0x1c0 kernel/task_work.c:113
 tracehook_notify_resume include/linux/tracehook.h:188 [inline]
 exit_to_usermode_loop+0x316/0x380 arch/x86/entry/common.c:164
 prepare_exit_to_usermode arch/x86/entry/common.c:195 [inline]
 syscall_return_slowpath arch/x86/entry/common.c:278 [inline]
 do_syscall_64+0x676/0x790 arch/x86/entry/common.c:304
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x4afb40
Code: 8b 7c 24 10 48 8b 74 24 18 48 8b 54 24 20 49 c7 c2 00 00 00 00 49 c7 c0 00 00 00 00 49 c7 c1 00 00 00 00 48 8b 44 24 08 0f 05 <48> 3d 01 f0 ff ff 76 20 48 c7 44 24 28 ff ff ff ff 48 c7 44 24 30
RSP: 002b:000000c0001ed540 EFLAGS: 00000202 ORIG_RAX: 0000000000000003
RAX: 0000000000000000 RBX: 000000c00002c000 RCX: 00000000004afb40
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000003
RBP: 000000c0001ed580 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000202 R12: 00000000000000cc
R13: 00000000000000cb R14: 0000000000000200 R15: 0000000000000200

Allocated by task 10009:
 save_stack+0x23/0x90 mm/kasan/common.c:72
 set_track mm/kasan/common.c:80 [inline]
 __kasan_kmalloc mm/kasan/common.c:515 [inline]
 __kasan_kmalloc.constprop.0+0xcf/0xe0 mm/kasan/common.c:488
 kasan_kmalloc+0x9/0x10 mm/kasan/common.c:529
 __do_kmalloc mm/slab.c:3656 [inline]
 __kmalloc+0x163/0x770 mm/slab.c:3665
 kmalloc include/linux/slab.h:560 [inline]
 sk_prot_alloc+0x23a/0x310 net/core/sock.c:1603
 sk_alloc+0x39/0xfd0 net/core/sock.c:1657
 l2cap_sock_alloc.constprop.0+0x37/0x230 net/bluetooth/l2cap_sock.c:1603
 l2cap_sock_create+0x11e/0x1c0 net/bluetooth/l2cap_sock.c:1649
 bt_sock_create+0x16a/0x2d0 net/bluetooth/af_bluetooth.c:130
 __sock_create+0x3ce/0x730 net/socket.c:1433
 sock_create net/socket.c:1484 [inline]
 __sys_socket+0x103/0x220 net/socket.c:1526
 __do_sys_socket net/socket.c:1535 [inline]
 __se_sys_socket net/socket.c:1533 [inline]
 __x64_sys_socket+0x73/0xb0 net/socket.c:1533
 do_syscall_64+0xfa/0x790 arch/x86/entry/common.c:294
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 10009:
 save_stack+0x23/0x90 mm/kasan/common.c:72
 set_track mm/kasan/common.c:80 [inline]
 kasan_set_free_info mm/kasan/common.c:337 [inline]
 __kasan_slab_free+0x102/0x150 mm/kasan/common.c:476
 kasan_slab_free+0xe/0x10 mm/kasan/common.c:485
 __cache_free mm/slab.c:3426 [inline]
 kfree+0x10a/0x2c0 mm/slab.c:3757
 sk_prot_free net/core/sock.c:1640 [inline]
 __sk_destruct+0x5d8/0x7f0 net/core/sock.c:1724
 sk_destruct+0xd5/0x110 net/core/sock.c:1739
 __sk_free+0xfb/0x3f0 net/core/sock.c:1750
 sk_free+0x83/0xb0 net/core/sock.c:1761
 sock_put include/net/sock.h:1719 [inline]
 l2cap_sock_kill+0x160/0x190 net/bluetooth/l2cap_sock.c:1058
 l2cap_sock_release+0x1c3/0x290 net/bluetooth/l2cap_sock.c:1210
 __sock_release+0xce/0x280 net/socket.c:605
 sock_close+0x1e/0x30 net/socket.c:1283
 __fput+0x2ff/0x890 fs/file_table.c:280
 ____fput+0x16/0x20 fs/file_table.c:313
 task_work_run+0x145/0x1c0 kernel/task_work.c:113
 tracehook_notify_resume include/linux/tracehook.h:188 [inline]
 exit_to_usermode_loop+0x316/0x380 arch/x86/entry/common.c:164
 prepare_exit_to_usermode arch/x86/entry/common.c:195 [inline]
 syscall_return_slowpath arch/x86/entry/common.c:278 [inline]
 do_syscall_64+0x676/0x790 arch/x86/entry/common.c:304
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff88809eaa3000
 which belongs to the cache kmalloc-2k of size 2048
The buggy address is located 1184 bytes inside of
 2048-byte region [ffff88809eaa3000, ffff88809eaa3800)
The buggy address belongs to the page:
page:ffffea00027aa8c0 refcount:1 mapcount:0 mapping:ffff8880aa400e00 index:0x0
flags: 0xfffe0000000200(slab)
raw: 00fffe0000000200 ffffea00028121c8 ffffea00025315c8 ffff8880aa400e00
raw: 0000000000000000 ffff88809eaa3000 0000000100000001 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff88809eaa3380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88809eaa3400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88809eaa3480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                               ^
 ffff88809eaa3500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88809eaa3580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (12):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2020/02/05 13:47 linux-next 14b549456391 662cf49a .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/05 13:47 linux-next 14b549456391 662cf49a .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/05 13:47 linux-next 14b549456391 662cf49a .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/05 02:33 linux-next 14b549456391 93e5e335 .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/05 02:33 linux-next 14b549456391 93e5e335 .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/05 02:33 linux-next 14b549456391 93e5e335 .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/04 05:50 linux-next 03cd8b289266 93e5e335 .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/04 05:50 linux-next 03cd8b289266 93e5e335 .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/04 05:50 linux-next 03cd8b289266 93e5e335 .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/03 03:44 linux-next cee5a42837d4 93e5e335 .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/03 03:44 linux-next cee5a42837d4 93e5e335 .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/03 03:44 linux-next cee5a42837d4 93e5e335 .config console log report ci-upstream-linux-next-kasan-gce-root
* Struck through repros no longer work on HEAD.