syzbot


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

Status: upstream: reported C repro on 2019/01/07 13:31
Reported-by: syzbot+660883c56e2fa65d4497@syzkaller.appspotmail.com
First crash: 1271d, last: 743d

Cause bisection: introduced by (bisect log) :
commit c470abd4fde40ea6a0846a2beab642a578c0b8cd
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date: Sun Feb 19 22:34:00 2017 +0000

  Linux 4.10


Fix bisection: the fix commit could be any of (bisect log):
  6b643a07a7e4 x86/entry, ubsan, objtool: Whitelist __ubsan_handle_*()
  8e8bb06d199a x86/entry, bug: Comment the instrumentation_begin() usage for WARN()
  14d3b376b6c3 x86/entry, cpumask: Provide non-instrumented variant of cpu_is_offline()
  33aea07f30c2 compiler_attributes.h: Support no_sanitize_undefined check with GCC 4
  5144f8a8dfd7 compiler_types.h: Add __no_sanitize_{address,undefined} to noinstr
  acf7b0bf7dcf kasan: Fix required compiler version
  734d099ba644 objtool: Don't consider vmlinux a C-file
  7b861a53e46b kasan: Bump required compiler version
  5ddbc4082e10 x86, kcsan: Add __no_kcsan to noinstr
  e3a9e681adb7 x86/entry: Fixup bad_iret vs noinstr
  c7aadc09321d x86/entry: Increase entry_stack size to a full page
  e79302ae8c8c kcsan: Remove __no_kcsan_or_inline
  145a773aef83 x86/entry: Fix #UD vs WARN more
  e82587336695 x86, kcsan: Remove __no_kcsan_or_inline usage
  2c92d787cc9f Merge branch 'linus' into x86/entry, to resolve conflicts
similar bugs (1):
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.19 KASAN: slab-out-of-bounds Read in bacpy C done 3 694d 1156d 1/1 fixed on 2020/09/09 05:22
Patch testing requests:
Created Duration User Patch Repo Result
2019/03/18 20:02 18m xiyou.wangcong@gmail.com https://github.com/congwang/linux.git bluetooth OK

Sample crash report:
==================================================================
BUG: KASAN: slab-out-of-bounds in memcpy include/linux/string.h:380 [inline]
BUG: KASAN: slab-out-of-bounds in bacpy+0x23/0x30 include/net/bluetooth/bluetooth.h:236
Read of size 6 at addr ffff888099490a08 by task kworker/u5:0/1595

CPU: 1 PID: 1595 Comm: kworker/u5:0 Not tainted 5.5.0-rc4-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: hci0 hci_rx_work
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x197/0x210 lib/dump_stack.c:118
 print_address_description.constprop.0.cold+0xd4/0x30b mm/kasan/report.c:374
 __kasan_report.cold+0x1b/0x41 mm/kasan/report.c:506
 kasan_report+0x12/0x20 mm/kasan/common.c:639
 check_memory_region_inline mm/kasan/generic.c:185 [inline]
 check_memory_region+0x134/0x1a0 mm/kasan/generic.c:192
 memcpy+0x24/0x50 mm/kasan/common.c:125
 memcpy include/linux/string.h:380 [inline]
 bacpy+0x23/0x30 include/net/bluetooth/bluetooth.h:236
 hci_extended_inquiry_result_evt net/bluetooth/hci_event.c:4281 [inline]
 hci_event_packet+0x506d/0xa8fb net/bluetooth/hci_event.c:5959
 hci_rx_work+0x4b7/0xb20 net/bluetooth/hci_core.c:4491
 process_one_work+0x9af/0x1740 kernel/workqueue.c:2264
 worker_thread+0x98/0xe40 kernel/workqueue.c:2410
 kthread+0x361/0x430 kernel/kthread.c:255
 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352

