KASAN: use-after-free Read in vhost_transport_send_pkt

Status: fixed on 2018/12/18 11:30
Fix commit: 834e772c8db0 vhost/vsock: fix use-after-free in network stack callers
First crash: 1432d, last: 1305d

Sample crash report:
IPv6: ADDRCONF(NETDEV_CHANGE): veth1: link becomes ready
IPv6: ADDRCONF(NETDEV_CHANGE): veth0: link becomes ready
8021q: adding VLAN 0 to HW filter on device team0
8021q: adding VLAN 0 to HW filter on device team0
BUG: KASAN: use-after-free in __lock_acquire+0x37c2/0x4ec0 kernel/locking/lockdep.c:3290
Read of size 8 at addr ffff8801a93ad1d0 by task syz-executor4/10978

CPU: 1 PID: 10978 Comm: syz-executor4 Not tainted 4.19.0-rc8+ #293
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+0x1c4/0x2b4 lib/dump_stack.c:113
 print_address_description.cold.8+0x9/0x1ff mm/kasan/report.c:256
 kasan_report_error mm/kasan/report.c:354 [inline]
 kasan_report.cold.9+0x242/0x309 mm/kasan/report.c:412
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:433
 __lock_acquire+0x37c2/0x4ec0 kernel/locking/lockdep.c:3290
 lock_acquire+0x1ed/0x520 kernel/locking/lockdep.c:3900
 __raw_spin_lock_bh include/linux/spinlock_api_smp.h:135 [inline]
 _raw_spin_lock_bh+0x31/0x40 kernel/locking/spinlock.c:168
 spin_lock_bh include/linux/spinlock.h:334 [inline]
 vhost_transport_send_pkt+0x12e/0x380 drivers/vhost/vsock.c:223
 virtio_transport_send_pkt_info+0x31d/0x460 net/vmw_vsock/virtio_transport_common.c:190
 virtio_transport_connect+0x17c/0x220 net/vmw_vsock/virtio_transport_common.c:588
 vsock_stream_connect+0x4ed/0xe40 net/vmw_vsock/af_vsock.c:1200
 __sys_connect+0x37d/0x4c0 net/socket.c:1664
 __do_sys_connect net/socket.c:1675 [inline]
 __se_sys_connect net/socket.c:1672 [inline]
 __x64_sys_connect+0x73/0xb0 net/socket.c:1672
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
RIP: 0033:0x457569
Code: fd b3 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 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 0f 83 cb b3 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007f5572f14c78 EFLAGS: 00000246 ORIG_RAX: 000000000000002a
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 0000000000457569
RDX: 0000000000000010 RSI: 0000000020000200 RDI: 0000000000000006
RBP: 000000000072bf00 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f5572f156d4
R13: 00000000004bdb06 R14: 00000000004cc658 R15: 00000000ffffffff

Allocated by task 10978:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 kasan_kmalloc+0xc7/0xe0 mm/kasan/kasan.c:553
 __do_kmalloc_node mm/slab.c:3682 [inline]
 __kmalloc_node+0x47/0x70 mm/slab.c:3689
 kmalloc_node include/linux/slab.h:555 [inline]
 kvmalloc_node+0xb9/0xf0 mm/util.c:423
 kvmalloc include/linux/mm.h:577 [inline]
 vhost_vsock_dev_open+0xa2/0x5a0 drivers/vhost/vsock.c:511
 misc_open+0x3ca/0x560 drivers/char/misc.c:141
 chrdev_open+0x25a/0x710 fs/char_dev.c:417
 do_dentry_open+0x499/0x1250 fs/open.c:771
 vfs_open+0xa0/0xd0 fs/open.c:880
 do_last fs/namei.c:3418 [inline]
 path_openat+0x12bf/0x5160 fs/namei.c:3534
 do_filp_open+0x255/0x380 fs/namei.c:3564
 do_sys_open+0x568/0x700 fs/open.c:1063
 __do_sys_openat fs/open.c:1090 [inline]
 __se_sys_openat fs/open.c:1084 [inline]
 __x64_sys_openat+0x9d/0x100 fs/open.c:1084
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290

Freed by task 10974:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 __kasan_slab_free+0x102/0x150 mm/kasan/kasan.c:521
 kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:528
 __cache_free mm/slab.c:3498 [inline]
 kfree+0xcf/0x230 mm/slab.c:3813
 kvfree+0x61/0x70 mm/util.c:452
 vhost_vsock_free drivers/vhost/vsock.c:499 [inline]
 vhost_vsock_dev_release+0x4f4/0x720 drivers/vhost/vsock.c:604
 __fput+0x385/0xa30 fs/file_table.c:278
 ____fput+0x15/0x20 fs/file_table.c:309
 task_work_run+0x1e8/0x2a0 kernel/task_work.c:113
 tracehook_notify_resume include/linux/tracehook.h:193 [inline]
 exit_to_usermode_loop+0x318/0x380 arch/x86/entry/common.c:166
 prepare_exit_to_usermode arch/x86/entry/common.c:197 [inline]
 syscall_return_slowpath arch/x86/entry/common.c:268 [inline]
 do_syscall_64+0x6be/0x820 arch/x86/entry/common.c:293

The buggy address belongs to the object at ffff8801a93a44c0
 which belongs to the cache kmalloc-65536 of size 65536
The buggy address is located 36112 bytes inside of
 65536-byte region [ffff8801a93a44c0, ffff8801a93b44c0)
