syzbot


KASAN: use-after-free Read in bpf_prog_kallsyms_find

Status: upstream: reported C repro on 2019/10/14 06:50
Reported-by: syzbot+78c0055f570265b80c19@syzkaller.appspotmail.com
First crash: 1655d, last: 1183d
Fix bisection: failed (error log, bisect log)
  
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in bpf_prog_kallsyms_find (2) bpf C done 9 1644d 1655d 13/26 fixed on 2019/11/23 02:56
upstream KASAN: use-after-free Read in bpf_prog_kallsyms_find bpf 2 1910d 1940d 0/26 auto-closed as invalid on 2019/07/31 10:58
Fix bisection attempts (9)
Created Duration User Patch Repo Result
2020/10/15 16:55 3m bisect fix linux-4.19.y error job log (0)
2020/09/15 16:32 23m bisect fix linux-4.19.y job log (0) log
2020/07/30 23:08 28m bisect fix linux-4.19.y job log (0) log
2020/06/30 22:20 24m bisect fix linux-4.19.y job log (0) log
2020/05/31 20:47 26m bisect fix linux-4.19.y job log (0) log
2020/05/01 20:20 26m bisect fix linux-4.19.y job log (0) log
2020/04/01 19:54 26m bisect fix linux-4.19.y job log (0) log
2020/03/02 19:22 31m bisect fix linux-4.19.y job log (0) log
2019/12/13 16:57 26m bisect fix linux-4.19.y job log (0) log

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in __read_once_size include/linux/compiler.h:193 [inline]
BUG: KASAN: use-after-free in __lt_find include/linux/rbtree_latch.h:118 [inline]
BUG: KASAN: use-after-free in latch_tree_find include/linux/rbtree_latch.h:208 [inline]
BUG: KASAN: use-after-free in bpf_prog_kallsyms_find kernel/bpf/core.c:511 [inline]
BUG: KASAN: use-after-free in bpf_prog_kallsyms_find+0x2a9/0x2c0 kernel/bpf/core.c:504
Read of size 8 at addr ffff8880a5a07180 by task syz-executor204/8448

CPU: 0 PID: 8448 Comm: syz-executor204 Not tainted 4.19.80 #0
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+0x172/0x1f0 lib/dump_stack.c:113
 print_address_description.cold+0x7c/0x20d mm/kasan/report.c:256
 kasan_report_error mm/kasan/report.c:354 [inline]
 kasan_report mm/kasan/report.c:412 [inline]
 kasan_report.cold+0x8c/0x2ba mm/kasan/report.c:396
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:433
 __read_once_size include/linux/compiler.h:193 [inline]
 __lt_find include/linux/rbtree_latch.h:118 [inline]
 latch_tree_find include/linux/rbtree_latch.h:208 [inline]
 bpf_prog_kallsyms_find kernel/bpf/core.c:511 [inline]
 bpf_prog_kallsyms_find+0x2a9/0x2c0 kernel/bpf/core.c:504
 is_bpf_text_address+0x78/0x170 kernel/bpf/core.c:546
 kernel_text_address+0x73/0xf0 kernel/extable.c:152
 __kernel_text_address+0xd/0x40 kernel/extable.c:107
 unwind_get_return_address arch/x86/kernel/unwind_frame.c:18 [inline]
 unwind_get_return_address+0x61/0xa0 arch/x86/kernel/unwind_frame.c:13
 __save_stack_trace+0x99/0x100 arch/x86/kernel/stacktrace.c:45
 save_stack_trace+0x1a/0x20 arch/x86/kernel/stacktrace.c:60
 save_stack+0x45/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 kasan_kmalloc mm/kasan/kasan.c:553 [inline]
 kasan_kmalloc+0xce/0xf0 mm/kasan/kasan.c:531
 kmem_cache_alloc_node_trace+0x153/0x720 mm/slab.c:3668
 __do_kmalloc_node mm/slab.c:3688 [inline]
 __kmalloc_node+0x3d/0x80 mm/slab.c:3696
 kmalloc_node include/linux/slab.h:557 [inline]
 __vmalloc_area_node mm/vmalloc.c:1677 [inline]
 __vmalloc_node_range+0x1f8/0x790 mm/vmalloc.c:1750
 __vmalloc_node mm/vmalloc.c:1801 [inline]
 __vmalloc_node_flags mm/vmalloc.c:1815 [inline]
 vzalloc+0x6b/0x90 mm/vmalloc.c:1854
 adjust_insn_aux_data kernel/bpf/verifier.c:5548 [inline]
 bpf_patch_insn_data+0xfd/0x330 kernel/bpf/verifier.c:5584
 convert_ctx_accesses+0x986/0x13e0 kernel/bpf/verifier.c:5754
 bpf_check+0x206d/0x6259 kernel/bpf/verifier.c:6334
 bpf_prog_load+0xdcf/0x13f0 kernel/bpf/syscall.c:1445
 __do_sys_bpf kernel/bpf/syscall.c:2411 [inline]
 __se_sys_bpf kernel/bpf/syscall.c:2373 [inline]
 __x64_sys_bpf+0x32b/0x4c0 kernel/bpf/syscall.c:2373
 do_syscall_64+0xfd/0x620 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x446949
