syzbot


KASAN: slab-out-of-bounds Read in do_tcp_getsockopt

Status: fixed on 2019/10/15 23:40
Subsystems: net
[Documentation on labels]
Fix commit: 3afb09618840 tcp: fix slab-out-of-bounds in tcp_zerocopy_receive()
First crash: 1721d, last: 1702d

Sample crash report:
==================================================================
BUG: KASAN: slab-out-of-bounds in tcp_zerocopy_receive net/ipv4/tcp.c:1807 [inline]
BUG: KASAN: slab-out-of-bounds in do_tcp_getsockopt.isra.0+0x2c7d/0x3130 net/ipv4/tcp.c:3657
Read of size 4 at addr ffff888091ed2888 by task syz-executor.1/2383

CPU: 0 PID: 2383 Comm: syz-executor.1 Not tainted 5.3.0+ #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+0x172/0x1f0 lib/dump_stack.c:113
 print_address_description.cold+0xd4/0x306 mm/kasan/report.c:351
 __kasan_report.cold+0x1b/0x36 mm/kasan/report.c:482
 kasan_report+0x12/0x17 mm/kasan/common.c:618
 __asan_report_load4_noabort+0x14/0x20 mm/kasan/generic_report.c:131
 tcp_zerocopy_receive net/ipv4/tcp.c:1807 [inline]
 do_tcp_getsockopt.isra.0+0x2c7d/0x3130 net/ipv4/tcp.c:3657
 tcp_getsockopt+0xbf/0xe0 net/ipv4/tcp.c:3683
 sock_common_getsockopt+0x94/0xd0 net/core/sock.c:3101
 __sys_getsockopt+0x16d/0x310 net/socket.c:2129
 __do_sys_getsockopt net/socket.c:2144 [inline]
 __se_sys_getsockopt net/socket.c:2141 [inline]
 __x64_sys_getsockopt+0xbe/0x150 net/socket.c:2141
 do_syscall_64+0xfa/0x760 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x459a09
Code: fd b7 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 b7 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007f7979ec0c78 EFLAGS: 00000246 ORIG_RAX: 0000000000000037
RAX: ffffffffffffffda RBX: 0000000000000005 RCX: 0000000000459a09
RDX: 0000000000000023 RSI: 0000000000000006 RDI: 0000000000000004
RBP: 000000000075bfc8 R08: 0000000020000040 R09: 0000000000000000
R10: 0000000020000000 R11: 0000000000000246 R12: 00007f7979ec16d4
R13: 00000000004cd148 R14: 00000000004d3c50 R15: 00000000ffffffff

