syzbot


KASAN: use-after-free Write in ipv4_conntrack_defrag

Status: public: reported C repro on 2019/04/11 08:44
Reported-by: syzbot+c05d4f10cc503d4a96b5@syzkaller.appspotmail.com
First crash: 2142d, last: 2114d

Sample crash report:
random: crng init done
==================================================================
BUG: KASAN: use-after-free in nf_ct_ipv4_gather_frags net/ipv4/netfilter/nf_defrag_ipv4.c:35 [inline]
BUG: KASAN: use-after-free in ipv4_conntrack_defrag net/ipv4/netfilter/nf_defrag_ipv4.c:84 [inline]
BUG: KASAN: use-after-free in ipv4_conntrack_defrag+0x2ae/0x2f0 net/ipv4/netfilter/nf_defrag_ipv4.c:61
Write of size 4 at addr ffff8801cf704448 by task syz-executor436/2060

CPU: 0 PID: 2060 Comm: syz-executor436 Not tainted 4.9.154+ #19
 ffff8801db607948 ffffffff81b47411 0000000000000001 ffffea00073dc100
 ffff8801cf704448 0000000000000004 ffffffff826028fe ffff8801db607980
 ffffffff81502615 0000000000000001 ffff8801cf704448 ffff8801cf704448
Call Trace:
 <IRQ> [   44.786305]  [<ffffffff81b47411>] __dump_stack lib/dump_stack.c:15 [inline]
 <IRQ> [   44.786305]  [<ffffffff81b47411>] dump_stack+0xc1/0x120 lib/dump_stack.c:51
 [<ffffffff81502615>] print_address_description+0x6f/0x238 mm/kasan/report.c:256
 [<ffffffff8150286a>] kasan_report_error mm/kasan/report.c:355 [inline]
 [<ffffffff8150286a>] kasan_report mm/kasan/report.c:412 [inline]
 [<ffffffff8150286a>] kasan_report.cold+0x8c/0x2ba mm/kasan/report.c:397
 [<ffffffff814f4ae7>] __asan_report_store4_noabort+0x17/0x20 mm/kasan/report.c:437
 [<ffffffff826028fe>] nf_ct_ipv4_gather_frags net/ipv4/netfilter/nf_defrag_ipv4.c:35 [inline]
 [<ffffffff826028fe>] ipv4_conntrack_defrag net/ipv4/netfilter/nf_defrag_ipv4.c:84 [inline]
 [<ffffffff826028fe>] ipv4_conntrack_defrag+0x2ae/0x2f0 net/ipv4/netfilter/nf_defrag_ipv4.c:61
 [<ffffffff823de69e>] nf_iterate+0x12e/0x310 net/netfilter/core.c:324
 [<ffffffff823de994>] nf_hook_slow+0x114/0x1f0 net/netfilter/core.c:355
 [<ffffffff8249efbf>] nf_hook_thresh include/linux/netfilter.h:191 [inline]
 [<ffffffff8249efbf>] NF_HOOK_THRESH include/linux/netfilter.h:230 [inline]
 [<ffffffff8249efbf>] NF_HOOK include/linux/netfilter.h:255 [inline]
 [<ffffffff8249efbf>] ip_rcv+0xbdf/0x1040 net/ipv4/ip_input.c:488
 [<ffffffff823018a6>] __netif_receive_skb_core+0x1156/0x2990 net/core/dev.c:4289
 [<ffffffff8230a368>] __netif_receive_skb+0x58/0x1c0 net/core/dev.c:4327
 [<ffffffff82311d48>] process_backlog+0x1e8/0x610 net/core/dev.c:4952
 [<ffffffff8231113a>] napi_poll net/core/dev.c:5253 [inline]
 [<ffffffff8231113a>] net_rx_action+0x3aa/0xdd0 net/core/dev.c:5318
 [<ffffffff8281b87d>] __do_softirq+0x22d/0x964 kernel/softirq.c:288
 [<ffffffff8281735c>] do_softirq_own_stack+0x1c/0x30 arch/x86/entry/entry_64.S:843
 <EOI> [   44.914081]  [<ffffffff810ee772>] do_softirq.part.0+0x62/0x70 kernel/softirq.c:332
 [<ffffffff810ee8d8>] do_softirq+0x18/0x20 kernel/softirq.c:320
 [<ffffffff823000ce>] netif_rx_ni+0xbe/0x310 net/core/dev.c:3919
 [<ffffffff81ed1392>] tun_get_user+0xcd2/0x2430 drivers/net/tun.c:1330
 [<ffffffff81ed2d0a>] tun_chr_write_iter+0xda/0x190 drivers/net/tun.c:1353
 [<ffffffff815094e9>] do_iter_readv_writev+0x3d9/0x4b0 fs/read_write.c:695
 [<ffffffff8150d06d>] do_readv_writev+0x2ed/0x7a0 fs/read_write.c:871
 [<ffffffff8150db09>] vfs_writev+0x89/0xc0 fs/read_write.c:910
 [<ffffffff8150dc29>] do_writev+0xe9/0x260 fs/read_write.c:943
 [<ffffffff81510e88>] SYSC_writev fs/read_write.c:1016 [inline]
 [<ffffffff81510e88>] SyS_writev+0x28/0x30 fs/read_write.c:1013
 [<ffffffff810056bd>] do_syscall_64+0x1ad/0x570 arch/x86/entry/common.c:285
 [<ffffffff82816493>] entry_SYSCALL_64_after_swapgs+0x5d/0xdb

