syzbot


KASAN: use-after-free Write in virtio_transport_recv_pkt

Status: upstream: reported C repro on 2024/04/03 23:05
Bug presence: origin:upstream
[Documentation on labels]
Reported-by: syzbot+9d13849d0e9e0ec75d47@syzkaller.appspotmail.com
First crash: 371d, last: 47d
Fix bisection: fixed by (bisect log) :
commit a3c9390f14cc590ca71407a908ca0482af583fa0
Author: Stefano Garzarella <sgarzare@redhat.com>
Date: Fri Jan 10 08:35:09 2025 +0000

  vsock/virtio: cancel close work in the destructor

  
Bug presence (2)
Date Name Commit Repro Result
2024/04/03 lts (merge base) 883d1a956208 C [report] KASAN: use-after-free Write in virtio_transport_recv_pkt
2024/04/03 upstream (ToT) c85af715cac0 C [report] KASAN: slab-use-after-free Write in virtio_transport_recv_pkt
Similar bugs (3)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
android-5-10 KASAN: use-after-free Write in virtio_transport_recv_pkt C inconclusive 1 179d 371d 0/2 auto-obsoleted due to no activity on 2025/03/02 12:40
android-5-15 KASAN: use-after-free Write in virtio_transport_recv_pkt origin:upstream C error 1 214d 370d 0/2 auto-obsoleted due to no activity on 2025/03/05 03:36
upstream KMSAN: uninit-value in virtio_transport_recv_pkt net C 20713 516d 530d 25/28 fixed on 2023/12/21 03:45
Fix bisection attempts (9)
Created Duration User Patch Repo Result
2025/03/24 01:44 4h05m bisect fix android14-6.1 OK (1) job log
2025/02/21 20:29 54m bisect fix android14-6.1 OK (0) job log log
2025/01/21 21:49 44m bisect fix android14-6.1 OK (0) job log log
2024/12/14 01:40 1h28m bisect fix android14-6.1 OK (0) job log log
2024/10/30 16:19 1h25m bisect fix android14-6.1 OK (0) job log log
2024/09/30 00:18 42m bisect fix android14-6.1 OK (0) job log log
2024/08/22 04:13 49m bisect fix android14-6.1 OK (0) job log log
2024/07/11 17:59 1h38m bisect fix android14-6.1 OK (0) job log log
2024/05/23 06:01 1h31m bisect fix android14-6.1 OK (0) job log log

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in instrument_atomic_read_write include/linux/instrumented.h:102 [inline]
BUG: KASAN: use-after-free in atomic_try_cmpxchg_acquire include/linux/atomic/atomic-instrumented.h:541 [inline]
BUG: KASAN: use-after-free in queued_spin_lock include/asm-generic/qspinlock.h:111 [inline]
BUG: KASAN: use-after-free in do_raw_spin_lock include/linux/spinlock.h:186 [inline]
BUG: KASAN: use-after-free in __raw_spin_lock_bh include/linux/spinlock_api_smp.h:127 [inline]
BUG: KASAN: use-after-free in _raw_spin_lock_bh+0x97/0x1b0 kernel/locking/spinlock.c:178
Write of size 4 at addr ffff888114764088 by task kworker/0:4/343

