================================================================== BUG: KASAN: use-after-free in drm_gem_object_release_handle+0x3d/0xb0 drivers/gpu/drm/drm_gem.c:238 Read of size 8 at addr ffff888146b8e1e8 by task syz-executor.5/5255 CPU: 1 PID: 5255 Comm: syz-executor.5 Not tainted 6.0.0-rc7-syzkaller-00162-g5a77386984b5 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/22/2022 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106 print_address_description+0x65/0x4b0 mm/kasan/report.c:317 print_report+0x108/0x220 mm/kasan/report.c:433 kasan_report+0xfb/0x130 mm/kasan/report.c:495 drm_gem_object_release_handle+0x3d/0xb0 drivers/gpu/drm/drm_gem.c:238 idr_for_each+0x1f8/0x2e0 lib/idr.c:208 drm_gem_release+0x21/0x30 drivers/gpu/drm/drm_gem.c:917 drm_file_free+0x6ac/0x920 drivers/gpu/drm/drm_file.c:281 drm_close_helper drivers/gpu/drm/drm_file.c:308 [inline] drm_release+0x33e/0x5c0 drivers/gpu/drm/drm_file.c:495 __fput+0x3b9/0x820 fs/file_table.c:320 task_work_run+0x146/0x1c0 kernel/task_work.c:177 exit_task_work include/linux/task_work.h:38 [inline] do_exit+0x55e/0x20a0 kernel/exit.c:795 do_group_exit+0x23b/0x2f0 kernel/exit.c:925 get_signal+0x172f/0x1780 kernel/signal.c:2857 arch_do_signal_or_restart+0x8d/0x750 arch/x86/kernel/signal.c:869 exit_to_user_mode_loop+0x74/0x160 kernel/entry/common.c:166 exit_to_user_mode_prepare+0xad/0x110 kernel/entry/common.c:201 __syscall_exit_to_user_mode_work kernel/entry/common.c:283 [inline] syscall_exit_to_user_mode+0x2e/0x60 kernel/entry/common.c:294 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7f703368a5a9 Code: Unable to access opcode bytes at RIP 0x7f703368a57f. RSP: 002b:00007f703477a168 EFLAGS: 00000246 ORIG_RAX: 0000000000000009 RAX: fffffffffffffff4 RBX: 00007f70337ac120 RCX: 00007f703368a5a9 RDX: 0000000000000000 RSI: 0000000000003028 RDI: 0000000020ffc000 RBP: 00007f70336e5580 R08: 0000000000000003 R09: 0000000100000000 R10: 0000000000000012 R11: 0000000000000246 R12: 0000000000000000 R13: 00007ffeeb28a08f R14: 00007f703477a300 R15: 0000000000022000 Allocated by task 5254: 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:437 [inline] ____kasan_kmalloc+0xdc/0x110 mm/kasan/common.c:516 kasan_kmalloc include/linux/kasan.h:234 [inline] kmem_cache_alloc_trace+0x97/0x310 mm/slub.c:3289 kmalloc include/linux/slab.h:600 [inline] kzalloc include/linux/slab.h:733 [inline] vgem_gem_create_object+0x46/0xa0 drivers/gpu/drm/vgem/vgem_drv.c:98 __drm_gem_shmem_create+0x7c/0x310 drivers/gpu/drm/drm_gem_shmem_helper.c:62 drm_gem_shmem_create drivers/gpu/drm/drm_gem_shmem_helper.c:127 [inline] drm_gem_shmem_create_with_handle drivers/gpu/drm/drm_gem_shmem_helper.c:424 [inline] drm_gem_shmem_dumb_create+0x243/0x420 drivers/gpu/drm/drm_gem_shmem_helper.c:534 drm_ioctl_kernel+0x33e/0x4f0 drivers/gpu/drm/drm_ioctl.c:782 drm_ioctl+0x626/0xa10 drivers/gpu/drm/drm_ioctl.c:885 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:870 [inline] __se_sys_ioctl+0xfb/0x170 fs/ioctl.c:856 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd Freed by task 5255: kasan_save_stack mm/kasan/common.c:38 [inline] kasan_set_track+0x4c/0x70 mm/kasan/common.c:45 kasan_set_free_info+0x1f/0x40 mm/kasan/generic.c:370 ____kasan_slab_free+0xd8/0x120 mm/kasan/common.c:367 kasan_slab_free include/linux/kasan.h:200 [inline] slab_free_hook mm/slub.c:1759 [inline] slab_free_freelist_hook+0x12e/0x1a0 mm/slub.c:1785 slab_free mm/slub.c:3539 [inline] kfree+0xda/0x210 mm/slub.c:4567 drm_gem_object_free drivers/gpu/drm/drm_gem.c:959 [inline] kref_put include/linux/kref.h:65 [inline] __drm_gem_object_put include/drm/drm_gem.h:381 [inline] drm_gem_object_put include/drm/drm_gem.h:394 [inline] drm_gem_mmap+0x4c9/0x760 drivers/gpu/drm/drm_gem.c:1119 call_mmap include/linux/fs.h:2192 [inline] mmap_region+0x10b2/0x16f0 mm/mmap.c:1752 do_mmap+0x7a7/0xdf0 mm/mmap.c:1540 vm_mmap_pgoff+0x1e5/0x2f0 mm/util.c:552 ksys_mmap_pgoff+0x48c/0x6d0 mm/mmap.c:1586 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd The buggy address belongs to the object at ffff888146b8e000 which belongs to the cache kmalloc-1k of size 1024 The buggy address is located 488 bytes inside of 1024-byte region [ffff888146b8e000, ffff888146b8e400) The buggy address belongs to the physical page: page:ffffea00051ae200 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x146b88 head:ffffea00051ae200 order:3 compound_mapcount:0 compound_pincount:0 flags: 0x57ff00000010200(slab|head|node=1|zone=2|lastcpupid=0x7ff) raw: 057ff00000010200 0000000000000000 dead000000000122 ffff888012041dc0 raw: 0000000000000000 0000000000100010 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 0x1d20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 5250, tgid 5249 (syz-executor.4), ts 279051851227, free_ts 89053723970 prep_new_page mm/page_alloc.c:2532 [inline] get_page_from_freelist+0x72b/0x7a0 mm/page_alloc.c:4283 __alloc_pages+0x259/0x560 mm/page_alloc.c:5549 __alloc_pages_node include/linux/gfp.h:243 [inline] alloc_slab_page+0x2e/0xf0 mm/slub.c:1831 allocate_slab+0x5e/0x520 mm/slub.c:1974 new_slab mm/slub.c:2034 [inline] ___slab_alloc+0x42e/0xce0 mm/slub.c:3036 __slab_alloc mm/slub.c:3123 [inline] slab_alloc_node mm/slub.c:3214 [inline] kmem_cache_alloc_node_trace+0x29c/0x360 mm/slub.c:3312 kmalloc_node include/linux/slab.h:618 [inline] kzalloc_node include/linux/slab.h:744 [inline] io_wq_create+0x38f/0xc30 io_uring/io-wq.c:1164 io_init_wq_offload io_uring/tctx.c:44 [inline] io_uring_alloc_task_context+0x30d/0x61d io_uring/tctx.c:76 __io_uring_add_tctx_node+0x497/0x6e0 io_uring/tctx.c:121 io_uring_install_fd+0x34/0x80 io_uring/io_uring.c:3186 io_uring_create+0x7e9/0xc56 io_uring/io_uring.c:3370 io_uring_setup io_uring/io_uring.c:3410 [inline] __do_sys_io_uring_setup io_uring/io_uring.c:3416 [inline] __se_sys_io_uring_setup io_uring/io_uring.c:3413 [inline] __x64_sys_io_uring_setup+0x226/0x2a0 io_uring/io_uring.c:3413 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1449 [inline] free_pcp_prepare+0x812/0x900 mm/page_alloc.c:1499 free_unref_page_prepare mm/page_alloc.c:3380 [inline] free_unref_page+0x7d/0x630 mm/page_alloc.c:3476 qlist_free_all+0x2b/0x70 mm/kasan/quarantine.c:187 kasan_quarantine_reduce+0x169/0x180 mm/kasan/quarantine.c:294 __kasan_slab_alloc+0x2f/0xe0 mm/kasan/common.c:447 kasan_slab_alloc include/linux/kasan.h:224 [inline] slab_post_alloc_hook mm/slab.h:727 [inline] slab_alloc_node mm/slub.c:3248 [inline] slab_alloc mm/slub.c:3256 [inline] kmem_cache_alloc_trace+0x1de/0x310 mm/slub.c:3287 kmalloc include/linux/slab.h:600 [inline] kzalloc include/linux/slab.h:733 [inline] kernfs_fop_open+0x3c4/0xc70 fs/kernfs/file.c:680 do_dentry_open+0x777/0x1180 fs/open.c:880 do_open fs/namei.c:3557 [inline] path_openat+0x260e/0x2e00 fs/namei.c:3691 do_filp_open+0x275/0x500 fs/namei.c:3718 do_sys_openat2+0x13b/0x500 fs/open.c:1313 do_sys_open fs/open.c:1329 [inline] __do_sys_openat fs/open.c:1345 [inline] __se_sys_openat fs/open.c:1340 [inline] __x64_sys_openat+0x243/0x290 fs/open.c:1340 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd Memory state around the buggy address: ffff888146b8e080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888146b8e100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff888146b8e180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff888146b8e200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888146b8e280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================