Allocated by task 2377:
 save_stack+0x23/0x90 mm/kasan/common.c:69
 set_track mm/kasan/common.c:77 [inline]
 __kasan_kmalloc mm/kasan/common.c:493 [inline]
 __kasan_kmalloc.constprop.0+0xcf/0xe0 mm/kasan/common.c:466
 kasan_kmalloc+0x9/0x10 mm/kasan/common.c:507
 __do_kmalloc_node mm/slab.c:3615 [inline]
 __kmalloc_node_track_caller+0x4e/0x70 mm/slab.c:3629
 __kmalloc_reserve.isra.0+0x40/0xf0 net/core/skbuff.c:141
 __alloc_skb+0x10b/0x5e0 net/core/skbuff.c:209
 alloc_skb_fclone include/linux/skbuff.h:1099 [inline]
 sk_stream_alloc_skb+0x2d2/0xc60 net/ipv4/tcp.c:875
 tcp_sendmsg_locked+0xc70/0x31d0 net/ipv4/tcp.c:1283
 tcp_sendmsg+0x30/0x50 net/ipv4/tcp.c:1434
 inet_sendmsg+0x9e/0xe0 net/ipv4/af_inet.c:807
 sock_sendmsg_nosec net/socket.c:637 [inline]
 sock_sendmsg+0xd7/0x130 net/socket.c:657
 __sys_sendto+0x262/0x380 net/socket.c:1952
 __do_sys_sendto net/socket.c:1964 [inline]
 __se_sys_sendto net/socket.c:1960 [inline]
 __x64_sys_sendto+0xe1/0x1a0 net/socket.c:1960
 do_syscall_64+0xfa/0x760 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 755:
 save_stack+0x23/0x90 mm/kasan/common.c:69
 set_track mm/kasan/common.c:77 [inline]
 __kasan_slab_free+0x102/0x150 mm/kasan/common.c:455
 kasan_slab_free+0xe/0x10 mm/kasan/common.c:463
 __cache_free mm/slab.c:3425 [inline]
 kfree+0x10a/0x2c0 mm/slab.c:3756
 skb_free_head+0x93/0xb0 net/core/skbuff.c:591
 skb_release_data+0x42d/0x7c0 net/core/skbuff.c:611
 skb_release_all+0x4d/0x60 net/core/skbuff.c:665
 __kfree_skb net/core/skbuff.c:679 [inline]
 kfree_skb net/core/skbuff.c:697 [inline]
 kfree_skb+0x101/0x3c0 net/core/skbuff.c:691
 ipip_tunnel_xmit+0x3c4/0x500 net/ipv4/ipip.c:309
 __netdev_start_xmit include/linux/netdevice.h:4420 [inline]
 netdev_start_xmit include/linux/netdevice.h:4434 [inline]
 xmit_one net/core/dev.c:3280 [inline]
 dev_hard_start_xmit+0x1a3/0x9c0 net/core/dev.c:3296
 __dev_queue_xmit+0x2b16/0x35b0 net/core/dev.c:3873
 dev_queue_xmit+0x18/0x20 net/core/dev.c:3906
 neigh_direct_output+0x16/0x20 net/core/neighbour.c:1530
 neigh_output include/net/neighbour.h:511 [inline]
 ip6_finish_output2+0x1034/0x2520 net/ipv6/ip6_output.c:116
 __ip6_finish_output+0x444/0xa50 net/ipv6/ip6_output.c:142
 ip6_finish_output+0x38/0x1f0 net/ipv6/ip6_output.c:152
 NF_HOOK_COND include/linux/netfilter.h:294 [inline]
 ip6_output+0x235/0x7c0 net/ipv6/ip6_output.c:175
 dst_output include/net/dst.h:436 [inline]
 ip6_local_out+0xbb/0x184 net/ipv6/output_core.c:179
 ip6_send_skb+0xbb/0x300 net/ipv6/ip6_output.c:1792
 udp_v6_send_skb.isra.0+0x839/0x14c0 net/ipv6/udp.c:1168
 udpv6_sendmsg+0x21e0/0x2990 net/ipv6/udp.c:1466
 inet6_sendmsg+0x9e/0xe0 net/ipv6/af_inet6.c:576
 sock_sendmsg_nosec net/socket.c:637 [inline]
 sock_sendmsg+0xd7/0x130 net/socket.c:657
 ___sys_sendmsg+0x3e2/0x920 net/socket.c:2311
 __sys_sendmmsg+0x1bf/0x4d0 net/socket.c:2413
 __do_sys_sendmmsg net/socket.c:2442 [inline]
 __se_sys_sendmmsg net/socket.c:2439 [inline]
 __x64_sys_sendmmsg+0x9d/0x100 net/socket.c:2439
 do_syscall_64+0xfa/0x760 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff888091ed2480
 which belongs to the cache kmalloc-1k of size 1024
The buggy address is located 8 bytes to the right of
 1024-byte region [ffff888091ed2480, ffff888091ed2880)
The buggy address belongs to the page:
page:ffffea000247b480 refcount:1 mapcount:0 mapping:ffff8880aa400c40 index:0x0 compound_mapcount: 0
flags: 0x1fffc0000010200(slab|head)
raw: 01fffc0000010200 ffffea00026fb288 ffffea0002451788 ffff8880aa400c40
raw: 0000000000000000 ffff888091ed2000 0000000100000007 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff888091ed2780: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff888091ed2800: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff888091ed2880: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
                      ^
 ffff888091ed2900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888091ed2980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (3):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2019/09/22 09:42 net-next-old b41dae061bbd d96e88f3 .config console log report ci-upstream-net-kasan-gce
2019/09/22 02:50 net-next-old b41dae061bbd d96e88f3 .config console log report ci-upstream-net-kasan-gce
2019/09/02 19:54 net-next-old a21cf11bc57f 14544a56 .config console log report ci-upstream-net-kasan-gce
* Struck through repros no longer work on HEAD.