CPU: 0 PID: 343 Comm: kworker/0:4 Not tainted 6.1.78-syzkaller-00133-g74c507aab139 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/02/2024
Workqueue: vsock-loopback vsock_loopback_work
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x151/0x1b7 lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:316 [inline]
 print_report+0x158/0x4e0 mm/kasan/report.c:427
 kasan_report+0x13c/0x170 mm/kasan/report.c:531
 kasan_check_range+0x294/0x2a0 mm/kasan/generic.c:189
 __kasan_check_write+0x14/0x20 mm/kasan/shadow.c:37
 instrument_atomic_read_write include/linux/instrumented.h:102 [inline]
 atomic_try_cmpxchg_acquire include/linux/atomic/atomic-instrumented.h:541 [inline]
 queued_spin_lock include/asm-generic/qspinlock.h:111 [inline]
 do_raw_spin_lock include/linux/spinlock.h:186 [inline]
 __raw_spin_lock_bh include/linux/spinlock_api_smp.h:127 [inline]
 _raw_spin_lock_bh+0x97/0x1b0 kernel/locking/spinlock.c:178
 spin_lock_bh include/linux/spinlock.h:355 [inline]
 virtio_transport_space_update net/vmw_vsock/virtio_transport_common.c:1171 [inline]
 virtio_transport_recv_pkt+0x6d3/0x4130 net/vmw_vsock/virtio_transport_common.c:1307
 vsock_loopback_work+0x37d/0x3f0 net/vmw_vsock/vsock_loopback.c:137
 process_one_work+0x73d/0xcb0 kernel/workqueue.c:2299
 worker_thread+0xa60/0x1260 kernel/workqueue.c:2446
 kthread+0x26d/0x300 kernel/kthread.c:386
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306
 </TASK>

Allocated by task 2153:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
 kasan_save_alloc_info+0x1f/0x30 mm/kasan/generic.c:505
 ____kasan_kmalloc mm/kasan/common.c:379 [inline]
 __kasan_kmalloc+0x9c/0xb0 mm/kasan/common.c:388
 kasan_kmalloc include/linux/kasan.h:212 [inline]
 kmalloc_trace+0x44/0xa0 mm/slab_common.c:1052
 kmalloc include/linux/slab.h:553 [inline]
 kzalloc include/linux/slab.h:689 [inline]
 virtio_transport_do_socket_init+0x56/0x2d0 net/vmw_vsock/virtio_transport_common.c:604
 vsock_assign_transport+0x473/0x5b0 net/vmw_vsock/af_vsock.c:506
 vsock_connect+0x5cf/0xd30 net/vmw_vsock/af_vsock.c:1361
 __sys_connect_file net/socket.c:1996 [inline]
 __sys_connect+0x2c9/0x300 net/socket.c:2013
 __do_sys_connect net/socket.c:2023 [inline]
 __se_sys_connect net/socket.c:2020 [inline]
 __x64_sys_connect+0x7a/0x90 net/socket.c:2020
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

Freed by task 2153:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
 kasan_save_free_info+0x2b/0x40 mm/kasan/generic.c:516
 ____kasan_slab_free+0x131/0x180 mm/kasan/common.c:241
 __kasan_slab_free+0x11/0x20 mm/kasan/common.c:249
 kasan_slab_free include/linux/kasan.h:178 [inline]
 slab_free_hook mm/slub.c:1745 [inline]
 slab_free_freelist_hook mm/slub.c:1771 [inline]
 slab_free mm/slub.c:3684 [inline]
 __kmem_cache_free+0x218/0x3b0 mm/slub.c:3697
 kfree+0x7a/0xf0 mm/slab_common.c:1009
 virtio_transport_destruct+0x3b/0x40 net/vmw_vsock/virtio_transport_common.c:815
 vsock_deassign_transport net/vmw_vsock/af_vsock.c:421 [inline]
 vsock_assign_transport+0x32b/0x5b0 net/vmw_vsock/af_vsock.c:489
 vsock_connect+0x5cf/0xd30 net/vmw_vsock/af_vsock.c:1361
 __sys_connect_file net/socket.c:1996 [inline]
 __sys_connect+0x2c9/0x300 net/socket.c:2013
 __do_sys_connect net/socket.c:2023 [inline]
 __se_sys_connect net/socket.c:2020 [inline]
 __x64_sys_connect+0x7a/0x90 net/socket.c:2020
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

