bisecting fixing commit since 54b4fa6d39551639cb10664f6ac78b01993a1d7e building syzkaller on 831e9a81a60573f12c44f35c7b04072f41854bdf testing commit 54b4fa6d39551639cb10664f6ac78b01993a1d7e with gcc (GCC) 8.4.1 20210217 kernel signature: e5faf1e350361f90a34eb223b67b50298af7ec11e96b3651139c69780b451d21 all runs: crashed: KASAN: use-after-free Write in hci_sock_bind testing current HEAD 78fec1611cbf7b0bdaddfdbf174a3a2463663bff testing commit 78fec1611cbf7b0bdaddfdbf174a3a2463663bff with gcc (GCC) 8.4.1 20210217 kernel signature: d8124e12e1b25e47bf23bdae45450474f847b74efd40fbbda81905b21767407c all runs: crashed: KASAN: use-after-free Write in hci_sock_bind revisions tested: 2, total time: 32m59.690104446s (build: 16m4.143263078s, test: 16m28.528029075s) the crash still happens on HEAD commit msg: Linux 4.19.183 crash: KASAN: use-after-free Write in hci_sock_bind systemd[1]: bluetooth.target: Unit not needed anymore. Stopping. systemd[1]: bluetooth.target: Unit not needed anymore. Stopping. systemd[1]: bluetooth.target: Unit not needed anymore. Stopping. systemd[1]: bluetooth.target: Unit not needed anymore. Stopping. ================================================================== BUG: KASAN: use-after-free in atomic_inc include/asm-generic/atomic-instrumented.h:109 [inline] BUG: KASAN: use-after-free in hci_sock_bind+0x66b/0xf30 net/bluetooth/hci_sock.c:1226 Write of size 4 at addr ffff8881ddc86a20 by task syz-executor855/3690 CPU: 1 PID: 3690 Comm: syz-executor855 Not tainted 4.19.183-syzkaller #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+0x123/0x171 lib/dump_stack.c:118 print_address_description.cold.8+0x9/0x1ff 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.9+0x242/0x2fe mm/kasan/report.c:396 check_memory_region_inline mm/kasan/kasan.c:260 [inline] check_memory_region+0x13e/0x1b0 mm/kasan/kasan.c:267 kasan_check_write+0x14/0x20 mm/kasan/kasan.c:278 atomic_inc include/asm-generic/atomic-instrumented.h:109 [inline] hci_sock_bind+0x66b/0xf30 net/bluetooth/hci_sock.c:1226 __sys_bind+0x1e1/0x230 net/socket.c:1482 __do_sys_bind net/socket.c:1493 [inline] __se_sys_bind net/socket.c:1491 [inline] __x64_sys_bind+0x6e/0xb0 net/socket.c:1491 do_syscall_64+0xd0/0x4e0 arch/x86/entry/common.c:293 entry_SYSCALL_64_after_hwframe+0x49/0xbe RIP: 0033:0x445809 Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 11 15 00 00 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 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f145beb5318 EFLAGS: 00000246 ORIG_RAX: 0000000000000031 RAX: ffffffffffffffda RBX: 00000000004ca428 RCX: 0000000000445809 RDX: 0000000000000006 RSI: 0000000020000080 RDI: 0000000000000004 RBP: 00000000004ca420 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 6368762f7665642f R13: 00007ffe2625c73f R14: 00007f145beb5400 R15: 0000000000022000 Allocated by task 3687: save_stack+0x43/0xd0 mm/kasan/kasan.c:448 set_track mm/kasan/kasan.c:460 [inline] kasan_kmalloc mm/kasan/kasan.c:553 [inline] kasan_kmalloc+0xc7/0xe0 mm/kasan/kasan.c:531 kmem_cache_alloc_trace+0x152/0x740 mm/slab.c:3625 kmalloc include/linux/slab.h:515 [inline] kzalloc include/linux/slab.h:709 [inline] hci_alloc_dev+0x3f/0x1bd0 net/bluetooth/hci_core.c:3055 __vhci_create_device+0xe1/0x500 drivers/bluetooth/hci_vhci.c:114 vhci_create_device drivers/bluetooth/hci_vhci.c:163 [inline] vhci_get_user drivers/bluetooth/hci_vhci.c:219 [inline] vhci_write+0x28a/0x3f0 drivers/bluetooth/hci_vhci.c:299 call_write_iter include/linux/fs.h:1821 [inline] new_sync_write fs/read_write.c:474 [inline] __vfs_write+0x443/0x890 fs/read_write.c:487 vfs_write+0x150/0x4d0 fs/read_write.c:549 ksys_write+0x103/0x260 fs/read_write.c:599 __do_sys_write fs/read_write.c:611 [inline] __se_sys_write fs/read_write.c:608 [inline] __x64_sys_write+0x6e/0xb0 fs/read_write.c:608 do_syscall_64+0xd0/0x4e0 arch/x86/entry/common.c:293 entry_SYSCALL_64_after_hwframe+0x49/0xbe Freed by task 3687: 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:3503 [inline] kfree+0xcf/0x220 mm/slab.c:3822 bt_host_release+0x10/0x20 net/bluetooth/hci_sysfs.c:86 device_release+0x71/0x1d0 drivers/base/core.c:1076 kobject_cleanup lib/kobject.c:662 [inline] kobject_release lib/kobject.c:691 [inline] kref_put include/linux/kref.h:70 [inline] kobject_put+0x115/0x1f0 lib/kobject.c:708 put_device+0x12/0x20 drivers/base/core.c:2266 hci_free_dev+0x10/0x20 net/bluetooth/hci_core.c:3147 vhci_release+0x73/0xe0 drivers/bluetooth/hci_vhci.c:355 __fput+0x249/0x7f0 fs/file_table.c:278 ____fput+0x9/0x10 fs/file_table.c:309 task_work_run+0x108/0x180 kernel/task_work.c:113 exit_task_work include/linux/task_work.h:22 [inline] do_exit+0xa6b/0x2da0 kernel/exit.c:870 do_group_exit+0xf4/0x2f0 kernel/exit.c:967 get_signal+0x316/0x19e0 kernel/signal.c:2589 do_signal+0x87/0x1960 arch/x86/kernel/signal.c:799 exit_to_usermode_loop+0x114/0x200 arch/x86/entry/common.c:163 prepare_exit_to_usermode arch/x86/entry/common.c:198 [inline] syscall_return_slowpath arch/x86/entry/common.c:271 [inline] do_syscall_64+0x413/0x4e0 arch/x86/entry/common.c:296 entry_SYSCALL_64_after_hwframe+0x49/0xbe The buggy address belongs to the object at ffff8881ddc859c0 which belongs to the cache kmalloc-8192 of size 8192 The buggy address is located 4192 bytes inside of 8192-byte region [ffff8881ddc859c0, ffff8881ddc879c0) The buggy address belongs to the page: page:ffffea0007772100 count:1 mapcount:0 mapping:ffff8881f6402080 index:0x0 compound_mapcount: 0 flags: 0x17ffe0000008100(slab|head) raw: 017ffe0000008100 ffffea0007591108 ffffea000762da08 ffff8881f6402080 raw: 0000000000000000 ffff8881ddc859c0 0000000100000001 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff8881ddc86900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8881ddc86980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff8881ddc86a00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff8881ddc86a80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8881ddc86b00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ================================================================== systemd[1]: bluetooth.target: Unit not needed anymore. Stopping. systemd[1]: bluetooth.target: Unit not needed anymore. Stopping. systemd[1]: bluetooth.target: Unit not needed anymore. Stopping. systemd[1]: bluetooth.target: Unit not needed anymore. Stopping. systemd[1]: bluetooth.target: Unit not needed anymore. Stopping. systemd[1]: bluetooth.target: Unit not needed anymore, but not stopping since we tried this too often recently. systemd[1]: bluetooth.target: Unit not needed anymore, but not stopping since we tried this too often recently. systemd[1]: bluetooth.target: Unit not needed anymore. Stopping. systemd[1]: bluetooth.target: Unit not needed anymore. Stopping. systemd[1]: bluetooth.target: Unit not needed anymore. Stopping.