syzbot


KASAN: slab-out-of-bounds Write in queue_stack_map_push_elem

Status: fixed on 2018/12/07 08:24
Subsystems: bpf
[Documentation on labels]
Reported-by: syzbot+36cf9e58446a643bfa14@syzkaller.appspotmail.com
Fix commit: 813961de3ee6 bpf: fix integer overflow in queue_stack_map
First crash: 2005d, last: 2003d
Discussions (1)
Title Replies (including bot) Last reply
KASAN: slab-out-of-bounds Write in queue_stack_map_push_elem 0 (1) 2018/11/25 13:50

Sample crash report:
audit: type=1800 audit(1543151244.938:30): pid=5875 uid=0 auid=4294967295 ses=4294967295 subj==unconfined op=collect_data cause=failed(directio) comm="startpar" name="rmnologin" dev="sda1" ino=2423 res=0
==================================================================
BUG: KASAN: slab-out-of-bounds in memcpy include/linux/string.h:352 [inline]
BUG: KASAN: slab-out-of-bounds in queue_stack_map_push_elem+0x185/0x290 kernel/bpf/queue_stack_maps.c:230
Write of size 262146 at addr ffff8881be5e48c8 by task syz-executor486/6030

CPU: 1 PID: 6030 Comm: syz-executor486 Not tainted 4.20.0-rc3+ #348
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
 check_memory_region_inline mm/kasan/kasan.c:260 [inline]
 check_memory_region+0x13e/0x1b0 mm/kasan/kasan.c:267
 memcpy+0x37/0x50 mm/kasan/kasan.c:303
 memcpy include/linux/string.h:352 [inline]
 queue_stack_map_push_elem+0x185/0x290 kernel/bpf/queue_stack_maps.c:230
 map_update_elem+0x605/0xf60 kernel/bpf/syscall.c:865
 __do_sys_bpf kernel/bpf/syscall.c:2495 [inline]
 __se_sys_bpf kernel/bpf/syscall.c:2466 [inline]
 __x64_sys_bpf+0x32d/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:0x4400e9
Code: 18 89 d0 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 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 fb 13 fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007ffc9cbf8ad8 EFLAGS: 00000213 ORIG_RAX: 0000000000000141
RAX: ffffffffffffffda RBX: 00000000004002c8 RCX: 00000000004400e9
RDX: 0000000000000020 RSI: 0000000020000040 RDI: 0000000000000002
RBP: 00000000006ca018 R08: 0000000000000000 R09: 00000000004002c8
R10: 0000000000000000 R11: 0000000000000213 R12: 0000000000401970
R13: 0000000000401a00 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 6030:
 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
 __do_kmalloc_node mm/slab.c:3684 [inline]
 __kmalloc_node+0x50/0x70 mm/slab.c:3691
 kmalloc_node include/linux/slab.h:589 [inline]
 bpf_map_area_alloc+0x3f/0x90 kernel/bpf/syscall.c:147
 queue_stack_map_alloc+0x192/0x290 kernel/bpf/queue_stack_maps.c:84
 find_and_alloc_map kernel/bpf/syscall.c:129 [inline]
 map_create+0x3bd/0x1110 kernel/bpf/syscall.c:509
 __do_sys_bpf kernel/bpf/syscall.c:2489 [inline]
 __se_sys_bpf kernel/bpf/syscall.c:2466 [inline]
 __x64_sys_bpf+0x303/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 3753:
 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
 kernfs_fop_release+0x12b/0x1a0 fs/kernfs/file.c:783
 __fput+0x385/0xa30 fs/file_table.c:278
 ____fput+0x15/0x20 fs/file_table.c:309
 task_work_run+0x1e8/0x2a0 kernel/task_work.c:113
 tracehook_notify_resume include/linux/tracehook.h:188 [inline]
 exit_to_usermode_loop+0x318/0x380 arch/x86/entry/common.c:166
 prepare_exit_to_usermode arch/x86/entry/common.c:197 [inline]
 syscall_return_slowpath arch/x86/entry/common.c:268 [inline]
 do_syscall_64+0x6be/0x820 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff8881be5e4780
 which belongs to the cache kmalloc-512 of size 512
The buggy address is located 328 bytes inside of
 512-byte region [ffff8881be5e4780, ffff8881be5e4980)
