syzbot


KASAN: use-after-free Read in bpf_prog_kallsyms_add

Status: fixed on 2019/09/06 20:45
Subsystems: bpf
[Documentation on labels]
Reported-by: syzbot+ac0311cfc9e80cd2e0e8@syzkaller.appspotmail.com
Fix commit: c751798aa224 bpf: fix use after free in prog symbol exposure
First crash: 2141d, last: 1906d
Cause bisection: failed (error log, bisect log)
  
Fix bisection: the issue occurs on the latest tested release (bisect log)
Crash: BUG: unable to handle kernel paging request in bpf_prog_kallsyms_find (log)
Repro: syz .config
  
Discussions (3)
Title Replies (including bot) Last reply
Reminder: 36 open syzbot bugs in "net/bpf" subsystem 1 (1) 2019/07/03 06:01
Reminder: 30 open syzbot bugs in "net/bpf" subsystem 1 (1) 2019/06/24 05:01
KASAN: use-after-free Read in bpf_prog_kallsyms_add 0 (2) 2018/11/18 17:28
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.14 KASAN: use-after-free Read in bpf_prog_kallsyms_add 1 1783d 1783d 0/1 auto-closed as invalid on 2019/12/31 17:26
linux-4.19 KASAN: use-after-free Read in bpf_prog_kallsyms_add 2 1769d 1831d 0/1 auto-closed as invalid on 2020/01/14 14:34

Sample crash report:
IPv6: ADDRCONF(NETDEV_CHANGE): veth0: link becomes ready
8021q: adding VLAN 0 to HW filter on device team0
8021q: adding VLAN 0 to HW filter on device team0
==================================================================
BUG: KASAN: use-after-free in __list_add_valid+0x8f/0xac lib/list_debug.c:26
Read of size 8 at addr ffff8881b97b8560 by task syz-executor3/12896

CPU: 1 PID: 12896 Comm: syz-executor3 Not tainted 4.20.0-rc2+ #117
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x244/0x39d lib/dump_stack.c:113
 print_address_description.cold.7+0x9/0x1ff mm/kasan/report.c:256
 kasan_report_error mm/kasan/report.c:354 [inline]
 kasan_report.cold.8+0x242/0x309 mm/kasan/report.c:412
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:433
 __list_add_valid+0x8f/0xac lib/list_debug.c:26
 __list_add_rcu include/linux/rculist.h:52 [inline]
 list_add_tail_rcu include/linux/rculist.h:101 [inline]
 bpf_prog_ksym_node_add kernel/bpf/core.c:460 [inline]
 bpf_prog_kallsyms_add+0x200/0x9b0 kernel/bpf/core.c:491
 jit_subprogs kernel/bpf/verifier.c:5973 [inline]
 fixup_call_args kernel/bpf/verifier.c:6023 [inline]
 bpf_check+0x4fcb/0x6310 kernel/bpf/verifier.c:6404
 bpf_prog_load+0x113d/0x1cc0 kernel/bpf/syscall.c:1528
 __do_sys_bpf kernel/bpf/syscall.c:2504 [inline]
 __se_sys_bpf kernel/bpf/syscall.c:2466 [inline]
 __x64_sys_bpf+0x36c/0x520 kernel/bpf/syscall.c:2466
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x457569
Code: fd b3 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 cb b3 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007f6de3718c78 EFLAGS: 00000246 ORIG_RAX: 0000000000000141
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 0000000000457569
RDX: 0000000000000048 RSI: 0000000020000000 RDI: 0000000000000005
RBP: 000000000072bf00 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f6de37196d4
R13: 00000000004bd97c R14: 00000000004cc688 R15: 00000000ffffffff

Allocated by task 12883:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 kasan_kmalloc+0xc7/0xe0 mm/kasan/kasan.c:553
 kmem_cache_alloc_trace+0x152/0x750 mm/slab.c:3620
 kmalloc include/linux/slab.h:546 [inline]
 kzalloc include/linux/slab.h:741 [inline]
 bpf_prog_alloc+0x16b/0x3e0 kernel/bpf/core.c:89
 bpf_prog_load+0x435/0x1cc0 kernel/bpf/syscall.c:1482
 __do_sys_bpf kernel/bpf/syscall.c:2504 [inline]
 __se_sys_bpf kernel/bpf/syscall.c:2466 [inline]
 __x64_sys_bpf+0x36c/0x520 kernel/bpf/syscall.c:2466
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 17:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 __kasan_slab_free+0x102/0x150 mm/kasan/kasan.c:521
 kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:528
 __cache_free mm/slab.c:3498 [inline]
 kfree+0xcf/0x230 mm/slab.c:3817
 __bpf_prog_free kernel/bpf/core.c:146 [inline]
 bpf_prog_unlock_free include/linux/filter.h:743 [inline]
 bpf_prog_free_deferred+0x2a4/0x420 kernel/bpf/core.c:1781
 process_one_work+0xc90/0x1c40 kernel/workqueue.c:2153
 worker_thread+0x17f/0x1390 kernel/workqueue.c:2296
 kthread+0x35a/0x440 kernel/kthread.c:246
 ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:352

