syzbot


KASAN: use-after-free Read in strp_data_ready

Status: fixed on 2018/03/12 10:10
Subsystems: net
[Documentation on labels]
Reported-by: syzbot+d65446dfccfeeedc946b8511903687fe9f2d327a@syzkaller.appspotmail.com
Fix commit: 581e7226a5d4 kcm: Only allow TCP sockets to be attached to a KCM mux
First crash: 2382d, last: 2284d

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in strp_data_ready+0x232/0x2a0 net/strparser/strparser.c:394
Read of size 1 at addr ffff8801c2fc7bd0 by task syzkaller988249/4653

CPU: 1 PID: 4653 Comm: syzkaller988249 Not tainted 4.15.0-rc7+ #191
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 <IRQ>
 __dump_stack lib/dump_stack.c:17 [inline]
 dump_stack+0x194/0x257 lib/dump_stack.c:53
 print_address_description+0x73/0x250 mm/kasan/report.c:252
 kasan_report_error mm/kasan/report.c:351 [inline]
 kasan_report+0x25b/0x340 mm/kasan/report.c:409
 __asan_report_load1_noabort+0x14/0x20 mm/kasan/report.c:427
 strp_data_ready+0x232/0x2a0 net/strparser/strparser.c:394
 psock_data_ready+0x56/0x70 net/kcm/kcmsock.c:353
 dccp_enqueue_skb+0x3c4/0x4f0 net/dccp/input.c:31
 dccp_fin net/dccp/input.c:44 [inline]
 dccp_rcv_close+0x2d8/0x3e0 net/dccp/input.c:81
 __dccp_rcv_established.isra.5+0x2d0/0x370 net/dccp/input.c:320
 dccp_rcv_established+0x93/0xb0 net/dccp/input.c:380
 dccp_v6_do_rcv+0x281/0x9c0 net/dccp/ipv6.c:605
 sk_backlog_rcv include/net/sock.h:908 [inline]
 __sk_receive_skb+0x33e/0xc10 net/core/sock.c:513
 dccp_v6_rcv+0xab0/0x1be0 net/dccp/ipv6.c:774
 ip6_input_finish+0x37e/0x17a0 net/ipv6/ip6_input.c:284
 NF_HOOK include/linux/netfilter.h:288 [inline]
 ip6_input+0xdb/0x560 net/ipv6/ip6_input.c:327
 dst_input include/net/dst.h:449 [inline]
 ip6_rcv_finish+0x1a9/0x7a0 net/ipv6/ip6_input.c:71
 NF_HOOK include/linux/netfilter.h:288 [inline]
 ipv6_rcv+0xf37/0x1fa0 net/ipv6/ip6_input.c:208
 __netif_receive_skb_core+0x1a41/0x3460 net/core/dev.c:4537
 __netif_receive_skb+0x2c/0x1b0 net/core/dev.c:4602
 process_backlog+0x203/0x740 net/core/dev.c:5282
 napi_poll net/core/dev.c:5680 [inline]
 net_rx_action+0x792/0x1910 net/core/dev.c:5746
 __do_softirq+0x2d7/0xb85 kernel/softirq.c:285
 do_softirq_own_stack+0x2a/0x40 arch/x86/entry/entry_64.S:1133
 </IRQ>
 do_softirq.part.21+0x14d/0x190 kernel/softirq.c:329
 do_softirq kernel/softirq.c:177 [inline]
 __local_bh_enable_ip+0x1ee/0x230 kernel/softirq.c:182
 local_bh_enable include/linux/bottom_half.h:32 [inline]
 rcu_read_unlock_bh include/linux/rcupdate.h:727 [inline]
 ip6_finish_output2+0xba0/0x23a0 net/ipv6/ip6_output.c:121
 ip6_finish_output+0x698/0xaf0 net/ipv6/ip6_output.c:154
 NF_HOOK_COND include/linux/netfilter.h:277 [inline]
 ip6_output+0x1eb/0x840 net/ipv6/ip6_output.c:171
 dst_output include/net/dst.h:443 [inline]
 NF_HOOK include/linux/netfilter.h:288 [inline]
 ip6_xmit+0xd84/0x2090 net/ipv6/ip6_output.c:277
 inet6_csk_xmit+0x2fc/0x580 net/ipv6/inet6_connection_sock.c:139
 dccp_transmit_skb+0x9ac/0x10f0 net/dccp/output.c:142
 dccp_send_close+0x1e3/0x380 net/dccp/output.c:703
 dccp_terminate_connection net/dccp/proto.c:984 [inline]
 dccp_close+0x8bc/0xc20 net/dccp/proto.c:1047
 inet_release+0xed/0x1c0 net/ipv4/af_inet.c:427
 inet6_release+0x50/0x70 net/ipv6/af_inet6.c:432
 sock_release+0x8d/0x1e0 net/socket.c:595
 sock_close+0x16/0x20 net/socket.c:1123
 __fput+0x327/0x7e0 fs/file_table.c:210
 ____fput+0x15/0x20 fs/file_table.c:244
 task_work_run+0x199/0x270 kernel/task_work.c:113
 exit_task_work include/linux/task_work.h:22 [inline]
 do_exit+0x9bb/0x1ad0 kernel/exit.c:865
 do_group_exit+0x149/0x400 kernel/exit.c:968
 get_signal+0x73f/0x16c0 kernel/signal.c:2335
 do_signal+0x90/0x1eb0 arch/x86/kernel/signal.c:809
 exit_to_usermode_loop+0x214/0x310 arch/x86/entry/common.c:158
 prepare_exit_to_usermode arch/x86/entry/common.c:195 [inline]
 syscall_return_slowpath+0x490/0x550 arch/x86/entry/common.c:264
 entry_SYSCALL_64_fastpath+0x98/0x9a
