==================================================================
BUG: KASAN: slab-use-after-free in snd_usb_midi_v2_free+0x602/0x7b0
Write of size 8 at addr ffff8881ae858350 by task syz.2.7961/12426

CPU: 0 UID: 0 PID: 12426 Comm: syz.2.7961 Tainted: G             L      syzkaller #0 PREEMPT(full) 
Tainted: [L]=SOFTLOCKUP
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.2-debian-1.16.2-1 04/01/2014
Call Trace:
 <TASK>
 dump_stack_lvl+0xe8/0x150
 print_address_description+0x55/0x1e0
 print_report+0x58/0x70
 kasan_report+0x117/0x150
 snd_usb_midi_v2_free+0x602/0x7b0
 snd_usb_midi_v2_free_all+0x67/0x90
 snd_usb_audio_free+0x4c/0x100
 release_card_device+0xab/0x1b0
 device_release+0xc4/0x1f0
 kobject_put+0x222/0x550
 usb_unbind_interface+0x295/0x9f0
 device_release_driver_internal+0x4f5/0x880
 bus_remove_device+0x444/0x560
 device_del+0x524/0x8f0
 usb_disable_device+0x3d4/0x8d0
 usb_disconnect+0x346/0x9a0
 hub_quiesce+0x171/0x330
 hub_disconnect+0xc6/0x450
 usb_unbind_interface+0x295/0x9f0
 device_release_driver_internal+0x4f5/0x880
 proc_disconnect_claim+0x34a/0x3e0
 usbdev_ioctl+0x132d/0x2120
 __se_sys_ioctl+0xfc/0x170
 do_syscall_64+0x174/0x580
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fd14679e0d9
Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fd1449f6028 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007fd146a25fa0 RCX: 00007fd14679e0d9
RDX: 0000200000000000 RSI: 000000008108551b RDI: 000000000000000a
RBP: 00007fd146835024 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007fd146a26038 R14: 00007fd146a25fa0 R15: 00007ffe76ee1518
 </TASK>

Allocated by task 10299:
 kasan_save_track+0x3e/0x80
 __kasan_kmalloc+0x93/0xb0
 __kmalloc_cache_noprof+0x32d/0x660
 snd_ump_endpoint_new+0x7d/0x3d0
 create_midi2_ump+0x314/0x7b0
 snd_usb_midi_v2_create+0x140d/0x4ac0
 snd_usb_create_stream+0x262/0x630
 usb_audio_probe+0x1447/0x2280
 usb_probe_interface+0x653/0xc60
 really_probe+0x254/0xae0
 __driver_probe_device+0x1e8/0x360
 driver_probe_device+0x4f/0x240
 __device_attach_driver+0x270/0x410
 bus_for_each_drv+0x258/0x2f0
 __device_attach+0x2c4/0x450
 device_initial_probe+0xa1/0xd0
 bus_probe_device+0x12a/0x220
 device_add+0x7d7/0xb80
 usb_set_configuration+0x1ad8/0x2180
 usb_generic_driver_probe+0x8d/0x150
 usb_probe_device+0x1c3/0x3b0
 really_probe+0x254/0xae0
 __driver_probe_device+0x1e8/0x360
 driver_probe_device+0x4f/0x240
 __device_attach_driver+0x270/0x410
 bus_for_each_drv+0x258/0x2f0
 __device_attach+0x2c4/0x450
 device_initial_probe+0xa1/0xd0
 bus_probe_device+0x12a/0x220
 device_add+0x7d7/0xb80
 usb_new_device+0x9aa/0x1690
 hub_event+0x28e8/0x4d30
 process_scheduled_works+0xa8e/0x14e0
 worker_thread+0xa47/0xfb0
 kthread+0x388/0x470
 ret_from_fork+0x514/0xb70
 ret_from_fork_asm+0x1a/0x30

