==================================================================
BUG: KASAN: slab-use-after-free in atkbd_event_work+0x592/0x650
Read of size 4 at addr ffff888177e68164 by task kworker/1:6/23035

CPU: 1 UID: 0 PID: 23035 Comm: kworker/1:6 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
Workqueue: events atkbd_event_work
Call Trace:
 <TASK>
 dump_stack_lvl+0xe8/0x150
 print_address_description+0x55/0x1e0
 print_report+0x58/0x70
 kasan_report+0x117/0x150
 atkbd_event_work+0x592/0x650
 process_scheduled_works+0xc3d/0x1630
 worker_thread+0xa47/0xfb0
 kthread+0x38b/0x480
 ret_from_fork+0x514/0xb70
 ret_from_fork_asm+0x1a/0x30
 </TASK>

Allocated by task 34:
 kasan_save_track+0x3e/0x80
 __kasan_kmalloc+0x93/0xb0
 __kmalloc_cache_noprof+0x31c/0x600
 input_allocate_device+0x4e/0x2a0
 atkbd_connect+0xb1/0x9c0
 serio_driver_probe+0x82/0xa0
 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+0x2bd/0x430
 device_initial_probe+0x9c/0x100
 __bus_probe_device+0x126/0x220
 device_add+0x7d7/0xb80
 serio_handle_event+0x9e6/0xf80
 process_scheduled_works+0xc3d/0x1630
 worker_thread+0xa47/0xfb0
 kthread+0x38b/0x480
 ret_from_fork+0x514/0xb70
 ret_from_fork_asm+0x1a/0x30

Freed by task 17832:
 kasan_save_track+0x3e/0x80
 kasan_save_free_info+0x40/0x50
 __kasan_slab_free+0x5c/0x80
 kfree+0x1c5/0x650
 input_dev_release+0xab/0xc0
 device_release+0xc4/0x1f0
 kobject_put+0x222/0x550
 atkbd_disconnect+0xb5/0x110
 serio_driver_remove+0x85/0xa0
 device_release_driver_internal+0x42b/0x7d0
 serio_unregister_port+0x128/0x150
 userio_char_release+0x80/0xc0
 __fput+0x408/0xa40
 fput_close_sync+0x11f/0x240
 filp_close_sync+0x6e/0xa0
 __se_sys_close_range+0xa77/0xef0
 do_syscall_64+0x166/0x520
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

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

The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x177e68
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 0000000000040004 00000000f5000000 0000000000000000
head: 057ff00000000040 ffff888100042140 dead000000000100 dead000000000122
head: 0000000000000000 0000000000040004 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 15020, tgid 15019 (syz.2.16560), ts 748105048818
 post_alloc_hook+0x1f9/0x250
 get_page_from_freelist+0x200d/0x2080
 __alloc_frozen_pages_noprof+0x1fe/0x410
 allocate_slab+0x7d/0x5e0
 refill_objects+0x2d5/0x350
 __pcs_replace_empty_main+0x2c8/0x6c0
 __kmalloc_noprof+0x476/0x710
 tomoyo_realpath_from_path+0xef/0x640
 tomoyo_path_number_perm+0x246/0x5f0
 security_file_ioctl+0xc3/0x2a0
 __se_sys_ioctl+0x47/0x170
 do_syscall_64+0x166/0x520
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
page last free pid 7331 tgid 7331 ts 729219174703 stack trace:
 __free_frozen_pages+0xd01/0xe10
 __slab_free+0x269/0x2c0
 qlist_free_all+0x99/0x100
 kasan_quarantine_reduce+0x148/0x160
 __kasan_slab_alloc+0x22/0x80
 kmem_cache_alloc_noprof+0x2b4/0x600
 do_getname+0x2e/0x250
 __se_sys_unlink+0x1e/0x140
 do_syscall_64+0x166/0x520
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Memory state around the buggy address:
 ffff888177e68000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888177e68080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888177e68100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                       ^
 ffff888177e68180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888177e68200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
