[v6.1] KASAN: use-after-free Read in __sock_queue_rcv_skb

0 views
Skip to first unread message

syzbot

unread,
Jun 5, 2024, 9:17:27 AMJun 5
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 88690811da69 Linux 6.1.92
git tree: linux-6.1.y
console output: https://syzkaller.appspot.com/x/log.txt?x=13313aac980000
kernel config: https://syzkaller.appspot.com/x/.config?x=ee57a613e7f5bf6c
dashboard link: https://syzkaller.appspot.com/bug?extid=beb7873f9206c5482971
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40

Unfortunately, I don't have any reproducer for this issue yet.

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/8b45ba80e02a/disk-88690811.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/ca769d644800/vmlinux-88690811.xz
kernel image: https://storage.googleapis.com/syzbot-assets/26a1d8aecbf6/bzImage-88690811.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+beb787...@syzkaller.appspotmail.com

==================================================================
BUG: KASAN: use-after-free in __lock_acquire+0x77/0x1f80 kernel/locking/lockdep.c:4919
Read of size 8 at addr ffff88805ea4d1e8 by task kworker/u5:3/3580

CPU: 0 PID: 3580 Comm: kworker/u5:3 Not tainted 6.1.92-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/02/2024
Workqueue: hci1 hci_rx_work
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
print_address_description mm/kasan/report.c:284 [inline]
print_report+0x15f/0x4f0 mm/kasan/report.c:395
kasan_report+0x136/0x160 mm/kasan/report.c:495
__lock_acquire+0x77/0x1f80 kernel/locking/lockdep.c:4919
lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5662
__raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
_raw_spin_lock_irqsave+0xd1/0x120 kernel/locking/spinlock.c:162
__sock_queue_rcv_skb+0x3f8/0xa00 net/core/sock.c:504
l2cap_sock_recv_cb+0xfe/0x1e0 net/bluetooth/l2cap_sock.c:1505
l2cap_conless_channel net/bluetooth/l2cap_core.c:7775 [inline]
l2cap_recv_frame+0x12ba/0x8b30 net/bluetooth/l2cap_core.c:7828
hci_acldata_packet net/bluetooth/hci_core.c:3897 [inline]
hci_rx_work+0x363/0xce0 net/bluetooth/hci_core.c:4134
process_one_work+0x8a9/0x11d0 kernel/workqueue.c:2292
worker_thread+0xa47/0x1200 kernel/workqueue.c:2439
kthread+0x28d/0x320 kernel/kthread.c:376
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308
</TASK>

Allocated by task 6568:
kasan_save_stack mm/kasan/common.c:45 [inline]
kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
____kasan_kmalloc mm/kasan/common.c:374 [inline]
__kasan_kmalloc+0x97/0xb0 mm/kasan/common.c:383
kasan_kmalloc include/linux/kasan.h:211 [inline]
__do_kmalloc_node mm/slab_common.c:955 [inline]
__kmalloc+0xb2/0x230 mm/slab_common.c:968
kmalloc include/linux/slab.h:561 [inline]
sk_prot_alloc+0xe0/0x200 net/core/sock.c:2047
sk_alloc+0x36/0x350 net/core/sock.c:2100
l2cap_sock_alloc+0x34/0x1d0 net/bluetooth/l2cap_sock.c:1850
l2cap_sock_create+0x10d/0x1c0 net/bluetooth/l2cap_sock.c:1896
bt_sock_create+0x159/0x220 net/bluetooth/af_bluetooth.c:132
__sock_create+0x488/0x910 net/socket.c:1550
sock_create net/socket.c:1601 [inline]
__sys_socket_create net/socket.c:1638 [inline]
__sys_socket+0x136/0x3a0 net/socket.c:1666
__do_sys_socket net/socket.c:1679 [inline]
__se_sys_socket net/socket.c:1677 [inline]
__x64_sys_socket+0x76/0x80 net/socket.c:1677
do_syscall_x64 arch/x86/entry/common.c:51 [inline]
do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
entry_SYSCALL_64_after_hwframe+0x68/0xd2

Freed by task 6567:
kasan_save_stack mm/kasan/common.c:45 [inline]
kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
kasan_save_free_info+0x27/0x40 mm/kasan/generic.c:516
____kasan_slab_free+0xd6/0x120 mm/kasan/common.c:236
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+0x25c/0x3c0 mm/slub.c:3674
sk_prot_free net/core/sock.c:2083 [inline]
__sk_destruct+0x473/0x5f0 net/core/sock.c:2169
l2cap_sock_release+0x157/0x1d0 net/bluetooth/l2cap_sock.c:1418
__sock_release net/socket.c:654 [inline]
sock_close+0xcd/0x230 net/socket.c:1400
__fput+0x3b7/0x890 fs/file_table.c:320
task_work_run+0x246/0x300 kernel/task_work.c:179
resume_user_mode_work include/linux/resume_user_mode.h:49 [inline]
exit_to_user_mode_loop+0xde/0x100 kernel/entry/common.c:177
exit_to_user_mode_prepare+0xb1/0x140 kernel/entry/common.c:210
__syscall_exit_to_user_mode_work kernel/entry/common.c:292 [inline]
syscall_exit_to_user_mode+0x60/0x270 kernel/entry/common.c:303
do_syscall_64+0x47/0xb0 arch/x86/entry/common.c:87
entry_SYSCALL_64_after_hwframe+0x68/0xd2

