syzbot


KASAN: slab-out-of-bounds Read in do_jit

Status: fixed on 2019/09/06 20:45
Subsystems: kernel
[Documentation on labels]
Reported-by: syzbot+6b40f58c6d280fa23b40@syzkaller.appspotmail.com
Fix commit: 7c2e988f400e bpf: fix x64 JIT code generation for jmp to 1st insn
First crash: 1910d, last: 1862d
Cause bisection: introduced by (bisect log) :
commit 2589726d12a1b12eaaa93c7f1ea64287e383c7a5
Author: Alexei Starovoitov <ast@kernel.org>
Date: Sat Jun 15 19:12:20 2019 +0000

  bpf: introduce bounded loops

Crash: KASAN: slab-out-of-bounds Read in do_jit (log)
Repro: C syz .config
  
Discussions (2)
Title Replies (including bot) Last reply
Reminder: 8 active syzbot reports in "net/bpf" subsystem 1 (1) 2019/08/16 04:17
KASAN: slab-out-of-bounds Read in do_jit 0 (1) 2019/07/23 16:18
Last patch testing requests (1)
Created Duration User Patch Repo Result
2019/08/26 08:28 17m daniel@iogearbox.net bpf OK

Sample crash report:
==================================================================
BUG: KASAN: slab-out-of-bounds in do_jit.isra.0+0x4c35/0x5630 /arch/x86/net/bpf_jit_comp.c:966
Read of size 4 at addr ffff8880a78dda3c by task syz-executor712/9233

CPU: 1 PID: 9233 Comm: syz-executor712 Not tainted 5.2.0+ #64
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+0x16f/0x1f0 /lib/dump_stack.c:113
 print_address_description.cold+0xd4/0x306 /mm/kasan/report.c:351
 __kasan_report.cold+0x1b/0x36 /mm/kasan/report.c:482
 kasan_report+0x12/0x17 /mm/kasan/common.c:612
 __asan_report_load4_noabort+0x14/0x20 /mm/kasan/generic_report.c:131
 do_jit.isra.0+0x4c35/0x5630 /arch/x86/net/bpf_jit_comp.c:966
 bpf_int_jit_compile+0x379/0xda5 /arch/x86/net/bpf_jit_comp.c:1132
 bpf_prog_select_runtime+0x4cd/0x7d0 /kernel/bpf/core.c:1725
 bpf_prog_load+0xe9b/0x1640 /kernel/bpf/syscall.c:1702
 __do_sys_bpf+0xa23/0x4240 /kernel/bpf/syscall.c:2849
 __se_sys_bpf /kernel/bpf/syscall.c:2808 [inline]
 __x64_sys_bpf+0x73/0xb0 /kernel/bpf/syscall.c:2808
 do_syscall_64+0xfd/0x6a0 /arch/x86/entry/common.c:296
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x4402c9
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:00007fff9f037ed8 EFLAGS: 00000246 ORIG_RAX: 0000000000000141
RAX: ffffffffffffffda RBX: 00000000004002c8 RCX: 00000000004402c9
RDX: 0000000000000046 RSI: 0000000020000180 RDI: 0000000000000005
RBP: 00000000006ca018 R08: 0000000000000000 R09: 0000000000000000
R10: 00000000ffffffff R11: 0000000000000246 R12: 0000000000401b50
R13: 0000000000401be0 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 9075:
 save_stack+0x23/0x90 /mm/kasan/common.c:69
 set_track /mm/kasan/common.c:77 [inline]
 __kasan_kmalloc /mm/kasan/common.c:487 [inline]
 __kasan_kmalloc.constprop.0+0xcf/0xe0 /mm/kasan/common.c:460
 kasan_kmalloc+0x9/0x10 /mm/kasan/common.c:501
 __do_kmalloc /mm/slab.c:3655 [inline]
 __kmalloc+0x163/0x760 /mm/slab.c:3664
 kmalloc /./include/linux/slab.h:557 [inline]
 kzalloc /./include/linux/slab.h:748 [inline]
 tomoyo_encode2.part.0+0xf5/0x400 /security/tomoyo/realpath.c:44
 tomoyo_encode2 /security/tomoyo/realpath.c:30 [inline]
 tomoyo_encode+0x2b/0x50 /security/tomoyo/realpath.c:79
 tomoyo_realpath_from_path+0x1d3/0x7b0 /security/tomoyo/realpath.c:316
 tomoyo_init_log+0xc63/0x2070 /security/tomoyo/audit.c:263
 tomoyo_supervisor+0x33f/0xef0 /security/tomoyo/common.c:2095
 tomoyo_audit_env_log /security/tomoyo/environ.c:36 [inline]
 tomoyo_env_perm+0x18e/0x210 /security/tomoyo/environ.c:63
 tomoyo_environ /security/tomoyo/domain.c:670 [inline]
 tomoyo_find_next_domain+0x1354/0x1f6c /security/tomoyo/domain.c:876
 tomoyo_bprm_check_security /security/tomoyo/tomoyo.c:107 [inline]
 tomoyo_bprm_check_security+0x124/0x1b0 /security/tomoyo/tomoyo.c:97
 security_bprm_check+0x63/0xb0 /security/security.c:750
 search_binary_handler+0x71/0x570 /fs/exec.c:1645
 exec_binprm /fs/exec.c:1701 [inline]
 __do_execve_file.isra.0+0x133b/0x2310 /fs/exec.c:1821
 do_execveat_common /fs/exec.c:1868 [inline]
 do_execve /fs/exec.c:1885 [inline]
 __do_sys_execve /fs/exec.c:1961 [inline]
 __se_sys_execve /fs/exec.c:1956 [inline]
 __x64_sys_execve+0x8f/0xc0 /fs/exec.c:1956
 do_syscall_64+0xfd/0x6a0 /arch/x86/entry/common.c:296
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 9075:
 save_stack+0x23/0x90 /mm/kasan/common.c:69
 set_track /mm/kasan/common.c:77 [inline]
 __kasan_slab_free+0x102/0x150 /mm/kasan/common.c:449
 kasan_slab_free+0xe/0x10 /mm/kasan/common.c:457
 __cache_free /mm/slab.c:3425 [inline]
 kfree+0x10a/0x2a0 /mm/slab.c:3756
 tomoyo_init_log+0x15b2/0x2070 /security/tomoyo/audit.c:292
 tomoyo_supervisor+0x33f/0xef0 /security/tomoyo/common.c:2095
 tomoyo_audit_env_log /security/tomoyo/environ.c:36 [inline]
 tomoyo_env_perm+0x18e/0x210 /security/tomoyo/environ.c:63
 tomoyo_environ /security/tomoyo/domain.c:670 [inline]
 tomoyo_find_next_domain+0x1354/0x1f6c /security/tomoyo/domain.c:876
 tomoyo_bprm_check_security /security/tomoyo/tomoyo.c:107 [inline]
 tomoyo_bprm_check_security+0x124/0x1b0 /security/tomoyo/tomoyo.c:97
 security_bprm_check+0x63/0xb0 /security/security.c:750
 search_binary_handler+0x71/0x570 /fs/exec.c:1645
 exec_binprm /fs/exec.c:1701 [inline]
 __do_execve_file.isra.0+0x133b/0x2310 /fs/exec.c:1821
 do_execveat_common /fs/exec.c:1868 [inline]
 do_execve /fs/exec.c:1885 [inline]
 __do_sys_execve /fs/exec.c:1961 [inline]
 __se_sys_execve /fs/exec.c:1956 [inline]
 __x64_sys_execve+0x8f/0xc0 /fs/exec.c:1956
 do_syscall_64+0xfd/0x6a0 /arch/x86/entry/common.c:296
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff8880a78dda00
 which belongs to the cache kmalloc-32 of size 32
