syzbot


KMSAN: use-after-free in sk_forced_mem_schedule

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: 1676d, last: 1668d

Sample crash report:
=====================================================
BUG: KMSAN: use-after-free in sk_forced_mem_schedule+0x1bd/0x2d0 net/ipv4/tcp_output.c:3108
CPU: 1 PID: 11836 Comm: syz-fuzzer Not tainted 5.4.0-rc5+ #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+0x128/0x220 mm/kmsan/kmsan_report.c:108
 __msan_warning+0x73/0xe0 mm/kmsan/kmsan_instr.c:245
 sk_forced_mem_schedule+0x1bd/0x2d0 net/ipv4/tcp_output.c:3108
 sk_stream_alloc_skb+0x3ed/0x1110 net/ipv4/tcp.c:883
 tcp_sendmsg_locked+0x1f95/0x6a00 net/ipv4/tcp.c:1285
 tcp_sendmsg+0xb2/0x100 net/ipv4/tcp.c:1436
 inet_sendmsg+0x178/0x2e0 net/ipv4/af_inet.c:807
 sock_sendmsg_nosec net/socket.c:637 [inline]
 sock_sendmsg net/socket.c:657 [inline]
 sock_write_iter+0x599/0x650 net/socket.c:989
 call_write_iter include/linux/fs.h:1895 [inline]
 new_sync_write fs/read_write.c:483 [inline]
 __vfs_write+0xa2c/0xcb0 fs/read_write.c:496
 vfs_write+0x481/0x920 fs/read_write.c:558
 ksys_write+0x265/0x430 fs/read_write.c:611
 __do_sys_write fs/read_write.c:623 [inline]
 __se_sys_write+0x92/0xb0 fs/read_write.c:620
 __x64_sys_write+0x4a/0x70 fs/read_write.c:620
 do_syscall_64+0xb6/0x160 arch/x86/entry/common.c:291
 entry_SYSCALL_64_after_hwframe+0x63/0xe7
RIP: 0033:0x47fd44
Code: ff ff cc cc cc cc e8 9b 40 fb ff 48 8b 7c 24 10 48 8b 74 24 18 48 8b 54 24 20 45 31 d2 45 31 c0 45 31 c9 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:000000c420357318 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 000000000047fd44
RDX: 0000000000000025 RSI: 000000c420360020 RDI: 0000000000000003
RBP: 000000c420357368 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 000000c42005e2c0
R13: 000000000000000f R14: 0000000000c36920 R15: ffffffffffffffff

Uninit was stored to memory at:
 kmsan_save_stack_with_flags mm/kmsan/kmsan.c:151 [inline]
 kmsan_internal_chain_origin+0xbd/0x180 mm/kmsan/kmsan.c:319
 __msan_chain_origin+0x6b/0xd0 mm/kmsan/kmsan_instr.c:179
 sk_mem_uncharge include/net/sock.h:1458 [inline]
 sock_rfree+0x219/0x2b0 net/core/sock.c:2051
 skb_release_head_state+0x16a/0x5e0 net/core/skbuff.c:652
 skb_release_all net/core/skbuff.c:663 [inline]
 __kfree_skb net/core/skbuff.c:679 [inline]
 kfree_skb+0x2cf/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/0xd50 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+0xef9/0x3a70 kernel/exit.c:819
 do_group_exit+0x18a/0x320 kernel/exit.c:923
 get_signal+0xbf6/0x32f0 kernel/signal.c:2734
 do_signal+0x6f/0xe10 arch/x86/kernel/signal.c:815
 exit_to_usermode_loop arch/x86/entry/common.c:159 [inline]
 prepare_exit_to_usermode+0x2c5/0x4d0 arch/x86/entry/common.c:194
 syscall_return_slowpath+0x90/0x610 arch/x86/entry/common.c:274
 do_syscall_64+0xdc/0x160 arch/x86/entry/common.c:301
 entry_SYSCALL_64_after_hwframe+0x63/0xe7

Uninit was created at:
 kmsan_save_stack_with_flags mm/kmsan/kmsan.c:151 [inline]
 kmsan_internal_poison_shadow+0x60/0x120 mm/kmsan/kmsan.c:134
 kmsan_slab_free+0x8d/0xf0 mm/kmsan/kmsan_hooks.c:108
 slab_free_freelist_hook mm/slub.c:1473 [inline]
 slab_free mm/slub.c:3046 [inline]
 kmem_cache_free+0x2d1/0x2b70 mm/slub.c:3062
 kfree_skbmem net/core/skbuff.c:644 [inline]
 __kfree_skb+0x1dd/0x210 net/core/skbuff.c:680
 sk_eat_skb include/net/sock.h:2459 [inline]
 tcp_recvmsg+0x27a6/0x4ff0 net/ipv4/tcp.c:2166
 inet_recvmsg+0x237/0x7d0 net/ipv4/af_inet.c:838
 sock_recvmsg_nosec net/socket.c:871 [inline]
 sock_recvmsg net/socket.c:889 [inline]
 sock_read_iter+0x5be/0x660 net/socket.c:967
 call_read_iter include/linux/fs.h:1889 [inline]
 new_sync_read fs/read_write.c:414 [inline]
 __vfs_read+0xa67/0xc90 fs/read_write.c:427
 vfs_read+0x359/0x6f0 fs/read_write.c:461
 ksys_read+0x265/0x430 fs/read_write.c:587
 __do_sys_read fs/read_write.c:597 [inline]
 __se_sys_read+0x92/0xb0 fs/read_write.c:595
 __x64_sys_read+0x4a/0x70 fs/read_write.c:595
 do_syscall_64+0xb6/0x160 arch/x86/entry/common.c:291
 entry_SYSCALL_64_after_hwframe+0x63/0xe7
=====================================================

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2019/11/20 00:07 https://github.com/google/kmsan.git master 9c6a71628ab9 5bc70212 .config console log report ci-upstream-kmsan-gce
2019/11/12 03:57 https://github.com/google/kmsan.git master e741088f2efa 048f2d49 .config console log report ci-upstream-kmsan-gce
* Struck through repros no longer work on HEAD.