Allocated by task 2060:
 save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:57
 save_stack mm/kasan/kasan.c:505 [inline]
 set_track mm/kasan/kasan.c:517 [inline]
 kasan_kmalloc.part.0+0x62/0xf0 mm/kasan/kasan.c:609
 kasan_kmalloc+0xb7/0xd0 mm/kasan/kasan.c:594
 kasan_slab_alloc+0xf/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]
 kmem_cache_alloc+0xd5/0x2b0 mm/slub.c:2728
 kmem_cache_alloc_node include/linux/slab.h:364 [inline]
 __alloc_skb+0xe7/0x5e0 net/core/skbuff.c:219
 alloc_skb include/linux/skbuff.h:924 [inline]
 alloc_skb_with_frags+0xb0/0x4f0 net/core/skbuff.c:4711
 sock_alloc_send_pskb+0x5ec/0x760 net/core/sock.c:1894
 tun_alloc_skb drivers/net/tun.c:1166 [inline]
 tun_get_user+0x53b/0x2430 drivers/net/tun.c:1263
 tun_chr_write_iter+0xda/0x190 drivers/net/tun.c:1353
 do_iter_readv_writev+0x3d9/0x4b0 fs/read_write.c:695
 do_readv_writev+0x2ed/0x7a0 fs/read_write.c:871
 vfs_writev+0x89/0xc0 fs/read_write.c:910
 do_writev+0xe9/0x260 fs/read_write.c:943
 SYSC_writev fs/read_write.c:1016 [inline]
 SyS_writev+0x28/0x30 fs/read_write.c:1013
 do_syscall_64+0x1ad/0x570 arch/x86/entry/common.c:285
 entry_SYSCALL_64_after_swapgs+0x5d/0xdb

