syzbot


KASAN: use-after-free Read in hci_uart_flush

Status: auto-closed as invalid on 2022/01/25 22:31
Reported-by: syzbot+ad045e5285050184d82a@syzkaller.appspotmail.com
First crash: 940d, last: 940d

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in atomic_read include/asm-generic/atomic-instrumented.h:26 [inline]
BUG: KASAN: use-after-free in refcount_read include/linux/refcount.h:43 [inline]
BUG: KASAN: use-after-free in skb_unref include/linux/skbuff.h:1021 [inline]
BUG: KASAN: use-after-free in kfree_skb+0x36/0x320 net/core/skbuff.c:703
Read of size 4 at addr ffff8881a9281d64 by task syz-executor.5/19574

CPU: 1 PID: 19574 Comm: syz-executor.5 Not tainted 5.4.125-syzkaller-00011-gd52ac987ad2a #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+0x1d8/0x24e lib/dump_stack.c:118
 print_address_description+0x9b/0x650 mm/kasan/report.c:384
 __kasan_report+0x182/0x260 mm/kasan/report.c:516
 kasan_report+0x30/0x60 mm/kasan/common.c:653
 check_memory_region_inline mm/kasan/generic.c:141 [inline]
 check_memory_region+0x2a5/0x2e0 mm/kasan/generic.c:191
 atomic_read include/asm-generic/atomic-instrumented.h:26 [inline]
 refcount_read include/linux/refcount.h:43 [inline]
 skb_unref include/linux/skbuff.h:1021 [inline]
 kfree_skb+0x36/0x320 net/core/skbuff.c:703
 hci_uart_flush+0x9b/0x340 drivers/bluetooth/hci_ldisc.c:233
 hci_uart_close drivers/bluetooth/hci_ldisc.c:266 [inline]
 hci_uart_tty_close+0x89/0x220 drivers/bluetooth/hci_ldisc.c:533
 tty_ldisc_close drivers/tty/tty_ldisc.c:494 [inline]
 tty_ldisc_kill drivers/tty/tty_ldisc.c:642 [inline]
 tty_ldisc_release+0x272/0x600 drivers/tty/tty_ldisc.c:814
 tty_release_struct+0x27/0xd0 drivers/tty/tty_io.c:1612
 tty_release+0xdd7/0x10a0 drivers/tty/tty_io.c:1785
 __fput+0x27d/0x6c0 fs/file_table.c:281
 task_work_run+0x186/0x1b0 kernel/task_work.c:113
 exit_task_work include/linux/task_work.h:22 [inline]
 do_exit+0xcb9/0x2bf0 kernel/exit.c:812
 do_group_exit+0x15c/0x2c0 kernel/exit.c:910
 get_signal+0x164f/0x1fc0 kernel/signal.c:2745
 do_signal+0x8d/0x610 arch/x86/kernel/signal.c:793
 exit_to_usermode_loop arch/x86/entry/common.c:159 [inline]
 prepare_exit_to_usermode+0x207/0x310 arch/x86/entry/common.c:194
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x7f312c88e51b
Code: Bad RIP value.
RSP: 002b:00007fff75ed06b0 EFLAGS: 00000293 ORIG_RAX: 0000000000000003
RAX: 0000000000000000 RBX: 0000000000000006 RCX: 00007f312c88e51b
RDX: 0000001b2f722c58 RSI: ffffffff8227ae4b RDI: 0000000000000005
RBP: 0000000000000001 R08: 0000000000000000 R09: 0000001b2f7229d0
R10: 0000000000000e6d R11: 0000000000000293 R12: 00007f312c9e0b60
R13: 00007f312c9e0b60 R14: 00007f312c9dff60 R15: 0000000000213ea3

