syzbot


KMSAN: use-after-free in copyout

Status: fixed on 2019/12/13 00:31
Subsystems: net
[Documentation on labels]
Fix commit: cf94da6f502d Bluetooth: Fix invalid-free in bcsp_close()
First crash: 1716d, last: 1716d

Sample crash report:
=====================================================
BUG: KMSAN: use-after-free in copyout+0x16b/0x1f0 lib/iov_iter.c:145
CPU: 1 PID: 5280 Comm: udevd Not tainted 5.3.0-rc7+ #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+0x191/0x1f0 lib/dump_stack.c:113
 kmsan_report+0x17d/0x2f0 mm/kmsan/kmsan_report.c:114
 kmsan_internal_check_memory+0x3bb/0x4c0 mm/kmsan/kmsan.c:475
 kmsan_copy_to_user+0xa9/0xb0 mm/kmsan/kmsan_hooks.c:268
 copyout+0x16b/0x1f0 lib/iov_iter.c:145
 _copy_to_iter+0x366/0x26e0 lib/iov_iter.c:616
 copy_to_iter include/linux/uio.h:138 [inline]
 simple_copy_to_iter+0x92/0xb0 net/core/datagram.c:515
 __skb_datagram_iter+0x257/0xf00 net/core/datagram.c:423
 skb_copy_datagram_iter+0x29c/0x2b0 net/core/datagram.c:529
 skb_copy_datagram_msg include/linux/skbuff.h:3429 [inline]
 netlink_recvmsg+0x68c/0x18e0 net/netlink/af_netlink.c:1975
 sock_recvmsg_nosec net/socket.c:871 [inline]
 sock_recvmsg+0x3b3/0x3c0 net/socket.c:889
 ___sys_recvmsg+0x461/0x11e0 net/socket.c:2480
 __sys_recvmsg net/socket.c:2537 [inline]
 __do_sys_recvmsg net/socket.c:2547 [inline]
 __se_sys_recvmsg+0x2fa/0x450 net/socket.c:2544
 __x64_sys_recvmsg+0x4a/0x70 net/socket.c:2544
 do_syscall_64+0xbc/0xf0 arch/x86/entry/common.c:297
 entry_SYSCALL_64_after_hwframe+0x63/0xe7
RIP: 0033:0x7fe836bf4210
Code: 31 d2 48 29 c2 64 89 11 48 83 c8 ff eb ea 90 90 90 90 90 90 90 90 90 90 90 90 83 3d e5 d3 2a 00 00 75 10 b8 2f 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 31 c3 48 83 ec 08 e8 6e bb 00 00 48 89 04 24
RSP: 002b:00007ffd65c95c28 EFLAGS: 00000246 ORIG_RAX: 000000000000002f
RAX: ffffffffffffffda RBX: 0000000000000001 RCX: 00007fe836bf4210
RDX: 0000000000000000 RSI: 00007ffd65c95c90 RDI: 0000000000000004
RBP: 0000000001021f80 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000040 R11: 0000000000000246 R12: 00007ffd65c95cf0
R13: 0000000000000000 R14: 000000000100d2d0 R15: 000000000100d250

Uninit was created at:
 kmsan_save_stack_with_flags mm/kmsan/kmsan.c:154 [inline]
 kmsan_internal_poison_shadow+0x60/0x120 mm/kmsan/kmsan.c:137
 kmsan_slab_free+0x8d/0x100 mm/kmsan/kmsan_hooks.c:123
 slab_free_freelist_hook mm/slub.c:1472 [inline]
 slab_free mm/slub.c:3038 [inline]
 kfree+0x4c1/0x2db0 mm/slub.c:3980
 skb_free_head net/core/skbuff.c:591 [inline]
 skb_release_data+0x7de/0x9d0 net/core/skbuff.c:611
 skb_release_all net/core/skbuff.c:665 [inline]
 __kfree_skb net/core/skbuff.c:679 [inline]
 kfree_skb+0x322/0x4c0 net/core/skbuff.c:697
 bcsp_close+0x127/0x1e0 drivers/bluetooth/hci_bcsp.c:748
 hci_uart_tty_close+0x385/0x410 drivers/bluetooth/hci_ldisc.c:548
 tty_ldisc_close drivers/tty/tty_ldisc.c:494 [inline]
 tty_ldisc_kill drivers/tty/tty_ldisc.c:642 [inline]
 tty_ldisc_release+0x5dd/0xdb0 drivers/tty/tty_ldisc.c:814
 tty_release_struct+0x4f/0x1d0 drivers/tty/tty_io.c:1612
 tty_release+0x1be2/0x1e80 drivers/tty/tty_io.c:1785
 __fput+0x4c9/0xba0 fs/file_table.c:280
 ____fput+0x37/0x40 fs/file_table.c:313
 task_work_run+0x22e/0x2a0 kernel/task_work.c:113
 exit_task_work include/linux/task_work.h:22 [inline]
 do_exit+0xf29/0x3aa0 kernel/exit.c:881
 do_group_exit+0x18a/0x320 kernel/exit.c:985
 __do_sys_exit_group+0x21/0x30 kernel/exit.c:996
 __se_sys_exit_group+0x14/0x20 kernel/exit.c:994
 __x64_sys_exit_group+0x1d/0x20 kernel/exit.c:994
 do_syscall_64+0xbc/0xf0 arch/x86/entry/common.c:297
 entry_SYSCALL_64_after_hwframe+0x63/0xe7

Bytes 8-137 of 138 are uninitialized
Memory access of size 138 starts at ffff88810ab4e000
=====================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2019/10/08 21:09 https://github.com/google/kmsan.git master cebb918b7474 b1ebbfef .config console log report syz C ci-upstream-kmsan-gce
* Struck through repros no longer work on HEAD.