Freed by task 2060:
 save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:57
 save_stack mm/kasan/kasan.c:505 [inline]
 set_track mm/kasan/kasan.c:517 [inline]
 kasan_slab_free+0xb0/0x190 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]
 kmem_cache_free+0xbe/0x310 mm/slub.c:2980
 kfree_skbmem+0x9f/0x100 net/core/skbuff.c:623
 __kfree_skb net/core/skbuff.c:685 [inline]
 kfree_skb+0xd4/0x350 net/core/skbuff.c:705
 ip_frag_queue net/ipv4/ip_fragment.c:505 [inline]
 ip_defrag+0x620/0x3bc0 net/ipv4/ip_fragment.c:690
 nf_ct_ipv4_gather_frags net/ipv4/netfilter/nf_defrag_ipv4.c:31 [inline]
 ipv4_conntrack_defrag net/ipv4/netfilter/nf_defrag_ipv4.c:84 [inline]
 ipv4_conntrack_defrag+0x1b4/0x2f0 net/ipv4/netfilter/nf_defrag_ipv4.c:61
 nf_iterate+0x12e/0x310 net/netfilter/core.c:324
 nf_hook_slow+0x114/0x1f0 net/netfilter/core.c:355
 nf_hook_thresh include/linux/netfilter.h:191 [inline]
 NF_HOOK_THRESH include/linux/netfilter.h:230 [inline]
 NF_HOOK include/linux/netfilter.h:255 [inline]
 ip_rcv+0xbdf/0x1040 net/ipv4/ip_input.c:488
 __netif_receive_skb_core+0x1156/0x2990 net/core/dev.c:4289
 __netif_receive_skb+0x58/0x1c0 net/core/dev.c:4327
 process_backlog+0x1e8/0x610 net/core/dev.c:4952
 napi_poll net/core/dev.c:5253 [inline]
 net_rx_action+0x3aa/0xdd0 net/core/dev.c:5318
 __do_softirq+0x22d/0x964 kernel/softirq.c:288

The buggy address belongs to the object at ffff8801cf7043c0
 which belongs to the cache skbuff_head_cache of size 224
The buggy address is located 136 bytes inside of
 224-byte region [ffff8801cf7043c0, ffff8801cf7044a0)
The buggy address belongs to the page:
page:ffffea00073dc100 count:1 mapcount:0 mapping:          (null) index:0x0
flags: 0x4000000000000080(slab)
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8801cf704300: 00 00 00 00 00 00 00 00 00 00 00 00 fc fc fc fc
 ffff8801cf704380: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
>ffff8801cf704400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                              ^
 ffff8801cf704480: fb fb fb fb fc fc fc fc fc fc fc fc fc fc fc fc
 ffff8801cf704500: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Crashes (2266):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2019/01/31 20:20 https://android.googlesource.com/kernel/common android-4.9 27c2fe3fe6ba 0e8ea0a3 .config console log report syz C ci-android-49-kasan-gce-root
