syzbot


KASAN: use-after-free Read in copy_to_iter

Status: public: reported C repro on 2019/04/13 00:00
Reported-by: syzbot+e454958b7dc8cb86d0ed@syzkaller.appspotmail.com
First crash: 2387d, last: 2372d

Sample crash report:
IPv6: ADDRCONF(NETDEV_UP): veth1: link is not ready
IPv6: ADDRCONF(NETDEV_CHANGE): veth1: link becomes ready
IPv6: ADDRCONF(NETDEV_CHANGE): veth0: link becomes ready
protocol 0000 is buggy, dev sit0
==================================================================
BUG: KASAN: use-after-free in __copy_to_user arch/x86/include/asm/uaccess_64.h:182 [inline]
BUG: KASAN: use-after-free in copy_to_iter+0x239/0x10e0 lib/iov_iter.c:540
Read of size 12 at addr ffff8801d8264300 by task syz-executor148/4151

CPU: 0 PID: 4151 Comm: syz-executor148 Not tainted 4.9.101-gaef17a5 #29
protocol 0000 is buggy, dev sit0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
 ffff8801d6c975f8[   26.219003] protocol 0000 is buggy, dev sit0
 ffffffff81eb1009 ffffea0007609900 ffff8801d8264300
 0000000000000000 ffff8801d8264300 ffff8801d8264300 ffff8801d6c97630
 ffffffff8156541b[   26.239439] protocol 0000 is buggy, dev sit0
 ffff8801d8264300 000000000000000c 0000000000000000
 [<ffffffff81eb1009>] __dump_stack lib/dump_stack.c:15 [inline]
 [<ffffffff81eb1009>] dump_stack+0xc1/0x128 lib/dump_stack.c:51
 [<ffffffff8156541b>] print_address_description+0x6c/0x234 mm/kasan/report.c:256
protocol 0000 is buggy, dev sit0
 [<ffffffff81565825>] kasan_report_error mm/kasan/report.c:355 [inline]
 [<ffffffff81565825>] kasan_report.cold.6+0x242/0x2fe mm/kasan/report.c:412
protocol 0000 is buggy, dev sit0
 [<ffffffff8153830f>] check_memory_region_inline mm/kasan/kasan.c:318 [inline]
 [<ffffffff8153830f>] check_memory_region+0x14f/0x1b0 mm/kasan/kasan.c:325
 [<ffffffff81538381>] kasan_check_read+0x11/0x20 mm/kasan/kasan.c:330
 [<ffffffff81efa529>] __copy_to_user arch/x86/include/asm/uaccess_64.h:182 [inline]
 [<ffffffff81efa529>] copy_to_iter+0x239/0x10e0 lib/iov_iter.c:540
protocol 0000 is buggy, dev sit0
protocol 0000 is buggy, dev sit0
 [<ffffffff8304b261>] skb_copy_datagram_iter+0x1d1/0x8f0 net/core/datagram.c:390
 [<ffffffff836897a3>] skb_copy_datagram_msg include/linux/skbuff.h:3049 [inline]
 [<ffffffff836897a3>] packet_recvmsg+0x263/0xf40 net/packet/af_packet.c:3359
protocol 0000 is buggy, dev sit0
protocol 0000 is buggy, dev sit0
 [<ffffffff830124c6>] sock_recvmsg_nosec net/socket.c:737 [inline]
 [<ffffffff830124c6>] sock_recvmsg+0xc6/0x110 net/socket.c:744
 [<ffffffff8301275a>] sock_read_iter+0x24a/0x360 net/socket.c:821
 [<ffffffff8156e471>] do_iter_readv_writev+0x301/0x4b0 fs/read_write.c:693
 [<ffffffff81570986>] do_readv_writev+0x2f6/0x7a0 fs/read_write.c:871
 [<ffffffff81570eb4>] vfs_readv+0x84/0xc0 fs/read_write.c:897
 [<ffffffff81570fd6>] do_readv+0xe6/0x260 fs/read_write.c:923
 [<ffffffff81574837>] SYSC_readv fs/read_write.c:1010 [inline]
 [<ffffffff81574837>] SyS_readv+0x27/0x30 fs/read_write.c:1007
 [<ffffffff81006316>] do_syscall_64+0x1a6/0x490 arch/x86/entry/common.c:282
 [<ffffffff839f4893>] entry_SYSCALL_64_after_swapgs+0x5d/0xdb

Allocated by task 4152:
 save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:57
 save_stack+0x43/0xd0 mm/kasan/kasan.c:505
 set_track mm/kasan/kasan.c:517 [inline]
 kasan_kmalloc+0xc7/0xe0 mm/kasan/kasan.c:609
 kasan_slab_alloc+0x12/0x20 mm/kasan/kasan.c:547
 slab_post_alloc_hook mm/slab.h:417 [inline]
 slab_alloc_node mm/slub.c:2715 [inline]
 slab_alloc mm/slub.c:2723 [inline]
 __kmalloc_track_caller+0xdc/0x2b0 mm/slub.c:4232
 __kmalloc_reserve.isra.37+0x33/0xc0 net/core/skbuff.c:138
 __alloc_skb+0x11a/0x600 net/core/skbuff.c:231
 alloc_skb include/linux/skbuff.h:919 [inline]
 alloc_skb_with_frags+0xaf/0x520 net/core/skbuff.c:4679
 sock_alloc_send_pskb+0x5a9/0x750 net/core/sock.c:1893
 packet_alloc_skb net/packet/af_packet.c:2817 [inline]
 packet_snd net/packet/af_packet.c:2908 [inline]
 packet_sendmsg+0x1581/0x4470 net/packet/af_packet.c:2985
 sock_sendmsg_nosec net/socket.c:635 [inline]
 sock_sendmsg+0xcc/0x110 net/socket.c:645
 SYSC_sendto+0x21c/0x370 net/socket.c:1670
 SyS_sendto+0x40/0x50 net/socket.c:1638
 do_syscall_64+0x1a6/0x490 arch/x86/entry/common.c:282
 entry_SYSCALL_64_after_swapgs+0x5d/0xdb

