syzbot


KASAN: use-after-free Read in fanout_demux_rollover

Status: fixed on 2017/11/06 20:46
Fix commit: 6f7cdd4aa0a4 packet: hold bind lock when rebinding to fanout hook
First crash: 2635d, last: 2614d
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in fanout_demux_rollover C 10 2614d 2632d 0/28 closed as invalid on 2017/10/18 08:55

Sample crash report:
dev_remove_pack: ffff8801d8d1b200 not found
==================================================================
BUG: KASAN: use-after-free in fanout_demux_rollover+0x49b/0x4d0 net/packet/af_packet.c:1387 at addr ffff8801d8d1b1b8
Read of size 8 by task syzkaller664810/16135
CPU: 0 PID: 16135 Comm: syzkaller664810 Not tainted 4.9.51-g9452b2c #49
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
 ffff8801db2077e0 ffffffff81d92f89 ffff8801da002000 ffff8801d8d1aa80
 ffff8801d8d1b280 ffffed003b1a3637 ffff8801d8d1b1b8 ffff8801db207808
 ffffffff8153cb8c ffffed003b1a3637 ffff8801da002000 0000000000000000
Call Trace:
 <IRQ> [  122.181823]  [<ffffffff81d92f89>] __dump_stack lib/dump_stack.c:15 [inline]
 <IRQ> [  122.181823]  [<ffffffff81d92f89>] dump_stack+0xc1/0x128 lib/dump_stack.c:51
 [<ffffffff8153cb8c>] kasan_object_err+0x1c/0x70 mm/kasan/report.c:160
 [<ffffffff8153ce4c>] print_address_description mm/kasan/report.c:198 [inline]
 [<ffffffff8153ce4c>] kasan_report_error mm/kasan/report.c:287 [inline]
 [<ffffffff8153ce4c>] kasan_report.part.1+0x21c/0x500 mm/kasan/report.c:309
 [<ffffffff8153d1e9>] kasan_report mm/kasan/report.c:330 [inline]
 [<ffffffff8153d1e9>] __asan_report_load8_noabort+0x29/0x30 mm/kasan/report.c:330
 [<ffffffff8354796b>] fanout_demux_rollover+0x49b/0x4d0 net/packet/af_packet.c:1387
 [<ffffffff8354e5d6>] packet_rcv_fanout+0x3e6/0x620 net/packet/af_packet.c:1473
 [<ffffffff82f34387>] deliver_skb net/core/dev.c:1834 [inline]
 [<ffffffff82f34387>] deliver_ptype_list_skb net/core/dev.c:1849 [inline]
 [<ffffffff82f34387>] __netif_receive_skb_core+0x887/0x29e0 net/core/dev.c:4220
 [<ffffffff82f3653b>] __netif_receive_skb+0x5b/0x1c0 net/core/dev.c:4275
 [<ffffffff82f3ac5f>] netif_receive_skb_internal+0xff/0x390 net/core/dev.c:4303
 [<ffffffff82f3ecbb>] napi_skb_finish net/core/dev.c:4661 [inline]
 [<ffffffff82f3ecbb>] napi_gro_receive+0x1fb/0x400 net/core/dev.c:4691
 [<ffffffff8271d4cc>] receive_buf drivers/net/virtio_net.c:508 [inline]
 [<ffffffff8271d4cc>] virtnet_receive+0xe1c/0x1cf0 drivers/net/virtio_net.c:723
 [<ffffffff8271e3c6>] virtnet_poll+0x26/0x140 drivers/net/virtio_net.c:741
 [<ffffffff82f3c966>] napi_poll net/core/dev.c:5197 [inline]
 [<ffffffff82f3c966>] net_rx_action+0x396/0xe00 net/core/dev.c:5262
 [<ffffffff838af11d>] __do_softirq+0x22d/0x964 kernel/softirq.c:284
 [<ffffffff81147985>] invoke_softirq kernel/softirq.c:364 [inline]
 [<ffffffff81147985>] irq_exit+0x165/0x190 kernel/softirq.c:405
 [<ffffffff838ae897>] exiting_irq arch/x86/include/asm/apic.h:659 [inline]
 [<ffffffff838ae897>] do_IRQ+0x107/0x1b0 arch/x86/kernel/irq.c:251
 [<ffffffff838acc4c>] common_interrupt+0x8c/0x8c arch/x86/entry/entry_64.S:520
 <EOI> [  122.405268]  [<ffffffff81435855>] ? __read_once_size include/linux/compiler.h:243 [inline]
 <EOI> [  122.405268]  [<ffffffff81435855>] ? compound_head include/linux/page-flags.h:143 [inline]
 <EOI> [  122.405268]  [<ffffffff81435855>] ? filemap_map_pages+0x265/0xd70 mm/filemap.c:2252
 [<ffffffff814cf7bd>] do_fault_around mm/memory.c:3109 [inline]
 [<ffffffff814cf7bd>] do_read_fault mm/memory.c:3149 [inline]
 [<ffffffff814cf7bd>] do_fault mm/memory.c:3289 [inline]
 [<ffffffff814cf7bd>] handle_pte_fault mm/memory.c:3490 [inline]
 [<ffffffff814cf7bd>] __handle_mm_fault mm/memory.c:3577 [inline]
 [<ffffffff814cf7bd>] handle_mm_fault+0x1a6d/0x2530 mm/memory.c:3614
 [<ffffffff810e020b>] __do_page_fault+0x4eb/0xbd0 arch/x86/mm/fault.c:1397
 [<ffffffff810e0917>] do_page_fault+0x27/0x30 arch/x86/mm/fault.c:1460
 [<ffffffff838ad458>] page_fault+0x28/0x30 arch/x86/entry/entry_64.S:1012