2019/01/31 20:05 https://android.googlesource.com/kernel/common android-4.9 27c2fe3fe6ba 0e8ea0a3 .config console log report syz C ci-android-49-kasan-gce-root
2019/01/31 13:44 https://android.googlesource.com/kernel/common android-4.9 27c2fe3fe6ba aa432daf .config console log report syz C ci-android-49-kasan-gce-root
2019/01/31 13:28 https://android.googlesource.com/kernel/common android-4.9 27c2fe3fe6ba aa432daf .config console log report syz C ci-android-49-kasan-gce-root
2019/01/31 13:13 https://android.googlesource.com/kernel/common android-4.9 27c2fe3fe6ba aa432daf .config console log report syz C ci-android-49-kasan-gce-root
2019/01/29 06:01 https://android.googlesource.com/kernel/common android-4.9 fe0eb27ac6e2 aa432daf .config console log report syz C ci-android-49-kasan-gce-root
2019/01/29 04:38 https://android.googlesource.com/kernel/common android-4.9 fe0eb27ac6e2 aa432daf .config console log report syz C ci-android-49-kasan-gce-root
2019/01/29 04:22 https://android.googlesource.com/kernel/common android-4.9 fe0eb27ac6e2 aa432daf .config console log report syz C ci-android-49-kasan-gce-root
2019/01/26 21:00 https://android.googlesource.com/kernel/common android-4.9 fe0eb27ac6e2 c73f090a .config console log report syz C ci-android-49-kasan-gce-root
2019/01/26 19:03 https://android.googlesource.com/kernel/common android-4.9 fe0eb27ac6e2 c73f090a .config console log report syz C ci-android-49-kasan-gce-root
2019/01/22 06:47 https://android.googlesource.com/kernel/common android-4.9 4b1d0d3e4e00 badbbeee .config console log report syz C ci-android-49-kasan-gce-root
2019/01/22 05:07 https://android.googlesource.com/kernel/common android-4.9 4b1d0d3e4e00 badbbeee .config console log report syz C ci-android-49-kasan-gce-root
2019/01/22 04:52 https://android.googlesource.com/kernel/common android-4.9 4b1d0d3e4e00 badbbeee .config console log report syz C ci-android-49-kasan-gce-root
2019/01/22 04:37 https://android.googlesource.com/kernel/common android-4.9 4b1d0d3e4e00 badbbeee .config console log report syz C ci-android-49-kasan-gce-root
2019/01/21 06:56 https://android.googlesource.com/kernel/common android-4.9 4b1d0d3e4e00 fd37a550 .config console log report syz C ci-android-49-kasan-gce-root
2019/01/21 06:41 https://android.googlesource.com/kernel/common android-4.9 4b1d0d3e4e00 fd37a550 .config console log report syz C ci-android-49-kasan-gce-root
2019/01/21 01:43 https://android.googlesource.com/kernel/common android-4.9 4b1d0d3e4e00 fd37a550 .config console log report syz C ci-android-49-kasan-gce-root
2019/01/20 23:36 https://android.googlesource.com/kernel/common android-4.9 4b1d0d3e4e00 fd37a550 .config console log report syz C ci-android-49-kasan-gce-root
2019/01/20 22:29 https://android.googlesource.com/kernel/common android-4.9 4b1d0d3e4e00 fd37a550 .config console log report syz C ci-android-49-kasan-gce-root
2019/01/20 22:07 https://android.googlesource.com/kernel/common android-4.9 4b1d0d3e4e00 fd37a550 .config console log report syz C ci-android-49-kasan-gce-root
2019/01/19 20:10 https://android.googlesource.com/kernel/common android-4.9 4b1d0d3e4e00 8aa587b0 .config console log report syz C ci-android-49-kasan-gce-root
2019/01/19 19:54 https://android.googlesource.com/kernel/common android-4.9 4b1d0d3e4e00 8aa587b0 .config console log report syz C ci-android-49-kasan-gce-root
2019/01/18 17:14 https://android.googlesource.com/kernel/common android-4.9 736cb63e53e4 2103a236 .config console log report syz C ci-android-49-kasan-gce-root
2019/01/17 20:15 https://android.googlesource.com/kernel/common android-4.9 736cb63e53e4 769e75ed .config console log report syz C ci-android-49-kasan-gce-root
2019/01/17 19:08 https://android.googlesource.com/kernel/common android-4.9 736cb63e53e4 769e75ed .config console log report syz C ci-android-49-kasan-gce-root
2019/01/13 05:43 https://android.googlesource.com/kernel/common android-4.9 9e6c14f45398 c3f3344c .config console log report syz C ci-android-49-kasan-gce-root
2019/01/13 02:39 https://android.googlesource.com/kernel/common android-4.9 9e6c14f45398 c3f3344c .config console log report syz C ci-android-49-kasan-gce-root
2019/01/13 02:12 https://android.googlesource.com/kernel/common android-4.9 9e6c14f45398 c3f3344c .config console log report syz C ci-android-49-kasan-gce-root
2019/01/12 21:02 https://android.googlesource.com/kernel/common android-4.9 9e6c14f45398 c3f3344c .config console log report syz C ci-android-49-kasan-gce-root
2019/01/09 23:11 https://android.googlesource.com/kernel/common android-4.9 ed0b11d22809 45c0c1b1 .config console log report syz C ci-android-49-kasan-gce-root
2019/01/31 20:50 https://android.googlesource.com/kernel/common android-4.9 27c2fe3fe6ba 0e8ea0a3 .config console log report syz ci-android-49-kasan-gce-root
2019/01/09 21:01 https://android.googlesource.com/kernel/common android-4.9 ed0b11d22809 45c0c1b1 .config console log report syz ci-android-49-kasan-gce-root
2019/02/07 09:24 https://android.googlesource.com/kernel/common android-4.9 7d08263a1394 d25487bc .config console log report ci-android-49-kasan-gce-root
2019/02/07 08:12 https://android.googlesource.com/kernel/common android-4.9 7d08263a1394 d25487bc .config console log report ci-android-49-kasan-gce-root
2019/02/07 07:54 https://android.googlesource.com/kernel/common android-4.9 7d08263a1394 d25487bc .config console log report ci-android-49-kasan-gce-root
2019/02/07 06:05 https://android.googlesource.com/kernel/common android-4.9 7d08263a1394 d25487bc .config console log report ci-android-49-kasan-gce-root
2019/02/07 04:11 https://android.googlesource.com/kernel/common android-4.9 7d08263a1394 d25487bc .config console log report ci-android-49-kasan-gce-root
2019/02/07 03:08 https://android.googlesource.com/kernel/common android-4.9 7d08263a1394 d25487bc .config console log report ci-android-49-kasan-gce-root
2019/02/07 00:28 https://android.googlesource.com/kernel/common android-4.9 7d08263a1394 d25487bc .config console log report ci-android-49-kasan-gce-root
2019/02/06 23:26 https://android.googlesource.com/kernel/common android-4.9 7d08263a1394 d25487bc .config console log report ci-android-49-kasan-gce-root
2019/02/06 20:04 https://android.googlesource.com/kernel/common android-4.9 7d08263a1394 d25487bc .config console log report ci-android-49-kasan-gce-root
2019/02/06 17:04 https://android.googlesource.com/kernel/common android-4.9 7d08263a1394 d25487bc .config console log report ci-android-49-kasan-gce-root
2019/02/06 17:02 https://android.googlesource.com/kernel/common android-4.9 7d08263a1394 d25487bc .config console log report ci-android-49-kasan-gce-root
2019/02/06 13:59 https://android.googlesource.com/kernel/common android-4.9 7d08263a1394 d25487bc .config console log report ci-android-49-kasan-gce-root
2019/02/06 12:39 https://android.googlesource.com/kernel/common android-4.9 7d08263a1394 d672172c .config console log report ci-android-49-kasan-gce-root
2019/02/06 10:23 https://android.googlesource.com/kernel/common android-4.9 d79aa412c82b d672172c .config console log report ci-android-49-kasan-gce-root
2019/02/06 08:08 https://android.googlesource.com/kernel/common android-4.9 d79aa412c82b d672172c .config console log report ci-android-49-kasan-gce-root
2019/02/06 06:08 https://android.googlesource.com/kernel/common android-4.9 d79aa412c82b d672172c .config console log report ci-android-49-kasan-gce-root
2019/02/06 03:57 https://android.googlesource.com/kernel/common android-4.9 d79aa412c82b d672172c .config console log report ci-android-49-kasan-gce-root
2019/02/06 02:28 https://android.googlesource.com/kernel/common android-4.9 d79aa412c82b d672172c .config console log report ci-android-49-kasan-gce-root
2019/02/06 02:02 https://android.googlesource.com/kernel/common android-4.9 d79aa412c82b d672172c .config console log report ci-android-49-kasan-gce-root
2019/02/05 23:20 https://android.googlesource.com/kernel/common android-4.9 d79aa412c82b d672172c .config console log report ci-android-49-kasan-gce-root
2019/02/05 20:48 https://android.googlesource.com/kernel/common android-4.9 6fffec46611b d672172c .config console log report ci-android-49-kasan-gce-root
2019/02/05 19:36 https://android.googlesource.com/kernel/common android-4.9 6fffec46611b d672172c .config console log report ci-android-49-kasan-gce-root
2019/02/05 17:39 https://android.googlesource.com/kernel/common android-4.9 6fffec46611b d672172c .config console log report ci-android-49-kasan-gce-root
2019/02/05 15:48 https://android.googlesource.com/kernel/common android-4.9 6fffec46611b d672172c .config console log report ci-android-49-kasan-gce-root
2019/02/05 14:24 https://android.googlesource.com/kernel/common android-4.9 6fffec46611b d672172c .config console log report ci-android-49-kasan-gce-root
2019/02/05 13:16 https://android.googlesource.com/kernel/common android-4.9 6fffec46611b d672172c .config console log report ci-android-49-kasan-gce-root
2019/02/05 11:41 https://android.googlesource.com/kernel/common android-4.9 6fffec46611b d672172c .config console log report ci-android-49-kasan-gce-root
2019/02/05 09:49 https://android.googlesource.com/kernel/common android-4.9 6fffec46611b d672172c .config console log report ci-android-49-kasan-gce-root
2019/02/05 08:16 https://android.googlesource.com/kernel/common android-4.9 cdba725fc2d8 d672172c .config console log report ci-android-49-kasan-gce-root
2019/02/05 07:15 https://android.googlesource.com/kernel/common android-4.9 cdba725fc2d8 d672172c .config console log report ci-android-49-kasan-gce-root
2019/02/05 05:51 https://android.googlesource.com/kernel/common android-4.9 cdba725fc2d8 d672172c .config console log report ci-android-49-kasan-gce-root
2019/02/05 04:01 https://android.googlesource.com/kernel/common android-4.9 cdba725fc2d8 d672172c .config console log report ci-android-49-kasan-gce-root
2019/02/05 02:08 https://android.googlesource.com/kernel/common android-4.9 cdba725fc2d8 d672172c .config console log report ci-android-49-kasan-gce-root
2019/02/05 00:16 https://android.googlesource.com/kernel/common android-4.9 cdba725fc2d8 d672172c .config console log report ci-android-49-kasan-gce-root
2019/02/04 23:04 https://android.googlesource.com/kernel/common android-4.9 cdba725fc2d8 d672172c .config console log report ci-android-49-kasan-gce-root
2019/02/04 21:02 https://android.googlesource.com/kernel/common android-4.9 cdba725fc2d8 d672172c .config console log report ci-android-49-kasan-gce-root
2019/02/04 17:30 https://android.googlesource.com/kernel/common android-4.9 5aa04bc73fa2 d672172c .config console log report ci-android-49-kasan-gce-root
2019/02/04 15:46 https://android.googlesource.com/kernel/common android-4.9 5aa04bc73fa2 d672172c .config console log report ci-android-49-kasan-gce-root
2019/02/04 14:35 https://android.googlesource.com/kernel/common android-4.9 5aa04bc73fa2 d672172c .config console log report ci-android-49-kasan-gce-root
2019/02/04 13:23 https://android.googlesource.com/kernel/common android-4.9 5aa04bc73fa2 d672172c .config console log report ci-android-49-kasan-gce-root
2019/02/04 12:14 https://android.googlesource.com/kernel/common android-4.9 5aa04bc73fa2 d672172c .config console log report ci-android-49-kasan-gce-root
2019/02/04 10:55 https://android.googlesource.com/kernel/common android-4.9 5aa04bc73fa2 c198d5dd .config console log report ci-android-49-kasan-gce-root
2019/01/09 18:04 https://android.googlesource.com/kernel/common android-4.9 ed0b11d22809 45c0c1b1 .config console log report ci-android-49-kasan-gce-root
* Struck through repros no longer work on HEAD.