Last potentially related work creation:
 kasan_save_stack+0x3b/0x60 mm/kasan/common.c:45
 __kasan_record_aux_stack+0xb4/0xc0 mm/kasan/generic.c:486
 kasan_record_aux_stack_noalloc+0xb/0x10 mm/kasan/generic.c:496
 kvfree_call_rcu+0x9f/0x800 kernel/rcu/tree.c:3444
 kernfs_unlink_open_file+0x327/0x3d0 fs/kernfs/file.c:629
 kernfs_fop_release+0x253/0x310 fs/kernfs/file.c:801
 __fput+0x3ab/0x870 fs/file_table.c:320
 ____fput+0x15/0x20 fs/file_table.c:348
 task_work_run+0x24d/0x2e0 kernel/task_work.c:179
 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline]
 exit_to_user_mode_loop+0x94/0xa0 kernel/entry/common.c:171
 exit_to_user_mode_prepare+0x5a/0xa0 kernel/entry/common.c:204
 __syscall_exit_to_user_mode_work kernel/entry/common.c:286 [inline]
 syscall_exit_to_user_mode+0x26/0x140 kernel/entry/common.c:297
 do_syscall_64+0x49/0xb0 arch/x86/entry/common.c:87
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

The buggy address belongs to the object at ffff888114764080
 which belongs to the cache kmalloc-96 of size 96
The buggy address is located 8 bytes inside of
 96-byte region [ffff888114764080, ffff8881147640e0)

The buggy address belongs to the physical page:
page:ffffea000451d900 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff888114764400 pfn:0x114764
flags: 0x4000000000000200(slab|zone=1)
raw: 4000000000000200 ffffea0004238540 dead000000000004 ffff888100042900
raw: ffff888114764400 0000000080200018 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), pid 102, tgid 102 (udevd), ts 3881985527, free_ts 0
 set_page_owner include/linux/page_owner.h:33 [inline]
 post_alloc_hook+0x213/0x220 mm/page_alloc.c:2590
 prep_new_page+0x1b/0x110 mm/page_alloc.c:2597
 get_page_from_freelist+0x27ea/0x2870 mm/page_alloc.c:4425
 __alloc_pages+0x3a1/0x780 mm/page_alloc.c:5712
 alloc_slab_page+0x6c/0xf0
 allocate_slab mm/slub.c:1962 [inline]
 new_slab+0x90/0x3e0 mm/slub.c:2015
 ___slab_alloc+0x6f9/0xb80 mm/slub.c:3203
 __slab_alloc+0x5d/0xa0 mm/slub.c:3302
 slab_alloc_node mm/slub.c:3387 [inline]
 __kmem_cache_alloc_node+0x1af/0x250 mm/slub.c:3460
 kmalloc_trace+0x2a/0xa0 mm/slab_common.c:1047
 kmalloc include/linux/slab.h:553 [inline]
 kzalloc include/linux/slab.h:689 [inline]
 kernfs_get_open_node fs/kernfs/file.c:568 [inline]
 kernfs_fop_open+0x70e/0xb10 fs/kernfs/file.c:736
 do_dentry_open+0x891/0x1250 fs/open.c:884
 vfs_open+0x73/0x80 fs/open.c:1015
 do_open fs/namei.c:3627 [inline]
 path_openat+0x2532/0x2d60 fs/namei.c:3784
 do_filp_open+0x230/0x480 fs/namei.c:3811
 do_sys_openat2+0x13f/0x850 fs/open.c:1341
page_owner free stack trace missing

Memory state around the buggy address:
 ffff888114763f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff888114764000: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
>ffff888114764080: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
                      ^
 ffff888114764100: 00 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc
 ffff888114764180: 00 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc
==================================================================

Crashes (3):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/06/01 21:41 android14-6.1 74c507aab139 3113787f .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Write in virtio_transport_recv_pkt
2024/04/03 22:58 android14-6.1 af361f9a1066 51c4dcff .config console log report syz C [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Write in virtio_transport_recv_pkt
2024/04/03 22:29 android14-6.1 af361f9a1066 51c4dcff .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Write in virtio_transport_recv_pkt
* Struck through repros no longer work on HEAD.