RIP: 0033:0x44c9c9
RSP: 002b:00007f31102f9cf8 EFLAGS: 00000246 ORIG_RAX: 00000000000000ca
RAX: fffffffffffffe00 RBX: 00000000006f003c RCX: 000000000044c9c9
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 00000000006f003c
RBP: 00000000006f0038 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00000000007ff97f R14: 00007f31102fa9c0 R15: 0000000000000001

Allocated by task 4653:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:447
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_kmalloc+0xad/0xe0 mm/kasan/kasan.c:551
 kasan_slab_alloc+0x12/0x20 mm/kasan/kasan.c:489
 kmem_cache_alloc+0x12e/0x760 mm/slab.c:3544
 kmem_cache_zalloc include/linux/slab.h:678 [inline]
 kcm_attach net/kcm/kcmsock.c:1394 [inline]
 kcm_attach_ioctl net/kcm/kcmsock.c:1460 [inline]
 kcm_ioctl+0x2d2/0x1690 net/kcm/kcmsock.c:1665
 sock_do_ioctl+0x65/0xb0 net/socket.c:958
 sock_ioctl+0x2c2/0x440 net/socket.c:1055
 vfs_ioctl fs/ioctl.c:46 [inline]
 do_vfs_ioctl+0x1b1/0x1520 fs/ioctl.c:686
 SYSC_ioctl fs/ioctl.c:701 [inline]
 SyS_ioctl+0x8f/0xc0 fs/ioctl.c:692
 entry_SYSCALL_64_fastpath+0x23/0x9a

Freed by task 4653:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:447
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_slab_free+0x71/0xc0 mm/kasan/kasan.c:524
 __cache_free mm/slab.c:3488 [inline]
 kmem_cache_free+0x83/0x2a0 mm/slab.c:3746
 kcm_unattach+0xe53/0x1510 net/kcm/kcmsock.c:1563
 release_mux net/kcm/kcmsock.c:1727 [inline]
 kcm_done+0x5c7/0x1990 net/kcm/kcmsock.c:1787
 kcm_release+0x478/0x860 net/kcm/kcmsock.c:1861
 sock_release+0x8d/0x1e0 net/socket.c:595
 sock_close+0x16/0x20 net/socket.c:1123
 __fput+0x327/0x7e0 fs/file_table.c:210
 ____fput+0x15/0x20 fs/file_table.c:244
 task_work_run+0x199/0x270 kernel/task_work.c:113
 exit_task_work include/linux/task_work.h:22 [inline]
 do_exit+0x9bb/0x1ad0 kernel/exit.c:865
 do_group_exit+0x149/0x400 kernel/exit.c:968
 get_signal+0x73f/0x16c0 kernel/signal.c:2335
 do_signal+0x90/0x1eb0 arch/x86/kernel/signal.c:809
 exit_to_usermode_loop+0x214/0x310 arch/x86/entry/common.c:158
 prepare_exit_to_usermode arch/x86/entry/common.c:195 [inline]
 syscall_return_slowpath+0x490/0x550 arch/x86/entry/common.c:264
 entry_SYSCALL_64_fastpath+0x98/0x9a

The buggy address belongs to the object at ffff8801c2fc7bc0
 which belongs to the cache kcm_psock_cache of size 544
The buggy address is located 16 bytes inside of
 544-byte region [ffff8801c2fc7bc0, ffff8801c2fc7de0)
The buggy address belongs to the page:
page:ffffea00070bf180 count:1 mapcount:0 mapping:ffff8801c2fc6040 index:0x0 compound_mapcount: 0
flags: 0x2fffc0000008100(slab|head)
raw: 02fffc0000008100 ffff8801c2fc6040 0000000000000000 000000010000000b
raw: ffff8801d32e9748 ffff8801d32e9748 ffff8801d32580c0 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8801c2fc7a80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff8801c2fc7b00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff8801c2fc7b80: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
                                                 ^
 ffff8801c2fc7c00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8801c2fc7c80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (204):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2018/01/16 19:08 net-next-old 79d891c1bbb6 4198e588 .config console log report syz C ci-upstream-net-kasan-gce
