KASAN: slab-use-after-free Read in l2cap_recv_frame
Subsystems (2)
syzbot
syzbotHello,
syzbot found the following issue on:
HEAD commit: 4d2008430ce8 Merge tag 'docs-6.9-fixes2' of git://git.lwn... git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=14555ae7180000 kernel config: https://syzkaller.appspot.com/x/.config?x=98d5a8e00ed1044a dashboard link: https://syzkaller.appspot.com/bug?extid=5c915dc5dd417b83b348 compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=176f9880980000
Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/5670e5771b96/disk-4d200843.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/03314e6c8879/vmlinux-4d200843.xz
kernel image: https://storage.googleapis.com/syzbot-assets/41aca7a9505a/bzImage-4d200843.xz
IMPORTANT: if you fix the issue, please add the following tag to the commit:
==================================================================
BUG: KASAN: slab-use-after-free in l2cap_connect net/bluetooth/l2cap_core.c:3920 [inline] BUG: KASAN: slab-use-after-free in l2cap_connect_req net/bluetooth/l2cap_core.c:4061 [inline] BUG: KASAN: slab-use-after-free in l2cap_bredr_sig_cmd net/bluetooth/l2cap_core.c:4759 [inline] BUG: KASAN: slab-use-after-free in l2cap_sig_channel net/bluetooth/l2cap_core.c:5533 [inline] BUG: KASAN: slab-use-after-free in l2cap_recv_frame+0x19ca/0x107c0 net/bluetooth/l2cap_core.c:6793 Read of size 8 at addr ffff88802ab26000 by task kworker/u9:7/5103 CPU: 0 PID: 5103 Comm: kworker/u9:7 Not tainted 6.9.0-rc5-syzkaller-00007-g4d2008430ce8 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/27/2024 Workqueue: hci3 hci_rx_work Call Trace: <TASK> __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x241/0x360 lib/dump_stack.c:114 print_address_description mm/kasan/report.c:377 [inline] print_report+0x169/0x550 mm/kasan/report.c:488 kasan_report+0x143/0x180 mm/kasan/report.c:601 l2cap_connect net/bluetooth/l2cap_core.c:3920 [inline] l2cap_connect_req net/bluetooth/l2cap_core.c:4061 [inline] l2cap_bredr_sig_cmd net/bluetooth/l2cap_core.c:4759 [inline] l2cap_sig_channel net/bluetooth/l2cap_core.c:5533 [inline] l2cap_recv_frame+0x19ca/0x107c0 net/bluetooth/l2cap_core.c:6793 hci_acldata_packet net/bluetooth/hci_core.c:3939 [inline] hci_rx_work+0x50f/0xca0 net/bluetooth/hci_core.c:4176 process_one_work kernel/workqueue.c:3254 [inline] process_scheduled_works+0xa10/0x17c0 kernel/workqueue.c:3335 worker_thread+0x86d/0xd70 kernel/workqueue.c:3416 kthread+0x2f0/0x390 kernel/kthread.c:388 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244 </TASK> Allocated by task 5096: kasan_save_stack mm/kasan/common.c:47 [inline] kasan_save_track+0x3f/0x80 mm/kasan/common.c:68 poison_kmalloc_redzone mm/kasan/common.c:370 [inline] __kasan_kmalloc+0x98/0xb0 mm/kasan/common.c:387 kasan_kmalloc include/linux/kasan.h:211 [inline] kmalloc_trace+0x1db/0x360 mm/slub.c:3997 kmalloc include/linux/slab.h:628 [inline] kzalloc include/linux/slab.h:749 [inline] l2cap_conn_add+0xa9/0x9c0 net/bluetooth/l2cap_core.c:6836 l2cap_connect_cfm+0x136/0x1220 net/bluetooth/l2cap_core.c:7227 hci_connect_cfm include/net/bluetooth/hci_core.h:2007 [inline] hci_remote_features_evt+0x68b/0xa70 net/bluetooth/hci_event.c:3778 hci_event_func net/bluetooth/hci_event.c:7542 [inline] hci_event_packet+0xac0/0x1540 net/bluetooth/hci_event.c:7594 hci_rx_work+0x3e8/0xca0 net/bluetooth/hci_core.c:4171 process_one_work kernel/workqueue.c:3254 [inline] process_scheduled_works+0xa10/0x17c0 kernel/workqueue.c:3335 worker_thread+0x86d/0xd70 kernel/workqueue.c:3416 kthread+0x2f0/0x390 kernel/kthread.c:388 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244 Freed by task 5102: kasan_save_stack mm/kasan/common.c:47 [inline] kasan_save_track+0x3f/0x80 mm/kasan/common.c:68 kasan_save_free_info+0x40/0x50 mm/kasan/generic.c:579 poison_slab_object+0xa6/0xe0 mm/kasan/common.c:240 __kasan_slab_free+0x37/0x60 mm/kasan/common.c:256 kasan_slab_free include/linux/kasan.h:184 [inline] slab_free_hook mm/slub.c:2106 [inline] slab_free mm/slub.c:4280 [inline] kfree+0x153/0x3a0 mm/slub.c:4390 l2cap_connect_cfm+0x11f/0x1220 net/bluetooth/l2cap_core.c:7223 hci_connect_cfm include/net/bluetooth/hci_core.h:2007 [inline] hci_conn_failed+0x1f6/0x340 net/bluetooth/hci_conn.c:1230 hci_abort_conn_sync+0x583/0xde0 net/bluetooth/hci_sync.c:5567 hci_cmd_sync_work+0x22b/0x400 net/bluetooth/hci_sync.c:310 process_one_work kernel/workqueue.c:3254 [inline] process_scheduled_works+0xa10/0x17c0 kernel/workqueue.c:3335 worker_thread+0x86d/0xd70 kernel/workqueue.c:3416 kthread+0x2f0/0x390 kernel/kthread.c:388 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244 Last potentially related work creation: kasan_save_stack+0x3f/0x60 mm/kasan/common.c:47 __kasan_record_aux_stack+0xac/0xc0 mm/kasan/generic.c:541 insert_work+0x3e/0x330 kernel/workqueue.c:2248 __queue_work+0xc24/0xef0 kernel/workqueue.c:2400 call_timer_fn+0x18e/0x650 kernel/time/timer.c:1793 expire_timers kernel/time/timer.c:1839 [inline] __run_timers kernel/time/timer.c:2418 [inline] __run_timer_base+0x695/0x8e0 kernel/time/timer.c:2429 run_timer_base kernel/time/timer.c:2438 [inline] run_timer_softirq+0xb7/0x170 kernel/time/timer.c:2448 __do_softirq+0x2c6/0x980 kernel/softirq.c:554 Second to last potentially related work creation: kasan_save_stack+0x3f/0x60 mm/kasan/common.c:47 __kasan_record_aux_stack+0xac/0xc0 mm/kasan/generic.c:541 insert_work+0x3e/0x330 kernel/workqueue.c:2248 __queue_work+0xb00/0xef0 kernel/workqueue.c:2404 queue_work_on+0x14f/0x250 kernel/workqueue.c:2435 queue_work include/linux/workqueue.h:605 [inline] l2cap_conn_ready net/bluetooth/l2cap_core.c:1613 [inline] l2cap_connect_cfm+0xec2/0x1220 net/bluetooth/l2cap_core.c:7268 hci_connect_cfm include/net/bluetooth/hci_core.h:2007 [inline] hci_remote_features_evt+0x68b/0xa70 net/bluetooth/hci_event.c:3778 hci_event_func net/bluetooth/hci_event.c:7542 [inline] hci_event_packet+0xac0/0x1540 net/bluetooth/hci_event.c:7594 hci_rx_work+0x3e8/0xca0 net/bluetooth/hci_core.c:4171 process_one_work kernel/workqueue.c:3254 [inline] process_scheduled_works+0xa10/0x17c0 kernel/workqueue.c:3335 worker_thread+0x86d/0xd70 kernel/workqueue.c:3416 kthread+0x2f0/0x390 kernel/kthread.c:388 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244 The buggy address belongs to the object at ffff88802ab26000 which belongs to the cache kmalloc-1k of size 1024
The buggy address is located 0 bytes inside of
freed 1024-byte region [ffff88802ab26000, ffff88802ab26400)
The buggy address belongs to the physical page: page: refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff88802ab27000 pfn:0x2ab20 head: order:3 entire_mapcount:0 nr_pages_mapped:0 pincount:0 flags: 0xfff80000000a40(workingset|slab|head|node=0|zone=1|lastcpupid=0xfff) page_type: 0xffffffff() raw: 00fff80000000a40 ffff888015041dc0 ffffea0000b7c210 ffffea00008af410 raw: ffff88802ab27000 000000000010000e 00000001ffffffff 0000000000000000
head: 00fff80000000a40 ffff888015041dc0 ffffea0000b7c210 ffffea00008af410
head: ffff88802ab27000 000000000010000e 00000001ffffffff 0000000000000000
head: 00fff80000000003 ffffea0000aac801 ffffea0000aac848 00000000ffffffff
head: 0000000800000000 0000000000000000 00000000ffffffff 0000000000000000
page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 3, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 1, tgid -1362480974 (swapper/0), ts 1, free_ts 0 set_page_owner include/linux/page_owner.h:32 [inline] post_alloc_hook+0x1ea/0x210 mm/page_alloc.c:1534 prep_new_page mm/page_alloc.c:1541 [inline] get_page_from_freelist+0x3410/0x35b0 mm/page_alloc.c:3317 __alloc_pages+0x256/0x6c0 mm/page_alloc.c:4575 __alloc_pages_node include/linux/gfp.h:238 [inline] alloc_pages_node include/linux/gfp.h:261 [inline] alloc_slab_page+0x5f/0x160 mm/slub.c:2175 allocate_slab mm/slub.c:2338 [inline] new_slab+0x84/0x2f0 mm/slub.c:2391 ___slab_alloc+0xc73/0x1260 mm/slub.c:3525 __slab_alloc mm/slub.c:3610 [inline] __slab_alloc_node mm/slub.c:3663 [inline] slab_alloc_node mm/slub.c:3835 [inline] kmalloc_trace+0x269/0x360 mm/slub.c:3992 kmalloc include/linux/slab.h:628 [inline] kzalloc include/linux/slab.h:749 [inline] fqdir_init+0x59/0x170 net/ipv4/inet_fragment.c:192 lowpan_frags_init_net+0x33/0x310 net/ieee802154/6lowpan/reassembly.c:453 ops_init+0x352/0x610 net/core/net_namespace.c:136 __register_pernet_operations net/core/net_namespace.c:1243 [inline] register_pernet_operations+0x2cb/0x660 net/core/net_namespace.c:1312 register_pernet_subsys+0x28/0x40 net/core/net_namespace.c:1353 lowpan_net_frag_init+0xb2/0x100 net/ieee802154/6lowpan/reassembly.c:538 lowpan_init_module+0x10/0x90 net/ieee802154/6lowpan/core.c:250 do_one_initcall+0x248/0x880 init/main.c:1245 do_initcall_level+0x157/0x210 init/main.c:1307
page_owner free stack trace missing
Memory state around the buggy address:
ffff88802ab25f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff88802ab25f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88802ab26000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88802ab26080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88802ab26100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================---
This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at [email protected].
syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title
If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.
If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)
If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report
If you want to undo deduplication, reply with:
#syz undup
syzbot
syzbotsyzbot has found a reproducer for the following issue on:
syzbot has found a reproducer for the following issue on:
HEAD commit: e8784b0aef62 Merge tag 'usb-6.11-rc6' of git://git.kernel... git tree: upstream console+strace: https://syzkaller.appspot.com/x/log.txt?x=1600ea63980000 kernel config: https://syzkaller.appspot.com/x/.config?x=b3e19fd08b312452 dashboard link: https://syzkaller.appspot.com/bug?extid=5c915dc5dd417b83b348 compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=13ba6d1f980000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=10dfdadb980000
Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/e1d3f7f323a8/disk-e8784b0a.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/01c01dcebf01/vmlinux-e8784b0a.xz
kernel image: https://storage.googleapis.com/syzbot-assets/53cc8ab0ce4d/bzImage-e8784b0a.xz
Bisection is inconclusive: the first bad commit could be any of:
b79e04091010 Bluetooth: btintel: Fix null ptr deref in btintel_read_version e7b02296fb40 Bluetooth: Remove BT_HS
bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=17d8bd73980000
IMPORTANT: if you fix the issue, please add the following tag to the commit:
=====================================================
BUG: KMSAN: uninit-value in l2cap_conless_channel net/bluetooth/l2cap_core.c:6757 [inline] BUG: KMSAN: uninit-value in l2cap_recv_frame+0xc9c5/0x18b10 net/bluetooth/l2cap_core.c:6831 l2cap_conless_channel net/bluetooth/l2cap_core.c:6757 [inline] l2cap_recv_frame+0xc9c5/0x18b10 net/bluetooth/l2cap_core.c:6831 l2cap_recv_acldata+0xdd9/0x2ac0 net/bluetooth/l2cap_core.c:7514 hci_acldata_packet net/bluetooth/hci_core.c:3791 [inline] hci_rx_work+0xb38/0x1130 net/bluetooth/hci_core.c:4028 process_one_work kernel/workqueue.c:3231 [inline] process_scheduled_works+0xae0/0x1c40 kernel/workqueue.c:3312 worker_thread+0xea7/0x14d0 kernel/workqueue.c:3389 kthread+0x3e2/0x540 kernel/kthread.c:389 ret_from_fork+0x6d/0x90 arch/x86/kernel/process.c:147 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244
Uninit was created at:
slab_post_alloc_hook mm/slub.c:3994 [inline] slab_alloc_node mm/slub.c:4037 [inline] kmem_cache_alloc_node_noprof+0x6bf/0xb80 mm/slub.c:4080 kmalloc_reserve+0x13d/0x4a0 net/core/skbuff.c:583 __alloc_skb+0x363/0x7b0 net/core/skbuff.c:674 alloc_skb include/linux/skbuff.h:1320 [inline] bt_skb_alloc include/net/bluetooth/bluetooth.h:493 [inline] vhci_get_user drivers/bluetooth/hci_vhci.c:487 [inline] vhci_write+0x128/0x910 drivers/bluetooth/hci_vhci.c:607 new_sync_write fs/read_write.c:497 [inline] vfs_write+0xb2f/0x1550 fs/read_write.c:590 ksys_write+0x20f/0x4c0 fs/read_write.c:643 __do_sys_write fs/read_write.c:655 [inline] __se_sys_write fs/read_write.c:652 [inline] __x64_sys_write+0x93/0xe0 fs/read_write.c:652 x64_sys_call+0x306a/0x3ba0 arch/x86/include/generated/asm/syscalls_64.h:2 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcd/0x1e0 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f CPU: 0 UID: 0 PID: 5180 Comm: kworker/u9:2 Not tainted 6.11.0-rc5-syzkaller-00310-ge8784b0aef62 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/06/2024 Workqueue: hci0 hci_rx_work =====================================================
---
If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.
On Sun, 01 Sep 2024 00:39:27 -0700
Quoted 5 lines
syzbot has found a reproducer for the following issue on:
HEAD commit: e8784b0aef62 Merge tag 'usb-6.11-rc6' of git://git.kernel... git tree: upstream C reproducer: https://syzkaller.appspot.com/x/repro.c?x=10dfdadb980000
#syz test upstream e8784b0aef62
net/bluetooth/l2cap_core.c +1 -0
@@ -1797,6 +1797,7 @@ static void l2cap_conn_del(struct hci_coif (conn->info_state &L2CAP_INFO_FEAT_MASK_REQ_SENT )cancel_delayed_work_sync (&conn->info_timer); +cancel_work_sync (&hcon->hdev->rx_work); hcon->l2cap_data =NULL ; conn->hchan =NULL ;l2cap_conn_put (conn);
--
syzbot
syzbotsyzbot has tested the proposed patch but the reproducer is still triggering an issue: KMSAN: uninit-value in l2cap_recv_frame
Hello,
syzbot has tested the proposed patch but the reproducer is still triggering an issue:
KMSAN: uninit-value in l2cap_recv_frame
Bluetooth: hci0: command tx timeout
=====================================================
BUG: KMSAN: uninit-value in l2cap_conless_channel net/bluetooth/l2cap_core.c:6758 [inline] BUG: KMSAN: uninit-value in l2cap_recv_frame+0xc9c5/0x18b10 net/bluetooth/l2cap_core.c:6832 l2cap_conless_channel net/bluetooth/l2cap_core.c:6758 [inline] l2cap_recv_frame+0xc9c5/0x18b10 net/bluetooth/l2cap_core.c:6832 l2cap_recv_acldata+0xdd9/0x2ac0 net/bluetooth/l2cap_core.c:7515 hci_acldata_packet net/bluetooth/hci_core.c:3791 [inline] hci_rx_work+0xb38/0x1130 net/bluetooth/hci_core.c:4028 process_one_work kernel/workqueue.c:3231 [inline] process_scheduled_works+0xae0/0x1c40 kernel/workqueue.c:3312 worker_thread+0xea7/0x14d0 kernel/workqueue.c:3389 kthread+0x3e2/0x540 kernel/kthread.c:389 ret_from_fork+0x6d/0x90 arch/x86/kernel/process.c:147 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244
Uninit was created at:
slab_post_alloc_hook mm/slub.c:3994 [inline] slab_alloc_node mm/slub.c:4037 [inline] kmem_cache_alloc_node_noprof+0x6bf/0xb80 mm/slub.c:4080 kmalloc_reserve+0x13d/0x4a0 net/core/skbuff.c:583 __alloc_skb+0x363/0x7b0 net/core/skbuff.c:674 alloc_skb include/linux/skbuff.h:1320 [inline] bt_skb_alloc include/net/bluetooth/bluetooth.h:493 [inline] vhci_get_user drivers/bluetooth/hci_vhci.c:487 [inline] vhci_write+0x128/0x910 drivers/bluetooth/hci_vhci.c:607 new_sync_write fs/read_write.c:497 [inline] vfs_write+0xb2f/0x1550 fs/read_write.c:590 ksys_write+0x20f/0x4c0 fs/read_write.c:643 __do_sys_write fs/read_write.c:655 [inline] __se_sys_write fs/read_write.c:652 [inline] __x64_sys_write+0x93/0xe0 fs/read_write.c:652 x64_sys_call+0x306a/0x3ba0 arch/x86/include/generated/asm/syscalls_64.h:2 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcd/0x1e0 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f CPU: 0 UID: 0 PID: 5289 Comm: kworker/u9:2 Not tainted 6.11.0-rc5-syzkaller-00310-ge8784b0aef62-dirty #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/06/2024 Workqueue: hci0 hci_rx_work =====================================================
Tested on:
commit: e8784b0a Merge tag 'usb-6.11-rc6' of git://git.kernel... git tree: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git console output: https://syzkaller.appspot.com/x/log.txt?x=1721e347980000 kernel config: https://syzkaller.appspot.com/x/.config?x=b3e19fd08b312452 dashboard link: https://syzkaller.appspot.com/bug?extid=5c915dc5dd417b83b348 compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40 patch: https://syzkaller.appspot.com/x/patch.diff?x=155009eb980000
On Sun, 01 Sep 2024 00:39:27 -0700
Quoted 5 lines
syzbot has found a reproducer for the following issue on:
HEAD commit: e8784b0aef62 Merge tag 'usb-6.11-rc6' of git://git.kernel... git tree: upstream C reproducer: https://syzkaller.appspot.com/x/repro.c?x=10dfdadb980000
#syz test upstream e8784b0aef62
net/bluetooth/l2cap_core.c +1 -0
@@ -6826,6 +6826,7 @@ static void l2cap_recv_frame(struct l2cabreak ;case L2CAP_CID_CONN_LESS : + *((__le16 *) skb->data) =0 ; psm =get_unaligned ((__le16 *) skb->data);skb_pull (skb,L2CAP_PSMLEN_SIZE );l2cap_conless_channel (conn, psm, skb);
--
syzbot has tested the proposed patch and the reproducer did not trigger any issue:
Hello,
syzbot has tested the proposed patch and the reproducer did not trigger any issue:
Tested on:
commit: e8784b0a Merge tag 'usb-6.11-rc6' of git://git.kernel... git tree: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git console output: https://syzkaller.appspot.com/x/log.txt?x=15b1272b980000 kernel config: https://syzkaller.appspot.com/x/.config?x=b3e19fd08b312452 dashboard link: https://syzkaller.appspot.com/bug?extid=5c915dc5dd417b83b348 compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40 patch: https://syzkaller.appspot.com/x/patch.diff?x=15dc43db980000
Note: testing is done by a robot and is best-effort only.