Freed by task 12426:
 kasan_save_track+0x3e/0x80
 kasan_save_free_info+0x40/0x50
 __kasan_slab_free+0x5c/0x80
 kfree+0x1c5/0x640
 snd_rawmidi_free+0x400/0x420
 snd_rawmidi_dev_free+0x38/0x50
 snd_device_free_all+0x2c7/0x7a0
 release_card_device+0x75/0x1b0
 device_release+0xc4/0x1f0
 kobject_put+0x222/0x550
 usb_unbind_interface+0x295/0x9f0
 device_release_driver_internal+0x4f5/0x880
 bus_remove_device+0x444/0x560
 device_del+0x524/0x8f0
 usb_disable_device+0x3d4/0x8d0
 usb_disconnect+0x346/0x9a0
 hub_quiesce+0x171/0x330
 hub_disconnect+0xc6/0x450
 usb_unbind_interface+0x295/0x9f0
 device_release_driver_internal+0x4f5/0x880
 proc_disconnect_claim+0x34a/0x3e0
 usbdev_ioctl+0x132d/0x2120
 __se_sys_ioctl+0xfc/0x170
 do_syscall_64+0x174/0x580
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

The buggy address belongs to the object at ffff8881ae858000
 which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 848 bytes inside of
 freed 4096-byte region [ffff8881ae858000, ffff8881ae859000)

The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1ae858
head: order:3 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0x57ff00000000040(head|node=1|zone=2|lastcpupid=0x7ff)
page_type: f5(slab)
raw: 057ff00000000040 ffff888100042140 dead000000000100 dead000000000122
raw: 0000000000000000 0000000800040004 00000000f5000000 0000000000000000
head: 057ff00000000040 ffff888100042140 dead000000000100 dead000000000122
head: 0000000000000000 0000000800040004 00000000f5000000 0000000000000000
head: 057ff00000000003 fffffffffffffe01 00000000ffffffff 00000000ffffffff
head: ffffffffffffffff 0000000000000000 00000000ffffffff 0000000000000008
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask 0x1d2040(__GFP_IO|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 23378, tgid 23376 (syz.4.3621), ts 743166128456, free_ts 743082742916
 post_alloc_hook+0x1f9/0x250
 get_page_from_freelist+0x21fa/0x2270
 __alloc_frozen_pages_noprof+0x18d/0x380
 allocate_slab+0x79/0x5e0
 refill_objects+0x2d5/0x350
 __pcs_replace_empty_main+0x2bf/0x6b0
 __kmalloc_noprof+0x485/0x720
 tomoyo_realpath_from_path+0xef/0x640
 tomoyo_check_open_permission+0x229/0x470
 security_file_open+0xa9/0x240
 do_dentry_open+0x4a0/0x1380
 vfs_open+0x3b/0x340
 path_openat+0x2e44/0x3830
 do_file_open+0x23e/0x4a0
 do_sys_openat2+0x115/0x200
 __x64_sys_openat+0x138/0x170
page last free pid 23376 tgid 23376 stack trace:
 __free_frozen_pages+0xc1e/0xd10
 __slab_free+0x274/0x2c0
 qlist_free_all+0x99/0x100
 kasan_quarantine_reduce+0x148/0x160
 __kasan_slab_alloc+0x22/0x80
 kmem_cache_alloc_noprof+0x2a0/0x5f0
 security_inode_alloc+0x39/0x310
 inode_init_always_gfp+0x97e/0xd30
 alloc_inode+0x82/0x1b0
 new_inode+0x1f/0x170
 shmem_get_inode+0x3a4/0xfe0
 shmem_symlink+0xa2/0x460
 vfs_symlink+0x18b/0x330
 filename_symlinkat+0x1cd/0x410
 __se_sys_symlinkat+0x4e/0x2b0
 do_syscall_64+0x174/0x580

Memory state around the buggy address:
 ffff8881ae858200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8881ae858280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8881ae858300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                 ^
 ffff8881ae858380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8881ae858400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