The buggy address is located 28 bytes to the right of
 32-byte region [ffff8880a78dda00, ffff8880a78dda20)
The buggy address belongs to the page:
page:ffffea00029e3740 refcount:1 mapcount:0 mapping:ffff8880aa4001c0 index:0xffff8880a78ddfc1
flags: 0x1fffc0000000200(slab)
raw: 01fffc0000000200 ffffea00029e31c8 ffffea0002927f08 ffff8880aa4001c0
raw: ffff8880a78ddfc1 ffff8880a78dd000 000000010000002f 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8880a78dd900: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc
 ffff8880a78dd980: 00 00 01 fc fc fc fc fc fb fb fb fb fc fc fc fc
>ffff8880a78dda00: fb fb fb fb fc fc fc fc 00 00 fc fc fc fc fc fc
                                        ^
 ffff8880a78dda80: 00 01 fc fc fc fc fc fc 00 00 01 fc fc fc fc fc
 ffff8880a78ddb00: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc
==================================================================

Crashes (16):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2019/07/21 03:49 upstream c6dd78fcb8ee 1656845f .config console log report syz C ci-upstream-kasan-gce-selinux-root
2019/07/21 03:30 upstream c6dd78fcb8ee 1656845f .config console log report syz C ci-upstream-kasan-gce-root
2019/07/21 03:25 bpf 1d4126c4e119 1656845f .config console log report syz C ci-upstream-bpf-kasan-gce
2019/07/21 03:24 net-old 89099d855bf0 1656845f .config console log report syz C ci-upstream-net-this-kasan-gce
2019/07/21 04:08 net-next-old 31cc088a4f5d 1656845f .config console log report syz C ci-upstream-net-kasan-gce
2019/07/21 03:24 bpf-next 192f0f8e9db7 1656845f .config console log report syz C ci-upstream-bpf-next-kasan-gce
2019/07/21 03:39 linux-next 6d21a41b7b1f 1656845f .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2019/09/06 17:52 bpf-next 310f4204eeb6 040fda58 .config console log report ci-upstream-bpf-next-kasan-gce
2019/08/15 20:56 net-next-old ecb9f80db23a 0d298d6b .config console log report ci-upstream-net-kasan-gce
2019/08/13 16:00 bpf-next 192f0f8e9db7 8620c2c2 .config console log report ci-upstream-bpf-next-kasan-gce
2019/08/09 21:32 net-next-old fcc32a21655e ede31a9b .config console log report ci-upstream-net-kasan-gce
2019/08/04 13:50 net-next-old 31cc088a4f5d 6affd8e8 .config console log report ci-upstream-net-kasan-gce
2019/08/02 16:44 bpf-next 192f0f8e9db7 835dffe7 .config console log report ci-upstream-bpf-next-kasan-gce
2019/08/02 03:38 bpf-next 192f0f8e9db7 835dffe7 .config console log report ci-upstream-bpf-next-kasan-gce
2019/07/30 05:43 net-next-old 31cc088a4f5d f67095ee .config console log report ci-upstream-net-kasan-gce
2019/07/23 20:51 bpf-next 192f0f8e9db7 de453f34 .config console log report ci-upstream-bpf-next-kasan-gce
* Struck through repros no longer work on HEAD.