Allocated by task 13246:
 save_stack mm/kasan/common.c:70 [inline]
 set_track mm/kasan/common.c:78 [inline]
 __kasan_kmalloc+0x137/0x1e0 mm/kasan/common.c:529
 slab_post_alloc_hook mm/slab.h:584 [inline]
 slab_alloc_node mm/slub.c:2821 [inline]
 slab_alloc mm/slub.c:2829 [inline]
 kmem_cache_alloc+0x115/0x290 mm/slub.c:2834
 kmem_cache_alloc_node include/linux/slab.h:427 [inline]
 __alloc_skb+0x75/0x4d0 net/core/skbuff.c:198
 alloc_skb include/linux/skbuff.h:1060 [inline]
 bt_skb_alloc include/net/bluetooth/bluetooth.h:339 [inline]
 hci_prepare_cmd net/bluetooth/hci_request.c:296 [inline]
 hci_req_add_ev+0xa4/0x3c0 net/bluetooth/hci_request.c:330
 bredr_init net/bluetooth/hci_core.c:200 [inline]
 hci_init1_req+0x134/0x270 net/bluetooth/hci_core.c:256
 __hci_req_sync+0x174/0x8a0 net/bluetooth/hci_request.c:205
 __hci_init net/bluetooth/hci_core.c:868 [inline]
 hci_dev_do_open+0xafe/0x1670 net/bluetooth/hci_core.c:1528
 hci_power_on+0x155/0x580 net/bluetooth/hci_core.c:2200
 process_one_work+0x679/0x1030 kernel/workqueue.c:2277
 worker_thread+0xa6f/0x1400 kernel/workqueue.c:2423
 kthread+0x30f/0x330 kernel/kthread.c:268
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:352

Freed by task 13246:
 save_stack mm/kasan/common.c:70 [inline]
 set_track mm/kasan/common.c:78 [inline]
 kasan_set_free_info mm/kasan/common.c:345 [inline]
 __kasan_slab_free+0x18a/0x240 mm/kasan/common.c:487
 slab_free_hook mm/slub.c:1454 [inline]
 slab_free_freelist_hook+0x7b/0x150 mm/slub.c:1492
 slab_free mm/slub.c:3072 [inline]
 kmem_cache_free+0xb8/0x5f0 mm/slub.c:3088
 hci_uart_flush+0x9b/0x340 drivers/bluetooth/hci_ldisc.c:233
 hci_dev_do_open+0xe66/0x1670 net/bluetooth/hci_core.c:1576
 hci_power_on+0x155/0x580 net/bluetooth/hci_core.c:2200
 process_one_work+0x679/0x1030 kernel/workqueue.c:2277
 worker_thread+0xa6f/0x1400 kernel/workqueue.c:2423
 kthread+0x30f/0x330 kernel/kthread.c:268
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:352

The buggy address belongs to the object at ffff8881a9281c80
 which belongs to the cache skbuff_head_cache of size 240
The buggy address is located 228 bytes inside of
 240-byte region [ffff8881a9281c80, ffff8881a9281d70)