The buggy address belongs to the page:
page:ffffea0006f97900 count:1 mapcount:0 mapping:ffff8881da800940 index:0x0
flags: 0x2fffc0000000200(slab)
raw: 02fffc0000000200 ffffea0006fc1508 ffffea0006f879c8 ffff8881da800940
raw: 0000000000000000 ffff8881be5e4000 0000000100000006 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8881be5e4800: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff8881be5e4880: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff8881be5e4900: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
                   ^
 ffff8881be5e4980: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff8881be5e4a00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (30):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2018/11/25 13:10 upstream e195ca6cb6f2 3d3ec907 .config console log report syz C ci-upstream-kasan-gce-root
2018/11/25 13:00 upstream e195ca6cb6f2 3d3ec907 .config console log report syz C ci-upstream-kasan-gce-selinux-root
2018/11/25 12:51 upstream e195ca6cb6f2 3d3ec907 .config console log report syz C ci-upstream-kasan-gce-root
2018/11/25 12:26 upstream e195ca6cb6f2 3d3ec907 .config console log report syz C ci-upstream-kasan-gce-smack-root
2018/11/25 12:17 upstream e195ca6cb6f2 3d3ec907 .config console log report syz C ci-upstream-kasan-gce-selinux-root
2018/11/25 11:57 upstream e195ca6cb6f2 3d3ec907 .config console log report syz C ci-upstream-kasan-gce
2018/11/25 11:46 upstream e195ca6cb6f2 3d3ec907 .config console log report syz C ci-upstream-kasan-gce-smack-root
2018/11/25 11:28 upstream e195ca6cb6f2 3d3ec907 .config console log report syz C ci-upstream-kasan-gce-root
2018/11/25 11:27 upstream e195ca6cb6f2 3d3ec907 .config console log report syz C ci-upstream-kasan-gce-smack-root
2018/11/25 10:47 upstream e195ca6cb6f2 3d3ec907 .config console log report syz C ci-upstream-kasan-gce-selinux-root
2018/11/25 10:23 upstream e195ca6cb6f2 3d3ec907 .config console log report syz C ci-upstream-kasan-gce
2018/11/25 12:23 upstream e195ca6cb6f2 3d3ec907 .config console log report syz C ci-upstream-kasan-gce-386
2018/11/25 12:03 upstream e195ca6cb6f2 3d3ec907 .config console log report syz C ci-upstream-kasan-gce-386
2018/11/25 11:06 net-old aba36930a35e 3d3ec907 .config console log report syz C ci-upstream-net-this-kasan-gce
2018/11/25 10:43 net-old aba36930a35e 3d3ec907 .config console log report syz C ci-upstream-net-this-kasan-gce
2018/11/25 11:07 net-next-old 358be656406d 3d3ec907 .config console log report syz C ci-upstream-net-kasan-gce
2018/11/25 11:07 bpf-next 197c2dac74e4 3d3ec907 .config console log report syz C ci-upstream-bpf-next-kasan-gce
2018/11/25 10:43 bpf-next 197c2dac74e4 3d3ec907 .config console log report syz C ci-upstream-bpf-next-kasan-gce
2018/11/25 10:41 net-next-old 358be656406d 3d3ec907 .config console log report syz C ci-upstream-net-kasan-gce
2018/11/25 13:27 linux-next 442b8cea2477 3d3ec907 .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2018/11/25 12:44 linux-next 442b8cea2477 3d3ec907 .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2018/11/25 12:25 linux-next 442b8cea2477 3d3ec907 .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2018/11/27 20:17 upstream ef78e5ec9214 4b6d14f2 .config console log report ci-upstream-kasan-gce-smack-root
2018/11/26 08:21 upstream d6d460b89378 3d3ec907 .config console log report ci-upstream-kasan-gce
2018/11/25 09:31 upstream e195ca6cb6f2 3d3ec907 .config console log report ci-upstream-kasan-gce
2018/11/25 09:28 upstream e195ca6cb6f2 3d3ec907 .config console log report ci-upstream-kasan-gce-root
2018/11/25 09:27 upstream e195ca6cb6f2 3d3ec907 .config console log report ci-upstream-kasan-gce-selinux-root
2018/11/26 22:01 bpf-next ffac28f95a98 ac912200 .config console log report ci-upstream-bpf-next-kasan-gce
2018/11/26 19:36 bpf-next ffac28f95a98 ac912200 .config console log report ci-upstream-bpf-next-kasan-gce
2018/11/26 08:19 bpf-next cf0dd411e80f 3d3ec907 .config console log report ci-upstream-bpf-next-kasan-gce
* Struck through repros no longer work on HEAD.