syzbot


KASAN: use-after-free Read in copyout

Status: fixed on 2018/06/07 13:52
Subsystems: net
[Documentation on labels]
Fix commit: b84bbaf7a6c8 packet: in packet_snd start writing at link layer allocation
First crash: 2195d, last: 2138d

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in copyout+0x7d/0xb0 lib/iov_iter.c:136
Read of size 14 at addr ffff8801d472a8d0 by task syzkaller790446/4590

CPU: 0 PID: 4590 Comm: syzkaller790446 Not tainted 4.16.0-rc7+ #9
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:17 [inline]
 dump_stack+0x194/0x24d lib/dump_stack.c:53
 print_address_description+0x73/0x250 mm/kasan/report.c:256
 kasan_report_error mm/kasan/report.c:354 [inline]
 kasan_report+0x23c/0x360 mm/kasan/report.c:412
 check_memory_region_inline mm/kasan/kasan.c:260 [inline]
 check_memory_region+0x137/0x190 mm/kasan/kasan.c:267
 kasan_check_read+0x11/0x20 mm/kasan/kasan.c:272
 copyout+0x7d/0xb0 lib/iov_iter.c:136
 _copy_to_iter+0x262/0x13a0 lib/iov_iter.c:565
 copy_to_iter include/linux/uio.h:106 [inline]
 skb_copy_datagram_iter+0x1c2/0xac0 net/core/datagram.c:431
 skb_copy_datagram_msg include/linux/skbuff.h:3256 [inline]
 packet_recvmsg+0x2b9/0x17a0 net/packet/af_packet.c:3341
 sock_recvmsg_nosec net/socket.c:803 [inline]
 sock_recvmsg+0xc9/0x110 net/socket.c:810
 sock_read_iter+0x35b/0x560 net/socket.c:887
 call_read_iter include/linux/fs.h:1776 [inline]
 do_iter_readv_writev+0x630/0x830 fs/read_write.c:651
 do_iter_read+0x21a/0x5a0 fs/read_write.c:895
 vfs_readv+0x121/0x1c0 fs/read_write.c:959
 do_readv+0xfc/0x2a0 fs/read_write.c:992
 SYSC_readv fs/read_write.c:1079 [inline]
 SyS_readv+0x27/0x30 fs/read_write.c:1076
 do_syscall_64+0x281/0x940 arch/x86/entry/common.c:287
 entry_SYSCALL_64_after_hwframe+0x42/0xb7
RIP: 0033:0x446d89
RSP: 002b:00007f2bcd5b1d48 EFLAGS: 00000293 ORIG_RAX: 0000000000000013
RAX: ffffffffffffffda RBX: 00000000006dcc8c RCX: 0000000000446d89
RDX: 0000000000000001 RSI: 0000000020000100 RDI: 00000000000003fe
RBP: 00000000006dcc88 R08: 00000000200001c0 R09: 00000000200001c0
R10: 00000000200001c0 R11: 0000000000000293 R12: 6475612f7665642f
R13: 440aa2dc38fb8f86 R14: 00007f2bcd5b29c0 R15: 0000000000000008

Allocated by task 4588:
 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:552
 __do_kmalloc_node mm/slab.c:3670 [inline]
 __kmalloc_node_track_caller+0x47/0x70 mm/slab.c:3684
 __kmalloc_reserve.isra.39+0x41/0xd0 net/core/skbuff.c:137
 __alloc_skb+0x13b/0x780 net/core/skbuff.c:205
 alloc_skb include/linux/skbuff.h:983 [inline]
 alloc_skb_with_frags+0x10d/0x750 net/core/skbuff.c:5229
 sock_alloc_send_pskb+0x787/0x9b0 net/core/sock.c:2085
 packet_alloc_skb net/packet/af_packet.c:2803 [inline]
 packet_snd net/packet/af_packet.c:2894 [inline]
 packet_sendmsg+0x1ece/0x60b0 net/packet/af_packet.c:2969
 sock_sendmsg_nosec net/socket.c:630 [inline]
 sock_sendmsg+0xca/0x110 net/socket.c:640
 SYSC_sendto+0x361/0x5c0 net/socket.c:1747
 SyS_sendto+0x40/0x50 net/socket.c:1715
 do_syscall_64+0x281/0x940 arch/x86/entry/common.c:287
 entry_SYSCALL_64_after_hwframe+0x42/0xb7