The buggy address belongs to the page:
page:ffffea0006a4a040 refcount:1 mapcount:0 mapping:ffff8881f1ddf400 index:0x0
flags: 0x8000000000000200(slab)
raw: 8000000000000200 0000000000000000 0000000800000001 ffff8881f1ddf400
raw: 0000000000000000 00000000000c000c 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask 0x12cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY)
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook mm/page_alloc.c:2165 [inline]
 prep_new_page+0x19a/0x380 mm/page_alloc.c:2171
 get_page_from_freelist+0x550/0x8b0 mm/page_alloc.c:3794
 __alloc_pages_nodemask+0x3a2/0x880 mm/page_alloc.c:4855
 alloc_slab_page+0x39/0x3e0 mm/slub.c:342
 allocate_slab mm/slub.c:1675 [inline]
 new_slab+0x97/0x460 mm/slub.c:1741
 new_slab_objects mm/slub.c:2498 [inline]
 ___slab_alloc+0x330/0x4c0 mm/slub.c:2659
 __slab_alloc mm/slub.c:2699 [inline]
 slab_alloc_node mm/slub.c:2784 [inline]
 slab_alloc mm/slub.c:2829 [inline]
 kmem_cache_alloc+0x18b/0x290 mm/slub.c:2834
 kmem_cache_alloc_node include/linux/slab.h:427 [inline]
 __alloc_skb+0x75/0x4d0 net/core/skbuff.c:198
 alloc_skb include/linux/skbuff.h:1060 [inline]
 alloc_skb_with_frags+0xad/0x5a0 net/core/skbuff.c:5806
 sock_alloc_send_pskb+0x86d/0xcb0 net/core/sock.c:2243
 unix_dgram_sendmsg+0x6e6/0x2680 net/unix/af_unix.c:1690
 sock_sendmsg_nosec net/socket.c:638 [inline]
 sock_sendmsg net/socket.c:658 [inline]
 ____sys_sendmsg+0x583/0x8c0 net/socket.c:2298
 ___sys_sendmsg net/socket.c:2352 [inline]
 __sys_sendmmsg+0x3b3/0x730 net/socket.c:2455
 __do_sys_sendmmsg net/socket.c:2484 [inline]
 __se_sys_sendmmsg net/socket.c:2481 [inline]
 __x64_sys_sendmmsg+0x9c/0xb0 net/socket.c:2481
 do_syscall_64+0xcb/0x1e0 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1176 [inline]
 free_pcp_prepare+0x1a9/0x270 mm/page_alloc.c:1233
 free_unref_page_prepare mm/page_alloc.c:3085 [inline]
 free_unref_page mm/page_alloc.c:3134 [inline]
 free_the_page mm/page_alloc.c:4915 [inline]
 __free_pages+0x9c/0x250 mm/page_alloc.c:4923
 tlb_batch_list_free mm/mmu_gather.c:61 [inline]
 tlb_finish_mmu+0x124/0x200 mm/mmu_gather.c:275
 exit_mmap+0x2e8/0x540 mm/mmap.c:3176
 __mmput+0x34/0x240 kernel/fork.c:1089
 exit_mm kernel/exit.c:489 [inline]
 do_exit+0xc19/0x2bf0 kernel/exit.c:799
 do_group_exit+0x15c/0x2c0 kernel/exit.c:910
 __do_sys_exit_group+0x13/0x20 kernel/exit.c:921
 __ia32_sys_exit_group+0x0/0x40 kernel/exit.c:919
 __x64_sys_exit_group+0x37/0x40 kernel/exit.c:919
 do_syscall_64+0xcb/0x1e0 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

Memory state around the buggy address:
 ffff8881a9281c00: fb fb fb fb fb fb fc fc fc fc fc fc fc fc fc fc
 ffff8881a9281c80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8881a9281d00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fc fc
                                                       ^
 ffff8881a9281d80: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
 ffff8881a9281e00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
==================================================================
BUG: KASAN: double-free or invalid-free in slab_free mm/slub.c:3072 [inline]
BUG: KASAN: double-free or invalid-free in kmem_cache_free+0xb8/0x5f0 mm/slub.c:3088

CPU: 1 PID: 19574 Comm: syz-executor.5 Tainted: G    B             5.4.125-syzkaller-00011-gd52ac987ad2a #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+0x1d8/0x24e lib/dump_stack.c:118
 print_address_description+0x9b/0x650 mm/kasan/report.c:384
 kasan_report_invalid_free+0x54/0x120 mm/kasan/report.c:478
 __kasan_slab_free+0x10e/0x240 mm/kasan/common.c:475
 slab_free_hook mm/slub.c:1454 [inline]
 slab_free_freelist_hook+0x7b/0x150 mm/slub.c:1492
 slab_free mm/slub.c:3072 [inline]
 kmem_cache_free+0xb8/0x5f0 mm/slub.c:3088
 hci_uart_flush+0x9b/0x340 drivers/bluetooth/hci_ldisc.c:233
 hci_uart_close drivers/bluetooth/hci_ldisc.c:266 [inline]
 hci_uart_tty_close+0x89/0x220 drivers/bluetooth/hci_ldisc.c:533
 tty_ldisc_close drivers/tty/tty_ldisc.c:494 [inline]
 tty_ldisc_kill drivers/tty/tty_ldisc.c:642 [inline]
 tty_ldisc_release+0x272/0x600 drivers/tty/tty_ldisc.c:814
 tty_release_struct+0x27/0xd0 drivers/tty/tty_io.c:1612
 tty_release+0xdd7/0x10a0 drivers/tty/tty_io.c:1785
 __fput+0x27d/0x6c0 fs/file_table.c:281
 task_work_run+0x186/0x1b0 kernel/task_work.c:113
 exit_task_work include/linux/task_work.h:22 [inline]
 do_exit+0xcb9/0x2bf0 kernel/exit.c:812
 do_group_exit+0x15c/0x2c0 kernel/exit.c:910
 get_signal+0x164f/0x1fc0 kernel/signal.c:2745
 do_signal+0x8d/0x610 arch/x86/kernel/signal.c:793
 exit_to_usermode_loop arch/x86/entry/common.c:159 [inline]
 prepare_exit_to_usermode+0x207/0x310 arch/x86/entry/common.c:194
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x7f312c88e51b
Code: Bad RIP value.
RSP: 002b:00007fff75ed06b0 EFLAGS: 00000293 ORIG_RAX: 0000000000000003
RAX: 0000000000000000 RBX: 0000000000000006 RCX: 00007f312c88e51b
RDX: 0000001b2f722c58 RSI: ffffffff8227ae4b RDI: 0000000000000005
RBP: 0000000000000001 R08: 0000000000000000 R09: 0000001b2f7229d0
R10: 0000000000000e6d R11: 0000000000000293 R12: 00007f312c9e0b60
R13: 00007f312c9e0b60 R14: 00007f312c9dff60 R15: 0000000000213ea3

