syzbot


KASAN: use-after-free Read in __sock_queue_rcv_skb

Status: upstream: reported on 2024/11/20 09:52
Reported-by: syzbot+e3de6a6edf6a41020a26@syzkaller.appspotmail.com
First crash: 1d10h, last: 1d10h
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-6.1 KASAN: use-after-free Read in __sock_queue_rcv_skb 4 121d 169d 0/3 auto-obsoleted due to no activity on 2024/10/31 03:14
upstream KASAN: slab-use-after-free Read in __sock_queue_rcv_skb bluetooth 7 143d 150d 0/28 auto-obsoleted due to no activity on 2024/10/09 10:28

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in debug_spin_lock_before kernel/locking/spinlock_debug.c:85 [inline]
BUG: KASAN: use-after-free in do_raw_spin_lock+0x290/0x370 kernel/locking/spinlock_debug.c:114
Read of size 4 at addr ffff888063e171cc by task kworker/u5:3/4174

CPU: 0 PID: 4174 Comm: kworker/u5:3 Not tainted 5.15.173-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/30/2024
Workqueue: hci4 hci_rx_work
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2d0 lib/dump_stack.c:106
 print_address_description+0x63/0x3b0 mm/kasan/report.c:248
 __kasan_report mm/kasan/report.c:434 [inline]
 kasan_report+0x16b/0x1c0 mm/kasan/report.c:451
 debug_spin_lock_before kernel/locking/spinlock_debug.c:85 [inline]
 do_raw_spin_lock+0x290/0x370 kernel/locking/spinlock_debug.c:114
 __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:117 [inline]
 _raw_spin_lock_irqsave+0xdd/0x120 kernel/locking/spinlock.c:162
 __sock_queue_rcv_skb+0x3e4/0x960 net/core/sock.c:481
 l2cap_sock_recv_cb+0xfe/0x1e0 net/bluetooth/l2cap_sock.c:1516
 l2cap_conless_channel net/bluetooth/l2cap_core.c:7769 [inline]
 l2cap_recv_frame+0x1299/0x8ae0 net/bluetooth/l2cap_core.c:7823
 hci_acldata_packet net/bluetooth/hci_core.c:4969 [inline]
 hci_rx_work+0x48f/0x990 net/bluetooth/hci_core.c:5160
 process_one_work+0x8a1/0x10c0 kernel/workqueue.c:2310
 worker_thread+0xaca/0x1280 kernel/workqueue.c:2457
 kthread+0x3f6/0x4f0 kernel/kthread.c:334
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:287
 </TASK>

Allocated by task 5832:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track mm/kasan/common.c:46 [inline]
 set_alloc_info mm/kasan/common.c:434 [inline]
 ____kasan_kmalloc+0xba/0xf0 mm/kasan/common.c:513
 kasan_kmalloc include/linux/kasan.h:264 [inline]
 __kmalloc+0x168/0x300 mm/slub.c:4407
 kmalloc include/linux/slab.h:596 [inline]
 sk_prot_alloc+0xe0/0x200 net/core/sock.c:1863
 sk_alloc+0x35/0x310 net/core/sock.c:1916
 l2cap_sock_alloc+0x34/0x1d0 net/bluetooth/l2cap_sock.c:1861
 l2cap_sock_create+0x10d/0x1c0 net/bluetooth/l2cap_sock.c:1907
 bt_sock_create+0x159/0x220 net/bluetooth/af_bluetooth.c:130
 __sock_create+0x460/0x8f0 net/socket.c:1486
 sock_create net/socket.c:1542 [inline]
 __sys_socket+0x132/0x370 net/socket.c:1584
 __do_sys_socket net/socket.c:1593 [inline]
 __se_sys_socket net/socket.c:1591 [inline]
 __x64_sys_socket+0x76/0x80 net/socket.c:1591
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x66/0xd0