The buggy address belongs to the object at ffff8881b97b8500
 which belongs to the cache kmalloc-512 of size 512
The buggy address is located 96 bytes inside of
 512-byte region [ffff8881b97b8500, ffff8881b97b8700)
The buggy address belongs to the page:
page:ffffea0006e5ee00 count:1 mapcount:0 mapping:ffff8881da800940 index:0xffff8881b97b8a00
flags: 0x2fffc0000000200(slab)
raw: 02fffc0000000200 ffffea0006ede848 ffffea0006e6b508 ffff8881da800940
raw: ffff8881b97b8a00 ffff8881b97b8000 0000000100000005 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8881b97b8400: 00 00 fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff8881b97b8480: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff8881b97b8500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                       ^
 ffff8881b97b8580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8881b97b8600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (120):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2018/11/18 17:27 upstream 1ce80e0fe98e adf636a8 .config console log report syz ci-upstream-kasan-gce-smack-root
2018/11/18 18:12 bpf 569a933b03f3 adf636a8 .config console log report syz ci-upstream-bpf-kasan-gce
2019/05/02 16:39 upstream 459e3a21535a 7516d9fa .config console log report ci-upstream-kasan-gce-selinux-root
2019/04/24 07:57 upstream 7142eaa58b49 4d3d6a50 .config console log report ci-upstream-kasan-gce-selinux-root
2019/04/11 03:35 upstream 771acc7e4a6e e955ac50 .config console log report ci-upstream-kasan-gce-selinux-root
2019/01/09 08:19 upstream a88cc8da0279 45c0c1b1 .config console log report ci-upstream-kasan-gce-selinux-root
2018/11/22 20:56 upstream edeca3a769ad 87815d9d .config console log report ci-upstream-kasan-gce-selinux-root
2018/11/18 16:55 upstream 1ce80e0fe98e adf636a8 .config console log report ci-upstream-kasan-gce-root
2019/04/26 15:46 bpf 7f09baa92884 b617407b .config console log report ci-upstream-bpf-kasan-gce
2019/04/23 16:21 bpf fed68833fc53 53199d6e .config console log report ci-upstream-bpf-kasan-gce
2019/03/29 03:43 bpf 8543e4378079 14c58f8d .config console log report ci-upstream-bpf-kasan-gce
2019/03/27 03:13 bpf 1da6c4d9140c 55684ce1 .config console log report ci-upstream-bpf-kasan-gce
2019/03/26 02:00 bpf a7d6ac3761d3 55684ce1 .config console log report ci-upstream-bpf-kasan-gce
2019/03/19 10:17 bpf f01a7dbe98ae 46264c32 .config console log report ci-upstream-bpf-kasan-gce
2019/03/14 02:33 bpf f48a920504e5 2881fc25 .config console log report ci-upstream-bpf-kasan-gce
2019/03/10 15:36 bpf 71b91a506bb0 12365b99 .config console log report ci-upstream-bpf-kasan-gce
2019/03/05 18:08 bpf 822e44b45eb9 bb91cf81 .config console log report ci-upstream-bpf-kasan-gce
2019/02/18 10:04 bpf 6e1077f51436 59f36113 .config console log report ci-upstream-bpf-kasan-gce
2019/02/15 03:55 bpf 1e405c1a3f66 76dd003f .config console log report ci-upstream-bpf-kasan-gce
2019/02/11 15:53 bpf b90efd225874 73f5f452 .config console log report ci-upstream-bpf-kasan-gce
2019/02/10 19:39 net-old ccc8ca9b90ac b4f792e4 .config console log report ci-upstream-net-this-kasan-gce
2019/02/06 11:33 bpf 0429f237ce08 d672172c .config console log report ci-upstream-bpf-kasan-gce
2019/02/05 13:35 bpf 0429f237ce08 d672172c .config console log report ci-upstream-bpf-kasan-gce
2019/02/05 09:52 bpf 0429f237ce08 d672172c .config console log report ci-upstream-bpf-kasan-gce
2019/02/03 21:43 bpf e7b816415e03 c198d5dd .config console log report ci-upstream-bpf-kasan-gce
2019/01/27 18:51 bpf c9e4576743ee c73f090a .config console log report ci-upstream-bpf-kasan-gce
2019/01/23 15:13 bpf b0ca5ecb8e22 7cf3249c .config console log report ci-upstream-bpf-kasan-gce
2019/01/15 08:09 bpf fb4129b9279d ebacf5cb .config console log report ci-upstream-bpf-kasan-gce
2019/01/12 09:36 bpf fb4129b9279d c3f3344c .config console log report ci-upstream-bpf-kasan-gce
2019/01/10 03:53 bpf d972f3dce8d1 45c0c1b1 .config console log report ci-upstream-bpf-kasan-gce
2019/01/09 12:46 bpf 977e4899c9b4 45c0c1b1 .config console log report ci-upstream-bpf-kasan-gce
2019/01/08 13:04 bpf 2dc0f02da14e 37dd2683 .config console log report ci-upstream-bpf-kasan-gce
2019/01/06 01:26 bpf 466f89e9ec8c 53be0a37 .config console log report ci-upstream-bpf-kasan-gce
2019/01/02 03:32 bpf 8b6b25cf93b7 3d85f48c .config console log report ci-upstream-bpf-kasan-gce
2018/12/29 15:47 bpf b71acb0e3721 a40793d7 .config console log report ci-upstream-bpf-kasan-gce
2018/12/25 16:02 bpf bcb671c2fa0e 8a41a0ad .config console log report ci-upstream-bpf-kasan-gce
2018/12/14 01:35 bpf 7640ead93924 fe7127be .config console log report ci-upstream-bpf-kasan-gce
2018/11/24 17:14 bpf 1efb6ee3edea ecc7c870 .config console log report ci-upstream-bpf-kasan-gce
2018/11/24 03:22 bpf 1efb6ee3edea eb9ed731 .config console log report ci-upstream-bpf-kasan-gce
2019/03/20 09:44 bpf-next a0cfa79f8470 2458c1c6 .config console log report ci-upstream-bpf-next-kasan-gce
2019/03/16 09:22 bpf-next d9862cfbe209 bab43553 .config console log report ci-upstream-bpf-next-kasan-gce
2019/03/10 20:07 bpf-next d9862cfbe209 12365b99 .config console log report ci-upstream-bpf-next-kasan-gce
2019/03/04 01:08 bpf-next ea5bade929bf 1c0e457a .config console log report ci-upstream-bpf-next-kasan-gce
2019/02/20 12:32 bpf-next 74e31ca850c1 c95f0707 .config console log report ci-upstream-bpf-next-kasan-gce
2019/01/25 04:32 bpf-next d9ff286a0f59 bfab9cd8 .config console log report ci-upstream-bpf-next-kasan-gce
2019/01/16 21:51 bpf-next 7939f8beecf1 d538790b .config console log report ci-upstream-bpf-next-kasan-gce
2019/01/12 06:13 bpf-next b71acb0e3721 c3f3344c .config console log report ci-upstream-bpf-next-kasan-gce
2018/12/30 23:20 bpf-next b71acb0e3721 9942de5f .config console log report ci-upstream-bpf-next-kasan-gce
2018/12/26 11:31 bpf-next fa2323325e8b 8a41a0ad .config console log report ci-upstream-bpf-next-kasan-gce
2018/12/26 06:33 bpf-next fa2323325e8b 8a41a0ad .config console log report ci-upstream-bpf-next-kasan-gce
2018/12/24 21:06 bpf-next fa2323325e8b 8a41a0ad .config console log report ci-upstream-bpf-next-kasan-gce
2018/12/05 08:05 bpf-next 2a95471c3397 f162ad97 .config console log report ci-upstream-bpf-next-kasan-gce
2018/12/04 14:19 bpf-next d59dd69d5576 6ad0ae61 .config console log report ci-upstream-bpf-next-kasan-gce
2018/12/04 03:24 bpf-next 90b1023f68c7 03f94a45 .config console log report ci-upstream-bpf-next-kasan-gce
2018/12/03 12:59 bpf-next 5482e9a93c83 819002b0 .config console log report ci-upstream-bpf-next-kasan-gce
2018/11/30 10:50 bpf-next b42699547fc9 66071e27 .config console log report ci-upstream-bpf-next-kasan-gce
2018/10/31 21:02 net-next-old 4b42745211af 89781090 .config console log report ci-upstream-net-kasan-gce
2018/09/09 05:47 bpf-next f6f3bac08ff9 6b5120a4 .config console log report ci-upstream-bpf-next-kasan-gce
2018/10/18 13:35 linux-next 9bab64345e83 d257b2d2 .config console log report ci-upstream-linux-next-kasan-gce-root
* Struck through repros no longer work on HEAD.