Allocated by task 13246:
 save_stack mm/kasan/common.c:70 [inline]
 set_track mm/kasan/common.c:78 [inline]
 __kasan_kmalloc+0x137/0x1e0 mm/kasan/common.c:529
 slab_post_alloc_hook mm/slab.h:584 [inline]
 slab_alloc_node mm/slub.c:2821 [inline]
 slab_alloc mm/slub.c:2829 [inline]
 kmem_cache_alloc+0x115/0x290 mm/slub.c:2834
 kmem_cache_alloc_node include/linux/slab.h:427 [inline]
 __alloc_skb+0x75/0x4d0 net/core/skbuff.c:198
 alloc_skb include/linux/skbuff.h:1060 [inline]
 bt_skb_alloc include/net/bluetooth/bluetooth.h:339 [inline]
 hci_prepare_cmd net/bluetooth/hci_request.c:296 [inline]
 hci_req_add_ev+0xa4/0x3c0 net/bluetooth/hci_request.c:330
 bredr_init net/bluetooth/hci_core.c:200 [inline]
 hci_init1_req+0x134/0x270 net/bluetooth/hci_core.c:256
 __hci_req_sync+0x174/0x8a0 net/bluetooth/hci_request.c:205
 __hci_init net/bluetooth/hci_core.c:868 [inline]
 hci_dev_do_open+0xafe/0x1670 net/bluetooth/hci_core.c:1528
 hci_power_on+0x155/0x580 net/bluetooth/hci_core.c:2200
 process_one_work+0x679/0x1030 kernel/workqueue.c:2277
 worker_thread+0xa6f/0x1400 kernel/workqueue.c:2423
 kthread+0x30f/0x330 kernel/kthread.c:268
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:352

Freed by task 13246:
 save_stack mm/kasan/common.c:70 [inline]
 set_track mm/kasan/common.c:78 [inline]
 kasan_set_free_info mm/kasan/common.c:345 [inline]
 __kasan_slab_free+0x18a/0x240 mm/kasan/common.c:487
 slab_free_hook mm/slub.c:1454 [inline]
 slab_free_freelist_hook+0x7b/0x150 mm/slub.c:1492
 slab_free mm/slub.c:3072 [inline]
 kmem_cache_free+0xb8/0x5f0 mm/slub.c:3088
 hci_uart_flush+0x9b/0x340 drivers/bluetooth/hci_ldisc.c:233
 hci_dev_do_open+0xe66/0x1670 net/bluetooth/hci_core.c:1576
 hci_power_on+0x155/0x580 net/bluetooth/hci_core.c:2200
 process_one_work+0x679/0x1030 kernel/workqueue.c:2277
 worker_thread+0xa6f/0x1400 kernel/workqueue.c:2423
 kthread+0x30f/0x330 kernel/kthread.c:268
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:352

The buggy address belongs to the object at ffff8881a9281c80
 which belongs to the cache skbuff_head_cache of size 240
The buggy address is located 0 bytes inside of
 240-byte region [ffff8881a9281c80, ffff8881a9281d70)