Object at ffff8801d8d1aa80, in cache kmalloc-2048 size: 2048
Allocated:
PID = 16082
 save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:57
 save_stack+0x43/0xd0 mm/kasan/kasan.c:495
 set_track mm/kasan/kasan.c:507 [inline]
 kasan_kmalloc+0xad/0xe0 mm/kasan/kasan.c:598
 __kmalloc+0x11d/0x310 mm/slub.c:3741
 kmalloc include/linux/slab.h:495 [inline]
 sk_prot_alloc+0x101/0x2a0 net/core/sock.c:1338
 sk_alloc+0x3a/0x3a0 net/core/sock.c:1394
 packet_create+0xf0/0x8e0 net/packet/af_packet.c:3211
 __sock_create+0x3ab/0x640 net/socket.c:1182
 sock_create net/socket.c:1222 [inline]
 SYSC_socket net/socket.c:1252 [inline]
 SyS_socket+0xf0/0x1b0 net/socket.c:1232
 entry_SYSCALL_64_fastpath+0x23/0xc6
Freed:
PID = 16054
 save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:57
 save_stack+0x43/0xd0 mm/kasan/kasan.c:495
 set_track mm/kasan/kasan.c:507 [inline]
 kasan_slab_free+0x73/0xc0 mm/kasan/kasan.c:571
 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+0xf0/0x2f0 mm/slub.c:3878
 sk_prot_free net/core/sock.c:1377 [inline]
 __sk_destruct+0x47f/0x570 net/core/sock.c:1455
 sk_destruct+0x47/0x80 net/core/sock.c:1463
 __sk_free+0x57/0x230 net/core/sock.c:1471
 sk_free+0x23/0x30 net/core/sock.c:1482
 sock_put include/net/sock.h:1592 [inline]
 packet_release+0x732/0xa20 net/packet/af_packet.c:3047
 sock_release+0x8d/0x1e0 net/socket.c:599
 sock_close+0x16/0x20 net/socket.c:1046
 __fput+0x28c/0x6e0 fs/file_table.c:208
 ____fput+0x15/0x20 fs/file_table.c:244
 task_work_run+0x115/0x190 kernel/task_work.c:116
 exit_task_work include/linux/task_work.h:21 [inline]
 do_exit+0x82e/0x2a50 kernel/exit.c:833
 do_group_exit+0x108/0x320 kernel/exit.c:937
 SYSC_exit_group kernel/exit.c:948 [inline]
 SyS_exit_group+0x1d/0x20 kernel/exit.c:946
 entry_SYSCALL_64_fastpath+0x23/0xc6
