syzbot


KASAN: use-after-free Read in inet_frag_destroy_rcu

Status: fixed on 2019/08/05 13:45
Subsystems: net
[Documentation on labels]
Fix commit: dc93f46bc4e0 inet: frags: fix use-after-free read in inet_frag_destroy_rcu
First crash: 1788d, last: 1785d
Cause bisection: introduced by (bisect log) :
commit dbb58e291cd47e594b64293bd91a4ce40626513c
Author: Adam Ford <aford173@gmail.com>
Date: Tue Apr 2 19:19:08 2019 +0000

  ARM: dts: imx6q-logicpd: Reduce inrush current on start

Crash: KASAN: use-after-free Read in rhashtable_last_table (log)
Repro: C syz .config
  

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in inet_frag_destroy_rcu+0xd9/0xe0 net/ipv4/inet_fragment.c:201
Read of size 8 at addr ffff888091f18058 by task syz-executor494/8693

CPU: 0 PID: 8693 Comm: syz-executor494 Not tainted 5.2.0-rc1+ #3
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 <IRQ>
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x172/0x1f0 lib/dump_stack.c:113
 print_address_description.cold+0x7c/0x20d mm/kasan/report.c:188
 __kasan_report.cold+0x1b/0x40 mm/kasan/report.c:317
 kasan_report+0x12/0x20 mm/kasan/common.c:614
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/generic_report.c:132
 inet_frag_destroy_rcu+0xd9/0xe0 net/ipv4/inet_fragment.c:201
 __rcu_reclaim kernel/rcu/rcu.h:222 [inline]
 rcu_do_batch kernel/rcu/tree.c:2092 [inline]
 invoke_rcu_callbacks kernel/rcu/tree.c:2310 [inline]
 rcu_core+0xba5/0x1500 kernel/rcu/tree.c:2291
 __do_softirq+0x25c/0x94c kernel/softirq.c:293
 invoke_softirq kernel/softirq.c:374 [inline]
 irq_exit+0x180/0x1d0 kernel/softirq.c:414
 exiting_irq arch/x86/include/asm/apic.h:536 [inline]
 smp_apic_timer_interrupt+0x13b/0x550 arch/x86/kernel/apic/apic.c:1068
 apic_timer_interrupt+0xf/0x20 arch/x86/entry/entry_64.S:806
 </IRQ>
RIP: 0010:__raw_spin_unlock_irq include/linux/spinlock_api_smp.h:169 [inline]
RIP: 0010:_raw_spin_unlock_irq+0x54/0x90 kernel/locking/spinlock.c:199
Code: c0 80 70 b2 88 48 ba 00 00 00 00 00 fc ff df 48 c1 e8 03 80 3c 10 00 75 33 48 83 3d 25 b4 95 01 00 74 20 fb 66 0f 1f 44 00 00 <bf> 01 00 00 00 e8 72 be 30 fa 65 8b 05 13 41 e5 78 85 c0 74 06 41
RSP: 0018:ffff888096b77b20 EFLAGS: 00000286 ORIG_RAX: ffffffffffffff13
RAX: 1ffffffff1164e10 RBX: ffff8880892ac200 RCX: 0000000000000000
RDX: dffffc0000000000 RSI: 0000000000000006 RDI: ffff8880892aca7c
RBP: ffff888096b77b28 R08: ffff8880892ac200 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: ffff8880ae835040
R13: ffffffff88a7a100 R14: ffff8880974cb600 R15: 0000000000000000
 finish_lock_switch kernel/sched/core.c:2568 [inline]
 finish_task_switch+0x146/0x730 kernel/sched/core.c:2668
 context_switch kernel/sched/core.c:2821 [inline]
 __schedule+0x7d3/0x1560 kernel/sched/core.c:3445
 schedule+0xa8/0x260 kernel/sched/core.c:3509
 freezable_schedule include/linux/freezer.h:172 [inline]
 do_nanosleep+0x201/0x690 kernel/time/hrtimer.c:1679
 hrtimer_nanosleep+0x2a6/0x570 kernel/time/hrtimer.c:1733
 __do_sys_nanosleep kernel/time/hrtimer.c:1767 [inline]
 __se_sys_nanosleep kernel/time/hrtimer.c:1754 [inline]
 __x64_sys_nanosleep+0x1a6/0x220 kernel/time/hrtimer.c:1754
 do_syscall_64+0xfd/0x680 arch/x86/entry/common.c:301
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x440fc0
Code: c0 5b 5d c3 66 0f 1f 44 00 00 8b 04 24 48 83 c4 18 5b 5d c3 66 0f 1f 44 00 00 83 3d 31 b0 29 00 00 75 14 b8 23 00 00 00 0f 05 <48> 3d 01 f0 ff ff 0f 83 74 21 fc ff c3 48 83 ec 08 e8 aa 43 00 00
RSP: 002b:00007ffc98ef6888 EFLAGS: 00000246 ORIG_RAX: 0000000000000023
RAX: ffffffffffffffda RBX: 000000000001ef06 RCX: 0000000000440fc0
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 00007ffc98ef6890
RBP: 000000000000025d R08: 0000000000000001 R09: 0000555556186880
R10: 0000000000000000 R11: 0000000000000246 R12: 000000000000025b
R13: 0000000000403650 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 8690:
 save_stack+0x23/0x90 mm/kasan/common.c:71
 set_track mm/kasan/common.c:79 [inline]
 __kasan_kmalloc mm/kasan/common.c:489 [inline]
 __kasan_kmalloc.constprop.0+0xcf/0xe0 mm/kasan/common.c:462
 kasan_kmalloc+0x9/0x10 mm/kasan/common.c:503
 kmem_cache_alloc_trace+0x151/0x750 mm/slab.c:3555
 kmalloc include/linux/slab.h:547 [inline]
 kzalloc include/linux/slab.h:742 [inline]
 fqdir_init include/net/inet_frag.h:115 [inline]
 ipv4_frags_init_net+0x48/0x4e0 net/ipv4/ip_fragment.c:645
 ops_init+0xb3/0x410 net/core/net_namespace.c:130
 setup_net+0x2d3/0x740 net/core/net_namespace.c:316
 copy_net_ns+0x1df/0x340 net/core/net_namespace.c:439
 create_new_namespaces+0x400/0x7b0 kernel/nsproxy.c:107
 unshare_nsproxy_namespaces+0xc2/0x200 kernel/nsproxy.c:206
 ksys_unshare+0x440/0x980 kernel/fork.c:2692
 __do_sys_unshare kernel/fork.c:2760 [inline]
 __se_sys_unshare kernel/fork.c:2758 [inline]
 __x64_sys_unshare+0x31/0x40 kernel/fork.c:2758
 do_syscall_64+0xfd/0x680 arch/x86/entry/common.c:301
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 9597:
 save_stack+0x23/0x90 mm/kasan/common.c:71
 set_track mm/kasan/common.c:79 [inline]
 __kasan_slab_free+0x102/0x150 mm/kasan/common.c:451
 kasan_slab_free+0xe/0x10 mm/kasan/common.c:459
 __cache_free mm/slab.c:3432 [inline]
 kfree+0xcf/0x220 mm/slab.c:3755
 fqdir_rwork_fn+0x33/0x40 net/ipv4/inet_fragment.c:154
 process_one_work+0x989/0x1790 kernel/workqueue.c:2269
 worker_thread+0x98/0xe40 kernel/workqueue.c:2415
 kthread+0x354/0x420 kernel/kthread.c:255
 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352

