syzbot


KASAN: use-after-free Write in virtio_transport_recv_pkt

Status: upstream: reported C repro on 2024/04/03 23:46
Reported-by: syzbot+17bca7383bb232a9c969@syzkaller.appspotmail.com
First crash: 212d, last: 20d
Fix bisection: the issue occurs on the latest tested release (bisect log)
  
Similar bugs (3)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
android-5-15 KASAN: use-after-free Write in virtio_transport_recv_pkt origin:upstream C error 1 56d 212d 0/2 upstream: reported C repro on 2024/04/04 06:14
android-6-1 KASAN: use-after-free Write in virtio_transport_recv_pkt origin:upstream C 3 3d00h 212d 0/2 upstream: reported C repro on 2024/04/03 23:05
upstream KMSAN: uninit-value in virtio_transport_recv_pkt net C 20713 358d 372d 25/28 fixed on 2023/12/21 03:45
Last patch testing requests (3)
Created Duration User Patch Repo Result
2024/10/12 18:59 5m retest repro android13-5.10-lts report log
2024/07/29 21:41 9m retest repro android13-5.10-lts report log
2024/04/18 00:05 7m retest repro android13-5.10-lts report log

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in instrument_atomic_read_write include/linux/instrumented.h:101 [inline]
BUG: KASAN: use-after-free in atomic_try_cmpxchg_acquire include/asm-generic/atomic-instrumented.h:705 [inline]
BUG: KASAN: use-after-free in queued_spin_lock include/asm-generic/qspinlock.h:82 [inline]
BUG: KASAN: use-after-free in do_raw_spin_lock include/linux/spinlock.h:183 [inline]
BUG: KASAN: use-after-free in __raw_spin_lock_bh include/linux/spinlock_api_smp.h:136 [inline]
BUG: KASAN: use-after-free in _raw_spin_lock_bh+0x97/0x1b0 kernel/locking/spinlock.c:175
Write of size 4 at addr ffff88811505e788 by task kworker/1:2/325

CPU: 1 PID: 325 Comm: kworker/1:2 Not tainted 5.10.209-syzkaller-00001-ge7daca75b4c3 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/27/2024
Workqueue: vsock-loopback vsock_loopback_work
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack_lvl+0x1e2/0x24b lib/dump_stack.c:118
 print_address_description+0x81/0x3b0 mm/kasan/report.c:248
 __kasan_report mm/kasan/report.c:435 [inline]
 kasan_report+0x179/0x1c0 mm/kasan/report.c:452
 kasan_check_range+0x293/0x2a0 mm/kasan/generic.c:189
 __kasan_check_write+0x14/0x20 mm/kasan/shadow.c:37
 instrument_atomic_read_write include/linux/instrumented.h:101 [inline]
 atomic_try_cmpxchg_acquire include/asm-generic/atomic-instrumented.h:705 [inline]
 queued_spin_lock include/asm-generic/qspinlock.h:82 [inline]
 do_raw_spin_lock include/linux/spinlock.h:183 [inline]
 __raw_spin_lock_bh include/linux/spinlock_api_smp.h:136 [inline]
 _raw_spin_lock_bh+0x97/0x1b0 kernel/locking/spinlock.c:175
 spin_lock_bh include/linux/spinlock.h:359 [inline]
 virtio_transport_space_update net/vmw_vsock/virtio_transport_common.c:1040 [inline]
 virtio_transport_recv_pkt+0x665/0x4130 net/vmw_vsock/virtio_transport_common.c:1164
 vsock_loopback_work+0x37d/0x3f0 net/vmw_vsock/vsock_loopback.c:125
 process_one_work+0x6dc/0xbd0 kernel/workqueue.c:2301
 worker_thread+0xaea/0x1510 kernel/workqueue.c:2447
 kthread+0x34b/0x3d0 kernel/kthread.c:313
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:299

Allocated by task 3447:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track mm/kasan/common.c:45 [inline]
 set_alloc_info mm/kasan/common.c:430 [inline]
 ____kasan_kmalloc+0xdb/0x110 mm/kasan/common.c:509
 __kasan_kmalloc+0x9/0x10 mm/kasan/common.c:518
 kasan_kmalloc include/linux/kasan.h:254 [inline]
 kmem_cache_alloc_trace+0x18a/0x2e0 mm/slub.c:2974
 kmalloc include/linux/slab.h:552 [inline]
 kzalloc include/linux/slab.h:664 [inline]
 virtio_transport_do_socket_init+0x56/0x2d0 net/vmw_vsock/virtio_transport_common.c:475
 vsock_assign_transport+0x324/0x3f0 net/vmw_vsock/af_vsock.c:470
 vsock_stream_connect+0x5cf/0xd30 net/vmw_vsock/af_vsock.c:1297
 __sys_connect_file net/socket.c:1866 [inline]
 __sys_connect+0x388/0x410 net/socket.c:1883
 __do_sys_connect net/socket.c:1893 [inline]
 __se_sys_connect net/socket.c:1890 [inline]
 __x64_sys_connect+0x7a/0x90 net/socket.c:1890
 do_syscall_64+0x34/0x70
 entry_SYSCALL_64_after_hwframe+0x61/0xc6