Freed by task 4588:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:447
 set_track mm/kasan/kasan.c:459 [inline]
 __kasan_slab_free+0x11a/0x170 mm/kasan/kasan.c:520
 kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:527
 __cache_free mm/slab.c:3486 [inline]
 kfree+0xd9/0x260 mm/slab.c:3801
 skb_free_head+0x74/0xb0 net/core/skbuff.c:550
 skb_release_data+0x58c/0x790 net/core/skbuff.c:570
 skb_release_all+0x4a/0x60 net/core/skbuff.c:627
 __kfree_skb net/core/skbuff.c:641 [inline]
 kfree_skb+0x15d/0x4c0 net/core/skbuff.c:659
 ip6_tnl_start_xmit+0x184/0x2070 net/ipv6/ip6_tunnel.c:1404
 __netdev_start_xmit include/linux/netdevice.h:4066 [inline]
 netdev_start_xmit include/linux/netdevice.h:4075 [inline]
 xmit_one net/core/dev.c:3026 [inline]
 dev_hard_start_xmit+0x24e/0xac0 net/core/dev.c:3042
 __dev_queue_xmit+0x26bf/0x2fc0 net/core/dev.c:3557
 dev_queue_xmit+0x17/0x20 net/core/dev.c:3590
 packet_snd net/packet/af_packet.c:2944 [inline]
 packet_sendmsg+0x3aed/0x60b0 net/packet/af_packet.c:2969
 sock_sendmsg_nosec net/socket.c:630 [inline]
 sock_sendmsg+0xca/0x110 net/socket.c:640
 SYSC_sendto+0x361/0x5c0 net/socket.c:1747
 SyS_sendto+0x40/0x50 net/socket.c:1715
 do_syscall_64+0x281/0x940 arch/x86/entry/common.c:287
 entry_SYSCALL_64_after_hwframe+0x42/0xb7

The buggy address belongs to the object at ffff8801d472a840
 which belongs to the cache kmalloc-512 of size 512
The buggy address is located 144 bytes inside of
 512-byte region [ffff8801d472a840, ffff8801d472aa40)
The buggy address belongs to the page:
page:ffffea000751ca80 count:1 mapcount:0 mapping:ffff8801d472a0c0 index:0x0
flags: 0x2fffc0000000100(slab)
raw: 02fffc0000000100 ffff8801d472a0c0 0000000000000000 0000000100000006
raw: ffffea000751c9e0 ffffea000751cb20 ffff8801dac00940 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8801d472a780: 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc
 ffff8801d472a800: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
>ffff8801d472a880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                 ^
 ffff8801d472a900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8801d472a980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (11):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2018/04/01 10:36 upstream 10b84daddbec 0174c6c8 .config console log report syz C ci-upstream-kasan-gce-root
2018/05/21 03:28 upstream 771c577c23ba f48c20b8 .config console log report ci-upstream-kasan-gce-root
2018/05/19 13:30 upstream 73fcb1a370c7 849705db .config console log report ci-upstream-kasan-gce-root
2018/05/19 06:49 upstream 2c71d338bef2 849705db .config console log report ci-upstream-kasan-gce-root
2018/05/15 13:37 upstream 67b8d5c70812 661fd7b9 .config console log report ci-upstream-kasan-gce-root
2018/05/10 16:17 upstream 008464a9360e 12c7428a .config console log report ci-upstream-kasan-gce-root
2018/04/04 09:33 upstream 17dec0a94915 676bd07e .config console log report ci-upstream-kasan-gce-root
2018/04/01 09:14 upstream 10b84daddbec 0174c6c8 .config console log report ci-upstream-kasan-gce-root
2018/03/30 02:01 upstream 0b412605ef5f d47f0ed6 .config console log report ci-upstream-kasan-gce-root
2018/03/28 03:01 upstream 3eb2ce825ea1 bf5e585c .config console log report ci-upstream-kasan-gce-root
2018/03/25 16:09 upstream bcfc1f455466 e033c1f1 .config console log report ci-upstream-kasan-gce-root
* Struck through repros no longer work on HEAD.