The buggy address belongs to the object at ffff888091f18040
 which belongs to the cache kmalloc-512 of size 512
The buggy address is located 24 bytes inside of
 512-byte region [ffff888091f18040, ffff888091f18240)
The buggy address belongs to the page:
page:ffffea000247c600 refcount:1 mapcount:0 mapping:ffff8880aa400940 index:0xffff888091f18cc0
flags: 0x1fffc0000000200(slab)
raw: 01fffc0000000200 ffffea0002650248 ffffea000257ec08 ffff8880aa400940
raw: ffff888091f18cc0 ffff888091f18040 0000000100000005 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff888091f17f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff888091f17f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff888091f18000: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
                                                    ^
 ffff888091f18080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888091f18100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (61):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2019/05/28 02:13 net-next-old cec4f328c929 6bd61501 .config console log report syz C ci-upstream-net-kasan-gce
2019/05/29 07:47 net-next-old c7ae09253cb8 6bd61501 .config console log report ci-upstream-net-kasan-gce
2019/05/29 06:32 net-next-old c7ae09253cb8 6bd61501 .config console log report ci-upstream-net-kasan-gce
2019/05/29 04:51 net-next-old c7ae09253cb8 6bd61501 .config console log report ci-upstream-net-kasan-gce
2019/05/29 03:30 net-next-old c7ae09253cb8 6bd61501 .config console log report ci-upstream-net-kasan-gce
2019/05/29 01:39 net-next-old c7ae09253cb8 6bd61501 .config console log report ci-upstream-net-kasan-gce
2019/05/29 01:36 net-next-old c7ae09253cb8 6bd61501 .config console log report ci-upstream-net-kasan-gce
2019/05/29 01:20 net-next-old c7ae09253cb8 6bd61501 .config console log report ci-upstream-net-kasan-gce
2019/05/28 21:58 net-next-old c7ae09253cb8 6bd61501 .config console log report ci-upstream-net-kasan-gce
2019/05/28 21:51 net-next-old c7ae09253cb8 6bd61501 .config console log report ci-upstream-net-kasan-gce
2019/05/28 20:49 net-next-old c7ae09253cb8 6bd61501 .config console log report ci-upstream-net-kasan-gce
2019/05/28 19:25 net-next-old c7ae09253cb8 6bd61501 .config console log report ci-upstream-net-kasan-gce
2019/05/28 19:02 net-next-old c7ae09253cb8 6bd61501 .config console log report ci-upstream-net-kasan-gce
2019/05/28 18:50 net-next-old c7ae09253cb8 6bd61501 .config console log report ci-upstream-net-kasan-gce
2019/05/28 17:35 net-next-old cec4f328c929 6bd61501 .config console log report ci-upstream-net-kasan-gce
2019/05/28 17:01 net-next-old cec4f328c929 6bd61501 .config console log report ci-upstream-net-kasan-gce
2019/05/28 16:54 net-next-old cec4f328c929 6bd61501 .config console log report ci-upstream-net-kasan-gce
2019/05/28 16:30 net-next-old cec4f328c929 6bd61501 .config console log report ci-upstream-net-kasan-gce
2019/05/28 13:36 net-next-old cec4f328c929 6bd61501 .config console log report ci-upstream-net-kasan-gce
2019/05/28 12:57 net-next-old cec4f328c929 6bd61501 .config console log report ci-upstream-net-kasan-gce
2019/05/28 12:47 net-next-old cec4f328c929 6bd61501 .config console log report ci-upstream-net-kasan-gce
2019/05/28 12:14 net-next-old cec4f328c929 6bd61501 .config console log report ci-upstream-net-kasan-gce
2019/05/28 11:01 net-next-old cec4f328c929 6bd61501 .config console log report ci-upstream-net-kasan-gce
2019/05/28 10:51 net-next-old cec4f328c929 6bd61501 .config console log report ci-upstream-net-kasan-gce
2019/05/28 09:30 net-next-old cec4f328c929 6bd61501 .config console log report ci-upstream-net-kasan-gce
2019/05/28 09:22 net-next-old cec4f328c929 6bd61501 .config console log report ci-upstream-net-kasan-gce
2019/05/28 08:00 net-next-old cec4f328c929 6bd61501 .config console log report ci-upstream-net-kasan-gce
2019/05/28 07:19 net-next-old cec4f328c929 6bd61501 .config console log report ci-upstream-net-kasan-gce
2019/05/28 06:00 net-next-old cec4f328c929 6bd61501 .config console log report ci-upstream-net-kasan-gce
2019/05/28 04:06 net-next-old cec4f328c929 6bd61501 .config console log report ci-upstream-net-kasan-gce
2019/05/28 04:03 net-next-old cec4f328c929 6bd61501 .config console log report ci-upstream-net-kasan-gce
2019/05/28 02:19 net-next-old cec4f328c929 6bd61501 .config console log report ci-upstream-net-kasan-gce
2019/05/28 02:19 net-next-old cec4f328c929 6bd61501 .config console log report ci-upstream-net-kasan-gce
2019/05/27 21:51 net-next-old cec4f328c929 6bd61501 .config console log report ci-upstream-net-kasan-gce
2019/05/27 21:50 net-next-old cec4f328c929 6bd61501 .config console log report ci-upstream-net-kasan-gce
2019/05/27 21:47 net-next-old cec4f328c929 6bd61501 .config console log report ci-upstream-net-kasan-gce
2019/05/27 18:23 net-next-old f4aa80129ff7 562efd79 .config console log report ci-upstream-net-kasan-gce
2019/05/27 14:02 net-next-old f4aa80129ff7 562efd79 .config console log report ci-upstream-net-kasan-gce
2019/05/27 13:30 net-next-old f4aa80129ff7 562efd79 .config console log report ci-upstream-net-kasan-gce
2019/05/27 13:25 net-next-old f4aa80129ff7 562efd79 .config console log report ci-upstream-net-kasan-gce
2019/05/27 12:49 net-next-old f4aa80129ff7 562efd79 .config console log report ci-upstream-net-kasan-gce
2019/05/27 10:21 net-next-old f4aa80129ff7 562efd79 .config console log report ci-upstream-net-kasan-gce
2019/05/27 10:04 net-next-old f4aa80129ff7 562efd79 .config console log report ci-upstream-net-kasan-gce
2019/05/27 09:59 net-next-old f4aa80129ff7 562efd79 .config console log report ci-upstream-net-kasan-gce
2019/05/30 03:25 linux-next 9a15d2e3fd03 d9aaf3c2 .config console log report ci-upstream-linux-next-kasan-gce-root
2019/05/30 03:24 linux-next 9a15d2e3fd03 d9aaf3c2 .config console log report ci-upstream-linux-next-kasan-gce-root
2019/05/30 01:42 linux-next 9a15d2e3fd03 d9aaf3c2 .config console log report ci-upstream-linux-next-kasan-gce-root
2019/05/29 14:30 linux-next 9a15d2e3fd03 5457ef34 .config console log report ci-upstream-linux-next-kasan-gce-root
2019/05/28 08:56 linux-next 531b0a360899 6bd61501 .config console log report ci-upstream-linux-next-kasan-gce-root
* Struck through repros no longer work on HEAD.