Code: e8 0c e8 ff ff 48 83 c4 18 c3 0f 1f 80 00 00 00 00 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 5b 07 fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007fed49b0edb8 EFLAGS: 00000246 ORIG_RAX: 0000000000000141
RAX: ffffffffffffffda RBX: 00000000006dbc28 RCX: 0000000000446949
RDX: 0000000000000032 RSI: 0000000020000440 RDI: 0000000000000005
RBP: 00000000006dbc20 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00000000006dbc2c
R13: 00007ffe1659767f R14: 00007fed49b0f9c0 R15: 000000000000002d

Allocated by task 8444:
 save_stack+0x45/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 kasan_kmalloc mm/kasan/kasan.c:553 [inline]
 kasan_kmalloc+0xce/0xf0 mm/kasan/kasan.c:531
 kmem_cache_alloc_trace+0x152/0x760 mm/slab.c:3625
 kmalloc include/linux/slab.h:515 [inline]
 kzalloc include/linux/slab.h:709 [inline]
 bpf_prog_alloc+0x216/0x2a0 kernel/bpf/core.c:90
 jit_subprogs kernel/bpf/verifier.c:5814 [inline]
 fixup_call_args kernel/bpf/verifier.c:5933 [inline]
 bpf_check+0x3e7f/0x6259 kernel/bpf/verifier.c:6340
 bpf_prog_load+0xdcf/0x13f0 kernel/bpf/syscall.c:1445
 __do_sys_bpf kernel/bpf/syscall.c:2411 [inline]
 __se_sys_bpf kernel/bpf/syscall.c:2373 [inline]
 __x64_sys_bpf+0x32b/0x4c0 kernel/bpf/syscall.c:2373
 do_syscall_64+0xfd/0x620 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 14:
 save_stack+0x45/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:3503 [inline]
 kfree+0xcf/0x220 mm/slab.c:3822
 bpf_jit_free+0xa5/0x300
 bpf_prog_free_deferred+0x1a6/0x420 kernel/bpf/core.c:1809
 process_one_work+0x989/0x1750 kernel/workqueue.c:2153
 worker_thread+0x98/0xe40 kernel/workqueue.c:2296
 kthread+0x354/0x420 kernel/kthread.c:246
 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:415

The buggy address belongs to the object at ffff8880a5a07140
 which belongs to the cache kmalloc-256 of size 256
The buggy address is located 64 bytes inside of
 256-byte region [ffff8880a5a07140, ffff8880a5a07240)
The buggy address belongs to the page:
page:ffffea00029681c0 count:1 mapcount:0 mapping:ffff88812c3f07c0 index:0x0
flags: 0x1fffc0000000100(slab)
raw: 01fffc0000000100 ffffea0002923988 ffffea00024c3188 ffff88812c3f07c0
raw: 0000000000000000 ffff8880a5a07000 000000010000000c 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8880a5a07080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880a5a07100: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
>ffff8880a5a07180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                   ^
 ffff8880a5a07200: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
 ffff8880a5a07280: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
==================================================================

Crashes (11):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2019/10/25 23:29 linux-4.19.y c3038e718a19 04ca72cd .config console log report syz C ci2-linux-4-19
2019/10/20 03:14 linux-4.19.y c3038e718a19 8c88c9c1 .config console log report syz C ci2-linux-4-19
2019/10/14 05:49 linux-4.19.y dafd634415a7 2f661ec4 .config console log report syz C ci2-linux-4-19
2021/01/27 18:16 linux-4.19.y c4ff839de17f a57db36f .config console log report info ci2-linux-4-19 KASAN: use-after-free Read in bpf_prog_kallsyms_find
2020/08/16 16:32 linux-4.19.y c14d30dc9987 5ce13532 .config console log report ci2-linux-4-19
2020/02/01 19:22 linux-4.19.y 32ee7492f104 326d4c78 .config console log report ci2-linux-4-19
2020/01/30 12:12 linux-4.19.y 7cdefde351b6 5ed23f9a .config console log report ci2-linux-4-19
2020/01/10 13:15 linux-4.19.y cb1f9a169a0e 4de4e9f0 .config console log report ci2-linux-4-19
2019/12/27 02:17 linux-4.19.y 672481c2deff be5c2c81 .config console log report ci2-linux-4-19
2019/12/23 09:06 linux-4.19.y 672481c2deff 8b967267 .config console log report ci2-linux-4-19
2019/10/19 21:45 linux-4.19.y c3038e718a19 8c88c9c1 .config console log report ci2-linux-4-19
* Struck through repros no longer work on HEAD.