Freed by task 4152:
 save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:57
 save_stack+0x43/0xd0 mm/kasan/kasan.c:505
 set_track mm/kasan/kasan.c:517 [inline]
 kasan_slab_free+0x72/0xc0 mm/kasan/kasan.c:582
 slab_free_hook mm/slub.c:1355 [inline]
 slab_free_freelist_hook mm/slub.c:1377 [inline]
 slab_free mm/slub.c:2958 [inline]
 kfree+0xfb/0x310 mm/slub.c:3878
 skb_free_head+0x8b/0xb0 net/core/skbuff.c:580
 skb_release_data+0x329/0x400 net/core/skbuff.c:611
 skb_release_all+0x4a/0x60 net/core/skbuff.c:670
 __kfree_skb+0x15/0x20 net/core/skbuff.c:684
 kfree_skb+0xcc/0x340 net/core/skbuff.c:705
 sit_tunnel_xmit+0xfb/0x2590 net/ipv6/sit.c:1033
 __netdev_start_xmit include/linux/netdevice.h:4062 [inline]
 netdev_start_xmit include/linux/netdevice.h:4071 [inline]
 xmit_one net/core/dev.c:2955 [inline]
 dev_hard_start_xmit+0x197/0x8b0 net/core/dev.c:2971
 __dev_queue_xmit+0x19a5/0x2080 net/core/dev.c:3451
 dev_queue_xmit+0x17/0x20 net/core/dev.c:3484
 packet_snd net/packet/af_packet.c:2960 [inline]
 packet_sendmsg+0x1eff/0x4470 net/packet/af_packet.c:2985
 sock_sendmsg_nosec net/socket.c:635 [inline]
 sock_sendmsg+0xcc/0x110 net/socket.c:645
 SYSC_sendto+0x21c/0x370 net/socket.c:1670
 SyS_sendto+0x40/0x50 net/socket.c:1638
 do_syscall_64+0x1a6/0x490 arch/x86/entry/common.c:282
 entry_SYSCALL_64_after_swapgs+0x5d/0xdb

The buggy address belongs to the object at ffff8801d8264280
 which belongs to the cache kmalloc-512 of size 512
The buggy address is located 128 bytes inside of
 512-byte region [ffff8801d8264280, ffff8801d8264480)
The buggy address belongs to the page:
page:ffffea0007609900 count:1 mapcount:0 mapping:          (null) index:0x0 compound_mapcount: 0
flags: 0x8000000000004080(slab|head)
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8801d8264200: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff8801d8264280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8801d8264300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                   ^
 ffff8801d8264380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8801d8264400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (12):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2018/05/22 10:59 https://android.googlesource.com/kernel/common android-4.9 aef17a58e8ca f48c20b8 .config console log report syz C ci-android-49-kasan-gce-root
2018/05/20 17:14 https://android.googlesource.com/kernel/common android-4.9 aef17a58e8ca f48c20b8 .config console log report syz C ci-android-49-kasan-gce-root
2018/05/18 03:58 https://android.googlesource.com/kernel/common android-4.9 73fdfa38c59d 738d58ad .config console log report syz C ci-android-49-kasan-gce-root
2018/05/17 16:14 https://android.googlesource.com/kernel/common android-4.9 73fdfa38c59d 90c54c49 .config console log report syz C ci-android-49-kasan-gce-root
2018/05/15 18:58 https://android.googlesource.com/kernel/common android-4.9 74fa0af47306 661fd7b9 .config console log report syz C ci-android-49-kasan-gce-root
2018/05/15 12:50 https://android.googlesource.com/kernel/common android-4.9 74fa0af47306 661fd7b9 .config console log report syz C ci-android-49-kasan-gce-root
2018/05/24 23:52 https://android.googlesource.com/kernel/common android-4.9 2e35bed46b50 f48c20b8 .config console log report ci-android-49-kasan-gce-root
2018/05/22 14:02 https://android.googlesource.com/kernel/common android-4.9 aef17a58e8ca f48c20b8 .config console log report ci-android-49-kasan-gce-root
2018/05/20 20:19 https://android.googlesource.com/kernel/common android-4.9 aef17a58e8ca f48c20b8 .config console log report ci-android-49-kasan-gce-root
2018/05/18 16:54 https://android.googlesource.com/kernel/common android-4.9 73fdfa38c59d c992b767 .config console log report ci-android-49-kasan-gce-root
2018/05/16 02:05 https://android.googlesource.com/kernel/common android-4.9 74fa0af47306 68ce85f1 .config console log report ci-android-49-kasan-gce-root
2018/05/10 05:19 https://android.googlesource.com/kernel/common android-4.9 c462abbf779b 12c7428a .config console log report ci-android-49-kasan-gce-root
* Struck through repros no longer work on HEAD.