Memory state around the buggy address:
 ffff8801d8d1b080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8801d8d1b100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8801d8d1b180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                        ^
 ffff8801d8d1b200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8801d8d1b280: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================
==================================================================
BUG: KASAN: use-after-free in fanout_demux_rollover+0x4bc/0x4d0 net/packet/af_packet.c:1387 at addr ffff8801d53ca000
Read of size 4 by task syzkaller664810/16135
CPU: 0 PID: 16135 Comm: syzkaller664810 Tainted: G    B           4.9.51-g9452b2c #49
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
 ffff8801db2077e0 ffffffff81d92f89 ffff8801da001640 ffff8801d53ca000
 ffff8801d53ca080 ffffed003aa79400 ffff8801d53ca000 ffff8801db207808
 ffffffff8153cb8c ffffed003aa79400 ffff8801da001640 0000000000000000
Call Trace:
 <IRQ> [  122.713249]  [<ffffffff81d92f89>] __dump_stack lib/dump_stack.c:15 [inline]
 <IRQ> [  122.713249]  [<ffffffff81d92f89>] dump_stack+0xc1/0x128 lib/dump_stack.c:51
 [<ffffffff8153cb8c>] kasan_object_err+0x1c/0x70 mm/kasan/report.c:160
 [<ffffffff8153ce4c>] print_address_description mm/kasan/report.c:198 [inline]
 [<ffffffff8153ce4c>] kasan_report_error mm/kasan/report.c:287 [inline]
 [<ffffffff8153ce4c>] kasan_report.part.1+0x21c/0x500 mm/kasan/report.c:309
 [<ffffffff8153d1b9>] kasan_report mm/kasan/report.c:329 [inline]
 [<ffffffff8153d1b9>] __asan_report_load4_noabort+0x29/0x30 mm/kasan/report.c:329
 [<ffffffff8354798c>] fanout_demux_rollover+0x4bc/0x4d0 net/packet/af_packet.c:1387
 [<ffffffff8354e5d6>] packet_rcv_fanout+0x3e6/0x620 net/packet/af_packet.c:1473
 [<ffffffff82f34387>] deliver_skb net/core/dev.c:1834 [inline]
 [<ffffffff82f34387>] deliver_ptype_list_skb net/core/dev.c:1849 [inline]
 [<ffffffff82f34387>] __netif_receive_skb_core+0x887/0x29e0 net/core/dev.c:4220
 [<ffffffff82f3653b>] __netif_receive_skb+0x5b/0x1c0 net/core/dev.c:4275
 [<ffffffff82f3ac5f>] netif_receive_skb_internal+0xff/0x390 net/core/dev.c:4303
 [<ffffffff82f3ecbb>] napi_skb_finish net/core/dev.c:4661 [inline]
 [<ffffffff82f3ecbb>] napi_gro_receive+0x1fb/0x400 net/core/dev.c:4691
 [<ffffffff8271d4cc>] receive_buf drivers/net/virtio_net.c:508 [inline]
 [<ffffffff8271d4cc>] virtnet_receive+0xe1c/0x1cf0 drivers/net/virtio_net.c:723
 [<ffffffff8271e3c6>] virtnet_poll+0x26/0x140 drivers/net/virtio_net.c:741
 [<ffffffff82f3c966>] napi_poll net/core/dev.c:5197 [inline]
 [<ffffffff82f3c966>] net_rx_action+0x396/0xe00 net/core/dev.c:5262
 [<ffffffff838af11d>] __do_softirq+0x22d/0x964 kernel/softirq.c:284
 [<ffffffff81147985>] invoke_softirq kernel/softirq.c:364 [inline]
 [<ffffffff81147985>] irq_exit+0x165/0x190 kernel/softirq.c:405
 [<ffffffff838ae897>] exiting_irq arch/x86/include/asm/apic.h:659 [inline]
 [<ffffffff838ae897>] do_IRQ+0x107/0x1b0 arch/x86/kernel/irq.c:251
 [<ffffffff838acc4c>] common_interrupt+0x8c/0x8c arch/x86/entry/entry_64.S:520
 <EOI> [  122.931088]  [<ffffffff81435855>] ? __read_once_size include/linux/compiler.h:243 [inline]
 <EOI> [  122.931088]  [<ffffffff81435855>] ? compound_head include/linux/page-flags.h:143 [inline]
 <EOI> [  122.931088]  [<ffffffff81435855>] ? filemap_map_pages+0x265/0xd70 mm/filemap.c:2252
 [<ffffffff814cf7bd>] do_fault_around mm/memory.c:3109 [inline]
 [<ffffffff814cf7bd>] do_read_fault mm/memory.c:3149 [inline]
 [<ffffffff814cf7bd>] do_fault mm/memory.c:3289 [inline]
 [<ffffffff814cf7bd>] handle_pte_fault mm/memory.c:3490 [inline]
 [<ffffffff814cf7bd>] __handle_mm_fault mm/memory.c:3577 [inline]
 [<ffffffff814cf7bd>] handle_mm_fault+0x1a6d/0x2530 mm/memory.c:3614
 [<ffffffff810e020b>] __do_page_fault+0x4eb/0xbd0 arch/x86/mm/fault.c:1397
 [<ffffffff810e0917>] do_page_fault+0x27/0x30 arch/x86/mm/fault.c:1460
 [<ffffffff838ad458>] page_fault+0x28/0x30 arch/x86/entry/entry_64.S:1012