The buggy address belongs to the object at ffff88805ea4d000
which belongs to the cache kmalloc-2k of size 2048
The buggy address is located 488 bytes inside of
2048-byte region [ffff88805ea4d000, ffff88805ea4d800)

The buggy address belongs to the physical page:
page:ffffea00017a9200 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x5ea48
head:ffffea00017a9200 order:3 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 ffffea0001cf5a00 dead000000000002 ffff888012442000
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 0x1d28c0(GFP_NOWAIT|__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 99, tgid 99 (kworker/u4:4), ts 163388215108, free_ts 163183328480
set_page_owner include/linux/page_owner.h:31 [inline]
post_alloc_hook+0x18d/0x1b0 mm/page_alloc.c:2513
prep_new_page mm/page_alloc.c:2520 [inline]
get_page_from_freelist+0x31a1/0x3320 mm/page_alloc.c:4279
__alloc_pages+0x28d/0x770 mm/page_alloc.c:5547
alloc_slab_page+0x6a/0x150 mm/slub.c:1794
allocate_slab mm/slub.c:1939 [inline]
new_slab+0x84/0x2d0 mm/slub.c:1992
___slab_alloc+0xc20/0x1270 mm/slub.c:3180
__slab_alloc mm/slub.c:3279 [inline]
slab_alloc_node mm/slub.c:3364 [inline]
__kmem_cache_alloc_node+0x19f/0x260 mm/slub.c:3437
__do_kmalloc_node mm/slab_common.c:954 [inline]
__kmalloc_node_track_caller+0xa0/0x220 mm/slab_common.c:975
kmalloc_reserve net/core/skbuff.c:446 [inline]
pskb_expand_head+0x18c/0x10e0 net/core/skbuff.c:1848
netlink_trim+0x183/0x220 net/netlink/af_netlink.c:1308
netlink_broadcast+0x5b/0x10b0 net/netlink/af_netlink.c:1502
nlmsg_multicast include/net/netlink.h:1071 [inline]
nlmsg_notify+0xfb/0x1c0 net/netlink/af_netlink.c:2551
dev_close_many+0x2a6/0x530 net/core/dev.c:1569
unregister_netdevice_many+0x4f7/0x17a0 net/core/dev.c:10855
default_device_exit_batch+0x956/0x9d0 net/core/dev.c:11394
ops_exit_list net/core/net_namespace.c:177 [inline]
cleanup_net+0x763/0xb60 net/core/net_namespace.c:604
page last free stack trace:
reset_page_owner include/linux/page_owner.h:24 [inline]
free_pages_prepare mm/page_alloc.c:1440 [inline]
free_pcp_prepare mm/page_alloc.c:1490 [inline]
free_unref_page_prepare+0xf63/0x1120 mm/page_alloc.c:3358
free_unref_page+0x33/0x3e0 mm/page_alloc.c:3453
free_slab mm/slub.c:2031 [inline]
discard_slab mm/slub.c:2037 [inline]
__unfreeze_partials+0x1b7/0x210 mm/slub.c:2586
put_cpu_partial+0x17b/0x250 mm/slub.c:2662
qlink_free mm/kasan/quarantine.c:168 [inline]
qlist_free_all+0x76/0xe0 mm/kasan/quarantine.c:187
kasan_quarantine_reduce+0x156/0x170 mm/kasan/quarantine.c:294
__kasan_slab_alloc+0x1f/0x70 mm/kasan/common.c:305
kasan_slab_alloc include/linux/kasan.h:201 [inline]
slab_post_alloc_hook+0x52/0x3a0 mm/slab.h:737
slab_alloc_node mm/slub.c:3398 [inline]
slab_alloc mm/slub.c:3406 [inline]
__kmem_cache_alloc_lru mm/slub.c:3413 [inline]
kmem_cache_alloc+0x10c/0x2d0 mm/slub.c:3422
getname_flags+0xb8/0x4f0 fs/namei.c:139
getname fs/namei.c:218 [inline]
__do_sys_symlinkat fs/namei.c:4519 [inline]
__se_sys_symlinkat fs/namei.c:4516 [inline]
__x64_sys_symlinkat+0x78/0xa0 fs/namei.c:4516
do_syscall_x64 arch/x86/entry/common.c:51 [inline]
do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
entry_SYSCALL_64_after_hwframe+0x68/0xd2

Memory state around the buggy address:
ffff88805ea4d080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88805ea4d100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88805ea4d180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88805ea4d200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88805ea4d280: 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 syzk...@googlegroups.com.

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 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
Reply all
Reply to author
Forward
0 new messages