The buggy address belongs to the page:
page:ffffea0006a4a040 refcount:1 mapcount:0 mapping:ffff8881f1ddf400 index:0x0
flags: 0x8000000000000200(slab)
raw: 8000000000000200 0000000000000000 0000000800000001 ffff8881f1ddf400
raw: 0000000000000000 00000000000c000c 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask 0x12cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY)
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook mm/page_alloc.c:2165 [inline]
 prep_new_page+0x19a/0x380 mm/page_alloc.c:2171
 get_page_from_freelist+0x550/0x8b0 mm/page_alloc.c:3794
 __alloc_pages_nodemask+0x3a2/0x880 mm/page_alloc.c:4855
 alloc_slab_page+0x39/0x3e0 mm/slub.c:342
 allocate_slab mm/slub.c:1675 [inline]
 new_slab+0x97/0x460 mm/slub.c:1741
 new_slab_objects mm/slub.c:2498 [inline]
 ___slab_alloc+0x330/0x4c0 mm/slub.c:2659
 __slab_alloc mm/slub.c:2699 [inline]
 slab_alloc_node mm/slub.c:2784 [inline]
 slab_alloc mm/slub.c:2829 [inline]
 kmem_cache_alloc+0x18b/0x290 mm/slub.c:2834
 kmem_cache_alloc_node include/linux/slab.h:427 [inline]
 __alloc_skb+0x75/0x4d0 net/core/skbuff.c:198
 alloc_skb include/linux/skbuff.h:1060 [inline]
 alloc_skb_with_frags+0xad/0x5a0 net/core/skbuff.c:5806
 sock_alloc_send_pskb+0x86d/0xcb0 net/core/sock.c:2243
 unix_dgram_sendmsg+0x6e6/0x2680 net/unix/af_unix.c:1690
 sock_sendmsg_nosec net/socket.c:638 [inline]
 sock_sendmsg net/socket.c:658 [inline]
 ____sys_sendmsg+0x583/0x8c0 net/socket.c:2298
 ___sys_sendmsg net/socket.c:2352 [inline]
 __sys_sendmmsg+0x3b3/0x730 net/socket.c:2455
 __do_sys_sendmmsg net/socket.c:2484 [inline]
 __se_sys_sendmmsg net/socket.c:2481 [inline]
 __x64_sys_sendmmsg+0x9c/0xb0 net/socket.c:2481
 do_syscall_64+0xcb/0x1e0 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1176 [inline]
 free_pcp_prepare+0x1a9/0x270 mm/page_alloc.c:1233
 free_unref_page_prepare mm/page_alloc.c:3085 [inline]
 free_unref_page mm/page_alloc.c:3134 [inline]
 free_the_page mm/page_alloc.c:4915 [inline]
 __free_pages+0x9c/0x250 mm/page_alloc.c:4923
 tlb_batch_list_free mm/mmu_gather.c:61 [inline]
 tlb_finish_mmu+0x124/0x200 mm/mmu_gather.c:275
 exit_mmap+0x2e8/0x540 mm/mmap.c:3176
 __mmput+0x34/0x240 kernel/fork.c:1089
 exit_mm kernel/exit.c:489 [inline]
 do_exit+0xc19/0x2bf0 kernel/exit.c:799
 do_group_exit+0x15c/0x2c0 kernel/exit.c:910
 __do_sys_exit_group+0x13/0x20 kernel/exit.c:921
 __ia32_sys_exit_group+0x0/0x40 kernel/exit.c:919
 __x64_sys_exit_group+0x37/0x40 kernel/exit.c:919
 do_syscall_64+0xcb/0x1e0 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

Memory state around the buggy address:
 ffff8881a9281b80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8881a9281c00: fb fb fb fb fb fb fc fc fc fc fc fc fc fc fc fc
>ffff8881a9281c80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                   ^
 ffff8881a9281d00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fc fc
 ffff8881a9281d80: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2021/09/27 22:30 android12-5.4 d52ac987ad2a 78494d16 .config console log report info ci2-android-5-4-kasan KASAN: use-after-free Read in hci_uart_flush
* Struck through repros no longer work on HEAD.