Object at ffff8801d53ca000, in cache kmalloc-128 size: 128
Allocated:
PID = 16086
 save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:57
 save_stack+0x43/0xd0 mm/kasan/kasan.c:495
 set_track mm/kasan/kasan.c:507 [inline]
 kasan_kmalloc+0xad/0xe0 mm/kasan/kasan.c:598
 kmem_cache_alloc_trace+0xfb/0x2a0 mm/slub.c:2742
 kmalloc include/linux/slab.h:490 [inline]
 kzalloc include/linux/slab.h:636 [inline]
 fanout_add net/packet/af_packet.c:1662 [inline]
 packet_setsockopt+0x181c/0x2240 net/packet/af_packet.c:3795
 SYSC_setsockopt net/socket.c:1771 [inline]
 SyS_setsockopt+0x160/0x250 net/socket.c:1750
 entry_SYSCALL_64_fastpath+0x23/0xc6
Freed:
PID = 0
 save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:57
 save_stack+0x43/0xd0 mm/kasan/kasan.c:495
 set_track mm/kasan/kasan.c:507 [inline]
 kasan_slab_free+0x73/0xc0 mm/kasan/kasan.c:571
 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+0xf0/0x2f0 mm/slub.c:3878
 __rcu_reclaim kernel/rcu/rcu.h:113 [inline]
 rcu_do_batch kernel/rcu/tree.c:2779 [inline]
 invoke_rcu_callbacks kernel/rcu/tree.c:3043 [inline]
 __rcu_process_callbacks kernel/rcu/tree.c:3010 [inline]
 rcu_process_callbacks+0x981/0x12d0 kernel/rcu/tree.c:3027
 __do_softirq+0x22d/0x964 kernel/softirq.c:284
Memory state around the buggy address:
 ffff8801d53c9f00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ffff8801d53c9f80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>ffff8801d53ca000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                   ^
 ffff8801d53ca080: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
 ffff8801d53ca100: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
==================================================================

Crashes (5):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2017/09/20 11:03 https://android.googlesource.com/kernel/common android-4.9 9452b2c248a4 4e341009 .config console log report syz C ci-android-49-kasan-gce
2017/09/26 00:48 https://android.googlesource.com/kernel/common android-4.9 47589a56b906 c26ea367 .config console log report syz ci-android-49-kasan-gce
2017/09/12 02:46 https://android.googlesource.com/kernel/common android-4.9 5316da5fec0d 0bd6a0a5 .config console log report syz ci-android-49-kasan-gce
2017/09/10 06:34 https://android.googlesource.com/kernel/common android-4.9 93babebe30d1 d18bfda0 .config console log report syz ci-android-49-kasan-gce
2017/09/04 19:51 https://android.googlesource.com/kernel/common android-4.9 6cd212785150 0ed1da4a .config console log report syz ci-android-49-kasan-gce
* Struck through repros no longer work on HEAD.