Freed by task 3447:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:45
 kasan_set_free_info+0x23/0x40 mm/kasan/generic.c:370
 ____kasan_slab_free+0x121/0x160 mm/kasan/common.c:362
 __kasan_slab_free+0x11/0x20 mm/kasan/common.c:370
 kasan_slab_free include/linux/kasan.h:220 [inline]
 slab_free_hook mm/slub.c:1595 [inline]
 slab_free_freelist_hook+0xc0/0x190 mm/slub.c:1621
 slab_free mm/slub.c:3203 [inline]
 kfree+0xc3/0x270 mm/slub.c:4191
 virtio_transport_destruct+0x3b/0x40 net/vmw_vsock/virtio_transport_common.c:693
 vsock_deassign_transport net/vmw_vsock/af_vsock.c:411 [inline]
 vsock_assign_transport+0x266/0x3f0 net/vmw_vsock/af_vsock.c:461
 vsock_stream_connect+0x5cf/0xd30 net/vmw_vsock/af_vsock.c:1297
 __sys_connect_file net/socket.c:1866 [inline]
 __sys_connect+0x388/0x410 net/socket.c:1883
 __do_sys_connect net/socket.c:1893 [inline]
 __se_sys_connect net/socket.c:1890 [inline]
 __x64_sys_connect+0x7a/0x90 net/socket.c:1890
 do_syscall_64+0x34/0x70
 entry_SYSCALL_64_after_hwframe+0x61/0xc6

The buggy address belongs to the object at ffff88811505e780
 which belongs to the cache kmalloc-64 of size 64
The buggy address is located 8 bytes inside of
 64-byte region [ffff88811505e780, ffff88811505e7c0)
The buggy address belongs to the page:
page:ffffea0004541780 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x11505e
flags: 0x4000000000000200(slab)
raw: 4000000000000200 dead000000000100 dead000000000122 ffff888100043800
raw: 0000000000000000 0000000080200020 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 280, ts 22356318178, free_ts 22340792038
 set_page_owner include/linux/page_owner.h:35 [inline]
 post_alloc_hook mm/page_alloc.c:2456 [inline]
 prep_new_page+0x166/0x180 mm/page_alloc.c:2462
 get_page_from_freelist+0x2d8c/0x2f30 mm/page_alloc.c:4254
 __alloc_pages_nodemask+0x435/0xaf0 mm/page_alloc.c:5346
 allocate_slab mm/slub.c:1808 [inline]
 new_slab+0x80/0x400 mm/slub.c:1869
 new_slab_objects mm/slub.c:2627 [inline]
 ___slab_alloc+0x302/0x4b0 mm/slub.c:2791
 __slab_alloc+0x63/0xa0 mm/slub.c:2831
 slab_alloc_node mm/slub.c:2913 [inline]
 slab_alloc mm/slub.c:2955 [inline]
 __kmalloc+0x204/0x330 mm/slub.c:4029
 kmalloc include/linux/slab.h:557 [inline]
 kzalloc include/linux/slab.h:664 [inline]
 ext4_htree_store_dirent+0x7f/0x590 fs/ext4/dir.c:475
 htree_dirblock_to_tree+0x8f7/0x1080 fs/ext4/namei.c:1115
 ext4_htree_fill_tree+0x73d/0x13e0 fs/ext4/namei.c:1194
 ext4_dx_readdir fs/ext4/dir.c:598 [inline]
 ext4_readdir+0x2dde/0x37c0 fs/ext4/dir.c:142
 iterate_dir+0x265/0x580
 __do_sys_getdents64 fs/readdir.c:369 [inline]
 __se_sys_getdents64+0x1c1/0x460 fs/readdir.c:354
 __x64_sys_getdents64+0x7b/0x90 fs/readdir.c:354
 do_syscall_64+0x34/0x70
 entry_SYSCALL_64_after_hwframe+0x61/0xc6
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:28 [inline]
 free_pages_prepare mm/page_alloc.c:1349 [inline]
 __free_pages_ok+0x82c/0x850 mm/page_alloc.c:1629
 free_the_page+0x76/0x370 mm/page_alloc.c:5407
 __free_pages+0x67/0xc0 mm/page_alloc.c:5416
 __free_slab+0xcf/0x190 mm/slub.c:1894
 free_slab mm/slub.c:1909 [inline]
 discard_slab mm/slub.c:1915 [inline]
 unfreeze_partials+0x15e/0x190 mm/slub.c:2410
 put_cpu_partial+0xbf/0x180 mm/slub.c:2446
 __slab_free+0x2c8/0x3a0 mm/slub.c:3095
 do_slab_free mm/slub.c:3191 [inline]
 ___cache_free+0x111/0x130 mm/slub.c:3210
 qlink_free+0x50/0x90 mm/kasan/quarantine.c:157
 qlist_free_all+0x47/0xb0 mm/kasan/quarantine.c:176
 kasan_quarantine_reduce+0x15a/0x170 mm/kasan/quarantine.c:283
 __kasan_slab_alloc+0x2f/0xe0 mm/kasan/common.c:440
 kasan_slab_alloc include/linux/kasan.h:244 [inline]
 slab_post_alloc_hook+0x61/0x2f0 mm/slab.h:583
 slab_alloc_node mm/slub.c:2947 [inline]
 slab_alloc mm/slub.c:2955 [inline]
 kmem_cache_alloc+0x168/0x2e0 mm/slub.c:2960
 ext4_alloc_inode+0x21/0x640 fs/ext4/super.c:1279
 alloc_inode fs/inode.c:233 [inline]
 new_inode_pseudo+0x64/0x220 fs/inode.c:929

Memory state around the buggy address:
 ffff88811505e680: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
 ffff88811505e700: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
>ffff88811505e780: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
                      ^
 ffff88811505e800: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
 ffff88811505e880: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/04/03 23:44 android13-5.10-lts e7daca75b4c3 51c4dcff .config console log report syz C [disk image] [vmlinux] [kernel image] ci2-android-5-10 KASAN: use-after-free Write in virtio_transport_recv_pkt
* Struck through repros no longer work on HEAD.