Freed by task 5831:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track+0x4b/0x80 mm/kasan/common.c:46
 kasan_set_free_info+0x1f/0x40 mm/kasan/generic.c:360
 ____kasan_slab_free+0xd8/0x120 mm/kasan/common.c:366
 kasan_slab_free include/linux/kasan.h:230 [inline]
 slab_free_hook mm/slub.c:1705 [inline]
 slab_free_freelist_hook+0xdd/0x160 mm/slub.c:1731
 slab_free mm/slub.c:3499 [inline]
 kfree+0xf1/0x270 mm/slub.c:4559
 sk_prot_free net/core/sock.c:1899 [inline]
 __sk_destruct+0x58e/0x840 net/core/sock.c:1985
 l2cap_sock_release+0x157/0x1d0 net/bluetooth/l2cap_sock.c:1429
 __sock_release net/socket.c:649 [inline]
 sock_close+0xcd/0x230 net/socket.c:1336
 __fput+0x3fe/0x8e0 fs/file_table.c:280
 task_work_run+0x129/0x1a0 kernel/task_work.c:188
 tracehook_notify_resume include/linux/tracehook.h:189 [inline]
 exit_to_user_mode_loop+0x106/0x130 kernel/entry/common.c:181
 exit_to_user_mode_prepare+0xb1/0x140 kernel/entry/common.c:214
 __syscall_exit_to_user_mode_work kernel/entry/common.c:296 [inline]
 syscall_exit_to_user_mode+0x5d/0x240 kernel/entry/common.c:307
 do_syscall_64+0x47/0xb0 arch/x86/entry/common.c:86
 entry_SYSCALL_64_after_hwframe+0x66/0xd0

The buggy address belongs to the object at ffff888063e17000
 which belongs to the cache kmalloc-2k of size 2048
The buggy address is located 460 bytes inside of
 2048-byte region [ffff888063e17000, ffff888063e17800)
The buggy address belongs to the page:
page:ffffea00018f8400 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x63e10
head:ffffea00018f8400 order:3 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 0000000000000000 0000000100000001 ffff888017042000
raw: 0000000000000000 0000000000080008 00000001ffffffff 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 4171, ts 61337472948, free_ts 19443433346
 prep_new_page mm/page_alloc.c:2426 [inline]
 get_page_from_freelist+0x3b78/0x3d40 mm/page_alloc.c:4192
 __alloc_pages+0x272/0x700 mm/page_alloc.c:5464
 alloc_slab_page mm/slub.c:1775 [inline]
 allocate_slab mm/slub.c:1912 [inline]
 new_slab+0xbb/0x4b0 mm/slub.c:1975
 ___slab_alloc+0x6f6/0xe10 mm/slub.c:3008
 __slab_alloc mm/slub.c:3095 [inline]
 slab_alloc_node mm/slub.c:3186 [inline]
 slab_alloc mm/slub.c:3228 [inline]
 __kmalloc_track_caller+0x1c7/0x300 mm/slub.c:4925
 kmemdup+0x21/0x50 mm/util.c:128
 neigh_sysctl_register+0xb0/0x530 net/core/neighbour.c:3647
 devinet_sysctl_register+0x9d/0x1a0 net/ipv4/devinet.c:2640
 inetdev_init+0x282/0x4a0 net/ipv4/devinet.c:277
 inetdev_event+0x29b/0x1490 net/ipv4/devinet.c:1543
 notifier_call_chain kernel/notifier.c:83 [inline]
 raw_notifier_call_chain+0xd0/0x170 kernel/notifier.c:391
 call_netdevice_notifiers_info net/core/dev.c:2018 [inline]
 call_netdevice_notifiers_extack net/core/dev.c:2030 [inline]
 call_netdevice_notifiers+0x145/0x1b0 net/core/dev.c:2044
 register_netdevice+0x12e8/0x1720 net/core/dev.c:10396
 virt_wifi_newlink+0x3e1/0x7f0 drivers/net/wireless/virt_wifi.c:567
 __rtnl_newlink net/core/rtnetlink.c:3521 [inline]
 rtnl_newlink+0x14e1/0x2070 net/core/rtnetlink.c:3569
 rtnetlink_rcv_msg+0x993/0xee0 net/core/rtnetlink.c:5647
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1340 [inline]
 free_pcp_prepare mm/page_alloc.c:1391 [inline]
 free_unref_page_prepare+0xc34/0xcf0 mm/page_alloc.c:3317
 free_unref_page+0x95/0x2d0 mm/page_alloc.c:3396
 free_contig_range+0x95/0xf0 mm/page_alloc.c:9383
 destroy_args+0xfe/0x980 mm/debug_vm_pgtable.c:1018
 debug_vm_pgtable+0x40d/0x470 mm/debug_vm_pgtable.c:1331
 do_one_initcall+0x22b/0x7a0 init/main.c:1302
 do_initcall_level+0x157/0x210 init/main.c:1375
 do_initcalls+0x49/0x90 init/main.c:1391
 kernel_init_freeable+0x425/0x5c0 init/main.c:1615
 kernel_init+0x19/0x290 init/main.c:1506
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:287

Memory state around the buggy address:
 ffff888063e17080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888063e17100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888063e17180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                              ^
 ffff888063e17200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888063e17280: fb fb fb fb fb fb fb fb 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
2024/11/20 09:52 linux-5.15.y 0a51d2d4527b 7d02db5a .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in __sock_queue_rcv_skb
* Struck through repros no longer work on HEAD.