================================================================== BUG: KASAN: use-after-free in set_powered_sync+0x40/0xdc net/bluetooth/mgmt.c:1365 Read of size 8 at addr ffff0000d7b73618 by task kworker/u5:4/4302 CPU: 1 PID: 4302 Comm: kworker/u5:4 Not tainted 6.1.119-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024 Workqueue: hci0 hci_cmd_sync_work Call trace: dump_backtrace+0x1c8/0x1f4 arch/arm64/kernel/stacktrace.c:158 show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:165 __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x108/0x170 lib/dump_stack.c:106 print_address_description mm/kasan/report.c:284 [inline] print_report+0x174/0x4c0 mm/kasan/report.c:395 kasan_report+0xd4/0x130 mm/kasan/report.c:495 __asan_report_load8_noabort+0x2c/0x38 mm/kasan/report_generic.c:351 set_powered_sync+0x40/0xdc net/bluetooth/mgmt.c:1365 hci_cmd_sync_work+0x1cc/0x34c net/bluetooth/hci_sync.c:322 process_one_work+0x7ac/0x1404 kernel/workqueue.c:2292 worker_thread+0x8e4/0xfec kernel/workqueue.c:2439 kthread+0x250/0x2d8 kernel/kthread.c:376 ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:864 Allocated by task 4576: kasan_save_stack mm/kasan/common.c:45 [inline] kasan_set_track+0x4c/0x80 mm/kasan/common.c:52 kasan_save_alloc_info+0x24/0x30 mm/kasan/generic.c:505 ____kasan_kmalloc mm/kasan/common.c:374 [inline] __kasan_kmalloc+0xac/0xc4 mm/kasan/common.c:383 kasan_kmalloc include/linux/kasan.h:211 [inline] kmalloc_trace+0x7c/0x94 mm/slab_common.c:1031 kmalloc include/linux/slab.h:557 [inline] kzalloc include/linux/slab.h:693 [inline] mgmt_pending_new+0x70/0x248 net/bluetooth/mgmt_util.c:269 mgmt_pending_add+0x48/0x124 net/bluetooth/mgmt_util.c:296 set_powered+0x240/0x44c net/bluetooth/mgmt.c:1398 hci_mgmt_cmd+0x7c4/0xbf8 net/bluetooth/hci_sock.c:1652 hci_sock_sendmsg+0x58c/0xd08 net/bluetooth/hci_sock.c:1772 sock_sendmsg_nosec net/socket.c:718 [inline] __sock_sendmsg net/socket.c:730 [inline] sock_write_iter+0x2d8/0x414 net/socket.c:1143 call_write_iter include/linux/fs.h:2265 [inline] new_sync_write fs/read_write.c:491 [inline] vfs_write+0x610/0x91c fs/read_write.c:584 ksys_write+0x15c/0x26c fs/read_write.c:637 __do_sys_write fs/read_write.c:649 [inline] __se_sys_write fs/read_write.c:646 [inline] __arm64_sys_write+0x7c/0x90 fs/read_write.c:646 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline] invoke_syscall+0x98/0x2bc arch/arm64/kernel/syscall.c:52 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:140 do_el0_svc+0x58/0x13c arch/arm64/kernel/syscall.c:204 el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637 el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655 el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:585 Freed by task 4566: kasan_save_stack mm/kasan/common.c:45 [inline] kasan_set_track+0x4c/0x80 mm/kasan/common.c:52 kasan_save_free_info+0x38/0x5c mm/kasan/generic.c:516 ____kasan_slab_free+0x144/0x1c0 mm/kasan/common.c:236 __kasan_slab_free+0x18/0x28 mm/kasan/common.c:244 kasan_slab_free include/linux/kasan.h:177 [inline] slab_free_hook mm/slub.c:1724 [inline] slab_free_freelist_hook mm/slub.c:1750 [inline] slab_free mm/slub.c:3661 [inline] __kmem_cache_free+0x2c0/0x4b4 mm/slub.c:3674 kfree+0xcc/0x1b8 mm/slab_common.c:988 mgmt_pending_free+0xc8/0x118 net/bluetooth/mgmt_util.c:309 settings_rsp+0x274/0x35c net/bluetooth/mgmt.c:1447 mgmt_pending_foreach+0xd4/0x148 net/bluetooth/mgmt_util.c:259 __mgmt_power_off+0x114/0x3dc net/bluetooth/mgmt.c:9494 hci_dev_close_sync+0x478/0xf1c net/bluetooth/hci_sync.c:5057 hci_dev_do_close net/bluetooth/hci_core.c:510 [inline] hci_rfkill_set_block+0xf0/0x20c net/bluetooth/hci_core.c:917 rfkill_set_block+0x18c/0x37c net/rfkill/core.c:345 rfkill_fop_write+0x578/0x734 net/rfkill/core.c:1286 vfs_write+0x2a4/0x91c fs/read_write.c:582 ksys_write+0x15c/0x26c fs/read_write.c:637 __do_sys_write fs/read_write.c:649 [inline] __se_sys_write fs/read_write.c:646 [inline] __arm64_sys_write+0x7c/0x90 fs/read_write.c:646 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline] invoke_syscall+0x98/0x2bc arch/arm64/kernel/syscall.c:52 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:140 do_el0_svc+0x58/0x13c arch/arm64/kernel/syscall.c:204 el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637 el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655 el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:585 Last potentially related work creation: kasan_save_stack+0x40/0x70 mm/kasan/common.c:45 __kasan_record_aux_stack+0xcc/0xe8 mm/kasan/generic.c:486 kasan_record_aux_stack_noalloc+0x14/0x20 mm/kasan/generic.c:496 kvfree_call_rcu+0xb4/0x714 kernel/rcu/tree.c:3401 kernfs_unlink_open_file+0x398/0x448 fs/kernfs/file.c:635 kernfs_fop_release+0x130/0x198 fs/kernfs/file.c:807 __fput+0x1c8/0x7c8 fs/file_table.c:320 ____fput+0x20/0x30 fs/file_table.c:348 task_work_run+0x240/0x2f0 kernel/task_work.c:203 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline] do_notify_resume+0x2080/0x2cb8 arch/arm64/kernel/signal.c:1132 prepare_exit_to_user_mode arch/arm64/kernel/entry-common.c:137 [inline] exit_to_user_mode arch/arm64/kernel/entry-common.c:142 [inline] el0_svc+0x9c/0x168 arch/arm64/kernel/entry-common.c:638 el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655 el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:585 Second to last potentially related work creation: kasan_save_stack+0x40/0x70 mm/kasan/common.c:45 __kasan_record_aux_stack+0xcc/0xe8 mm/kasan/generic.c:486 kasan_record_aux_stack_noalloc+0x14/0x20 mm/kasan/generic.c:496 kvfree_call_rcu+0xb4/0x714 kernel/rcu/tree.c:3401 kernfs_unlink_open_file+0x398/0x448 fs/kernfs/file.c:635 kernfs_fop_release+0x130/0x198 fs/kernfs/file.c:807 __fput+0x1c8/0x7c8 fs/file_table.c:320 ____fput+0x20/0x30 fs/file_table.c:348 task_work_run+0x240/0x2f0 kernel/task_work.c:203 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline] do_notify_resume+0x2080/0x2cb8 arch/arm64/kernel/signal.c:1132 prepare_exit_to_user_mode arch/arm64/kernel/entry-common.c:137 [inline] exit_to_user_mode arch/arm64/kernel/entry-common.c:142 [inline] el0_svc+0x9c/0x168 arch/arm64/kernel/entry-common.c:638 el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655 el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:585 The buggy address belongs to the object at ffff0000d7b73600 which belongs to the cache kmalloc-128 of size 128 The buggy address is located 24 bytes inside of 128-byte region [ffff0000d7b73600, ffff0000d7b73680) The buggy address belongs to the physical page: page:00000000abcc31d7 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x117b73 flags: 0x5ffc00000000200(slab|node=0|zone=2|lastcpupid=0x7ff) raw: 05ffc00000000200 fffffc00032b4b40 dead000000000002 ffff0000c0002300 raw: 0000000000000000 0000000000100010 00000001ffffffff 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff0000d7b73500: 00 fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff0000d7b73580: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff0000d7b73600: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff0000d7b73680: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff0000d7b73700: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ==================================================================