2017/10/19 14:00 net-next-old b9f1f1ce866c 3704c601 .config console log report syz C ci-upstream-net-kasan-gce
2018/01/25 01:52 upstream 5132ede0fe80 866f1102 .config console log report ci-upstream-kasan-gce
2018/01/24 16:57 upstream 1f07476ec143 a5b7566c .config console log report ci-upstream-kasan-gce
2018/01/24 13:47 upstream 1f07476ec143 a5b7566c .config console log report ci-upstream-kasan-gce
2018/01/24 11:31 upstream 1f07476ec143 a5b7566c .config console log report ci-upstream-kasan-gce
2018/01/24 08:42 upstream 1f07476ec143 a5b7566c .config console log report ci-upstream-kasan-gce
2018/01/23 21:44 upstream 1995266727fa a5b7566c .config console log report ci-upstream-kasan-gce
2018/01/23 08:55 upstream a0ec1ded22e6 228e3d95 .config console log report ci-upstream-kasan-gce
2018/01/23 04:07 upstream a0ec1ded22e6 228e3d95 .config console log report ci-upstream-kasan-gce
2018/01/22 08:57 upstream 5515114211c5 fbbdcd92 .config console log report ci-upstream-kasan-gce
2018/01/22 06:30 upstream 5515114211c5 fbbdcd92 .config console log report ci-upstream-kasan-gce
2018/01/22 02:04 upstream 5515114211c5 fbbdcd92 .config console log report ci-upstream-kasan-gce
2018/01/21 22:45 upstream d517bb79f499 fbbdcd92 .config console log report ci-upstream-kasan-gce
2018/01/21 22:37 upstream d517bb79f499 fbbdcd92 .config console log report ci-upstream-kasan-gce
2018/01/21 16:47 upstream d517bb79f499 fbbdcd92 .config console log report ci-upstream-kasan-gce
2018/01/21 16:43 upstream d517bb79f499 fbbdcd92 .config console log report ci-upstream-kasan-gce
2018/01/21 13:28 upstream d517bb79f499 fbbdcd92 .config console log report ci-upstream-kasan-gce
2018/01/21 13:23 upstream d517bb79f499 fbbdcd92 .config console log report ci-upstream-kasan-gce
2018/01/23 22:36 net-next-old e71494ae68d2 a5b7566c .config console log report ci-upstream-net-kasan-gce
2018/01/21 23:46 net-next-old cbcbeedbfd76 fbbdcd92 .config console log report ci-upstream-net-kasan-gce
2018/01/21 17:12 net-next-old ea9722e2650d fbbdcd92 .config console log report ci-upstream-net-kasan-gce
2018/01/19 02:42 net-next-old d680b3524cd2 161c1d64 .config console log report ci-upstream-net-kasan-gce
2018/01/18 11:32 net-next-old 4f7d58517f46 56cc113a .config console log report ci-upstream-net-kasan-gce
2018/01/17 18:49 net-next-old c02b3741eb99 a46e5318 .config console log report ci-upstream-net-kasan-gce
2018/01/17 17:49 net-next-old c02b3741eb99 a46e5318 .config console log report ci-upstream-net-kasan-gce
2018/01/17 17:45 net-next-old c02b3741eb99 a46e5318 .config console log report ci-upstream-net-kasan-gce
2018/01/17 17:31 net-next-old c02b3741eb99 a46e5318 .config console log report ci-upstream-net-kasan-gce
2018/01/17 17:12 net-next-old c02b3741eb99 a46e5318 .config console log report ci-upstream-net-kasan-gce
2018/01/17 17:04 net-next-old c02b3741eb99 a46e5318 .config console log report ci-upstream-net-kasan-gce
2018/01/17 16:19 net-next-old c02b3741eb99 a46e5318 .config console log report ci-upstream-net-kasan-gce
2018/01/17 15:58 net-next-old c02b3741eb99 a46e5318 .config console log report ci-upstream-net-kasan-gce
2018/01/17 15:21 net-next-old c02b3741eb99 a46e5318 .config console log report ci-upstream-net-kasan-gce
2018/01/17 15:19 net-next-old c02b3741eb99 a46e5318 .config console log report ci-upstream-net-kasan-gce
2018/01/17 14:56 net-next-old c02b3741eb99 a46e5318 .config console log report ci-upstream-net-kasan-gce
2018/01/17 13:46 net-next-old c02b3741eb99 a46e5318 .config console log report ci-upstream-net-kasan-gce
2018/01/17 13:37 net-next-old c02b3741eb99 a46e5318 .config console log report ci-upstream-net-kasan-gce
2018/01/17 12:51 net-next-old c02b3741eb99 a46e5318 .config console log report ci-upstream-net-kasan-gce
2018/01/17 12:36 net-next-old c02b3741eb99 a46e5318 .config console log report ci-upstream-net-kasan-gce
2018/01/17 12:31 net-next-old c02b3741eb99 a46e5318 .config console log report ci-upstream-net-kasan-gce
2018/01/17 12:31 net-next-old c02b3741eb99 a46e5318 .config console log report ci-upstream-net-kasan-gce
2018/01/17 12:14 net-next-old c02b3741eb99 a46e5318 .config console log report ci-upstream-net-kasan-gce
* Struck through repros no longer work on HEAD.