The buggy address belongs to the page:
page:ffffea0006a4e800 count:1 mapcount:0 mapping:ffff8801da802500 index:0x0 compound_mapcount: 0
flags: 0x2fffc0000008100(slab|head)
kobject: 'loop0' (0000000014267a7b): kobject_uevent_env
raw: 02fffc0000008100 ffffea0006a45008 ffffea0006a4a808 ffff8801da802500
raw: 0000000000000000 ffff8801a93a44c0 0000000100000001 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8801a93ad080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
kobject: 'loop0' (0000000014267a7b): fill_kobj_path: path = '/devices/virtual/block/loop0'
 ffff8801a93ad100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8801a93ad180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8801a93ad200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8801a93ad280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb

Crashes (36):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-kasan-gce-root 2018/10/20 15:30 upstream 270b77a0f30e ecb386fe .config log report syz
ci-upstream-kasan-gce-smack-root 2018/10/13 13:21 upstream bab5c80b2110 caf12900 .config log report syz
ci-upstream-kasan-gce-selinux-root 2018/10/07 20:16 upstream fb1c592cf4c9 8b311eaf .config log report syz
ci-upstream-kasan-gce 2018/10/07 19:47 upstream fb1c592cf4c9 8b311eaf .config log report syz
ci-upstream-kasan-gce-root 2018/09/28 00:52 upstream c127e59bee3e 0c2fa87b .config log report syz
ci-upstream-kasan-gce-smack-root 2018/09/28 00:50 upstream c127e59bee3e 0c2fa87b .config log report syz
ci-upstream-kasan-gce 2018/09/28 00:23 upstream c127e59bee3e 0c2fa87b .config log report syz
ci-upstream-kasan-gce-root 2018/09/22 06:45 upstream 10dc890d4228 37079712 .config log report syz
ci-upstream-kasan-gce-386 2018/10/13 15:14 upstream bab5c80b2110 caf12900 .config log report syz
ci-upstream-kasan-gce-386 2018/09/28 02:04 upstream c127e59bee3e 0c2fa87b .config log report syz
ci-upstream-linux-next-kasan-gce-root 2018/10/14 09:39 linux-next 774ea0551a29 caf12900 .config log report syz
ci-upstream-linux-next-kasan-gce-root 2018/10/07 20:14 linux-next 12ffaa1197f5 8b311eaf .config log report syz
ci-upstream-kasan-gce-selinux-root 2018/12/03 23:14 upstream 0072a0c14d5b 03f94a45 .config log report
ci-upstream-kasan-gce-root 2018/11/21 11:43 upstream c8ce94b8fe53 5d9a3924 .config log report
ci-upstream-kasan-gce 2018/11/09 05:19 upstream 24ccea7e102d 8fd01d3a .config log report
ci-upstream-kasan-gce 2018/11/06 07:47 upstream 163c8d54a997 8bd6bd63 .config log report
ci-upstream-kasan-gce-root 2018/10/22 12:56 upstream 467e050e9760 ecb386fe .config log report
ci-upstream-kasan-gce-selinux-root 2018/10/18 03:00 upstream c343db455eb3 b2695b95 .config log report
ci-upstream-kasan-gce-selinux-root 2018/10/14 13:11 upstream 3a27203102eb caf12900 .config log report
ci-upstream-kasan-gce 2018/10/01 14:56 upstream 17b57b1883c1 48a50c6b .config log report
ci-upstream-kasan-gce-selinux-root 2018/09/14 23:55 upstream 090b75bcba62 a343a400 .config log report
ci-upstream-kasan-gce 2018/09/09 18:47 upstream 9a5682765a2e 6b5120a4 .config log report
ci-upstream-kasan-gce 2018/08/30 07:12 upstream ff69279a44e9 6c7e9d3d .config log report
ci-upstream-kasan-gce 2018/08/19 15:21 upstream 08b5fa819970 2dc4378f .config log report
ci-upstream-kasan-gce 2018/07/30 16:02 upstream acb1872577b3 1a381291 .config log report
ci-upstream-kasan-gce-386 2018/12/04 05:29 upstream 0072a0c14d5b 03f94a45 .config log report
ci-upstream-kasan-gce-386 2018/12/01 05:22 upstream b6839ef26e54 d8988561 .config log report
ci-upstream-kasan-gce-386 2018/11/24 15:23 upstream 7c98a4261827 ecc7c870 .config log report
ci-upstream-kasan-gce-386 2018/11/10 00:47 upstream 3541833fd1f2 f9815aaf .config log report
ci-upstream-kasan-gce-386 2018/11/08 22:16 upstream b00d209241ff e85d2a61 .config log report
ci-upstream-kasan-gce-386 2018/10/05 07:27 upstream befad944e231 8b311eaf .config log report
ci-upstream-linux-next-kasan-gce-root 2018/11/25 02:56 linux-next 442b8cea2477 ecc7c870 .config log report
ci-upstream-linux-next-kasan-gce-root 2018/11/03 14:21 linux-next 25e9471b6a27 8bd6bd63 .config log report
ci-upstream-linux-next-kasan-gce-root 2018/10/18 05:55 linux-next 4efacb725c0e b2695b95 .config log report
ci-upstream-linux-next-kasan-gce-root 2018/10/14 18:43 linux-next 774ea0551a29 caf12900 .config log report
ci-upstream-linux-next-kasan-gce-root 2018/09/22 13:00 linux-next 46c163a036b4 37079712 .config log report