Allocated by task 10047:
 save_stack+0x23/0x90 mm/kasan/common.c:72
 set_track mm/kasan/common.c:80 [inline]
 __kasan_kmalloc mm/kasan/common.c:513 [inline]
 __kasan_kmalloc.constprop.0+0xcf/0xe0 mm/kasan/common.c:486
 kasan_kmalloc+0x9/0x10 mm/kasan/common.c:527
 __do_kmalloc_node mm/slab.c:3616 [inline]
 __kmalloc_node_track_caller+0x4e/0x70 mm/slab.c:3630
 __kmalloc_reserve.isra.0+0x40/0xf0 net/core/skbuff.c:141
 __alloc_skb+0x10b/0x5e0 net/core/skbuff.c:209
 alloc_skb include/linux/skbuff.h:1049 [inline]
 bt_skb_alloc include/net/bluetooth/bluetooth.h:339 [inline]
 vhci_get_user drivers/bluetooth/hci_vhci.c:165 [inline]
 vhci_write+0xc4/0x470 drivers/bluetooth/hci_vhci.c:284
 call_write_iter include/linux/fs.h:1902 [inline]
 new_sync_write+0x4d3/0x770 fs/read_write.c:483
 __vfs_write+0xe1/0x110 fs/read_write.c:496
 vfs_write+0x268/0x5d0 fs/read_write.c:558
 ksys_write+0x14f/0x290 fs/read_write.c:611
 __do_sys_write fs/read_write.c:623 [inline]
 __se_sys_write fs/read_write.c:620 [inline]
 __x64_sys_write+0x73/0xb0 fs/read_write.c:620
 do_syscall_64+0xfa/0x790 arch/x86/entry/common.c:294
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 9614:
 save_stack+0x23/0x90 mm/kasan/common.c:72
 set_track mm/kasan/common.c:80 [inline]
 kasan_set_free_info mm/kasan/common.c:335 [inline]
 __kasan_slab_free+0x102/0x150 mm/kasan/common.c:474
 kasan_slab_free+0xe/0x10 mm/kasan/common.c:483
 __cache_free mm/slab.c:3426 [inline]
 kfree+0x10a/0x2c0 mm/slab.c:3757
 tomoyo_supervisor+0x360/0xef0 security/tomoyo/common.c:2149
 tomoyo_audit_path_log security/tomoyo/file.c:168 [inline]
 tomoyo_path_permission security/tomoyo/file.c:587 [inline]
 tomoyo_path_permission+0x263/0x360 security/tomoyo/file.c:573
 tomoyo_path_perm+0x318/0x430 security/tomoyo/file.c:838
 tomoyo_inode_getattr+0x1d/0x30 security/tomoyo/tomoyo.c:129
 security_inode_getattr+0xf2/0x150 security/security.c:1222
 vfs_getattr+0x25/0x70 fs/stat.c:115
 vfs_statx+0x157/0x200 fs/stat.c:191
 vfs_stat include/linux/fs.h:3249 [inline]
 __do_sys_newstat+0xa4/0x130 fs/stat.c:341
 __se_sys_newstat fs/stat.c:337 [inline]
 __x64_sys_newstat+0x54/0x80 fs/stat.c:337
 do_syscall_64+0xfa/0x790 arch/x86/entry/common.c:294
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff888099490800
 which belongs to the cache kmalloc-512 of size 512
The buggy address is located 8 bytes to the right of
 512-byte region [ffff888099490800, ffff888099490a00)
The buggy address belongs to the page:
page:ffffea0002652400 refcount:1 mapcount:0 mapping:ffff8880aa400a80 index:0x0
raw: 00fffe0000000200 ffffea0002a48488 ffffea00029a2888 ffff8880aa400a80
raw: 0000000000000000 ffff888099490000 0000000100000004 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff888099490900: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff888099490980: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff888099490a00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
                      ^
 ffff888099490a80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff888099490b00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Crashes (21):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-kasan-gce-selinux-root 2020/01/01 21:03 upstream 738d2902773e 25a0186e .config log report syz C
ci-upstream-kasan-gce-root 2020/01/01 21:01 upstream 738d2902773e 25a0186e .config log report syz C
ci-upstream-kasan-gce-root 2019/05/02 03:00 upstream 459e3a21535a 7516d9fa .config log report syz C
ci-upstream-kasan-gce-selinux-root 2019/05/02 02:54 upstream 459e3a21535a 7516d9fa .config log report syz C
ci-upstream-kasan-gce 2019/05/02 02:53 upstream 459e3a21535a 7516d9fa .config log report syz C
ci-upstream-kasan-gce-smack-root 2019/05/02 02:52 upstream 459e3a21535a 7516d9fa .config log report syz C
ci-upstream-kasan-gce 2019/01/07 10:00 upstream 574823bfab82 ee332608 .config log report syz C
ci-upstream-kasan-gce-root 2019/01/07 09:58 upstream 574823bfab82 ee332608 .config log report syz C
ci-upstream-kasan-gce-smack-root 2019/01/07 09:57 upstream 574823bfab82 ee332608 .config log report syz C
ci-upstream-kasan-gce-selinux-root 2019/01/07 09:26 upstream 574823bfab82 ee332608 .config log report syz C
ci-upstream-kasan-gce-386 2020/01/01 21:36 upstream 738d2902773e 25a0186e .config log report syz C
ci-upstream-kasan-gce-386 2019/05/02 02:54 upstream 459e3a21535a 7516d9fa .config log report syz C
ci-upstream-kasan-gce-386 2019/01/07 10:00 upstream 574823bfab82 ee332608 .config log report syz C
ci-upstream-linux-next-kasan-gce-root 2020/01/08 06:28 linux-next 264673852033 6738e0b3 .config log report syz C
ci-upstream-linux-next-kasan-gce-root 2019/05/02 02:53 linux-next bf2c8035bd8b 7516d9fa .config log report syz C
ci-upstream-linux-next-kasan-gce-root 2019/01/07 09:57 linux-next a85b6b4f6416 ee332608 .config log report syz C
ci-upstream-kasan-gce 2019/12/18 10:44 upstream 2187f215ebaa f2fe0772 .config log report
ci-upstream-kasan-gce-selinux-root 2019/11/01 08:02 upstream e472c64aa4fa a41ca8fa .config log report
ci-upstream-kasan-gce-root 2019/08/20 21:25 upstream 5f97cbe22b76 cfc9868f .config log report
ci-upstream-kasan-gce-smack-root 2019/03/07 16:51 upstream f90d64483ebd 8c085c5e .config log report
ci-upstream-kasan-gce-selinux-root 2019/01/07 09:03 upstream 574823bfab82 ee332608 .config log report