RBP: 00007ffcee35e4e0 R08: 0000000000000003 R09: 0000000100000000 R10: 0000000000000012 R11: 0000000000000246 R12: 0000000000000004 R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 ================================================================== BUG: KASAN: use-after-free in drm_gem_object_release_handle+0xf2/0x110 drivers/gpu/drm/drm_gem.c:252 drivers/gpu/drm/drm_gem.c:252 Read of size 8 at addr ffff888078de9228 by task syz-executor763/3596 CPU: 0 PID: 3596 Comm: syz-executor763 Not tainted 5.16.0-rc5-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] __dump_stack lib/dump_stack.c:88 [inline] lib/dump_stack.c:106 dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106 lib/dump_stack.c:106 print_address_description.constprop.0.cold+0x8d/0x320 mm/kasan/report.c:247 mm/kasan/report.c:247 __kasan_report mm/kasan/report.c:433 [inline] __kasan_report mm/kasan/report.c:433 [inline] mm/kasan/report.c:450 kasan_report.cold+0x83/0xdf mm/kasan/report.c:450 mm/kasan/report.c:450 drm_gem_object_release_handle+0xf2/0x110 drivers/gpu/drm/drm_gem.c:252 drivers/gpu/drm/drm_gem.c:252 idr_for_each+0x113/0x220 lib/idr.c:208 lib/idr.c:208 drm_gem_release+0x22/0x30 drivers/gpu/drm/drm_gem.c:930 drivers/gpu/drm/drm_gem.c:930 drm_file_free.part.0+0x805/0xb80 drivers/gpu/drm/drm_file.c:281 drivers/gpu/drm/drm_file.c:281 drm_file_free drivers/gpu/drm/drm_file.c:248 [inline] drm_file_free drivers/gpu/drm/drm_file.c:248 [inline] drivers/gpu/drm/drm_file.c:308 drm_close_helper.isra.0+0x17d/0x1f0 drivers/gpu/drm/drm_file.c:308 drivers/gpu/drm/drm_file.c:308 drm_release+0x1e6/0x530 drivers/gpu/drm/drm_file.c:495 drivers/gpu/drm/drm_file.c:495 __fput+0x286/0x9f0 fs/file_table.c:280 fs/file_table.c:280 task_work_run+0xdd/0x1a0 kernel/task_work.c:164 kernel/task_work.c:164 exit_task_work include/linux/task_work.h:32 [inline] exit_task_work include/linux/task_work.h:32 [inline] kernel/exit.c:832 do_exit+0xc14/0x2b40 kernel/exit.c:832 kernel/exit.c:832 do_group_exit+0x125/0x310 kernel/exit.c:929 kernel/exit.c:929 __do_sys_exit_group kernel/exit.c:940 [inline] __se_sys_exit_group kernel/exit.c:938 [inline] __do_sys_exit_group kernel/exit.c:940 [inline] kernel/exit.c:938 __se_sys_exit_group kernel/exit.c:938 [inline] kernel/exit.c:938 __x64_sys_exit_group+0x3a/0x50 kernel/exit.c:938 kernel/exit.c:938 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_x64 arch/x86/entry/common.c:50 [inline] arch/x86/entry/common.c:80 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae RIP: 0033:0x7fe01452c9f9 Code: Unable to access opcode bytes at RIP 0x7fe01452c9cf. RSP: 002b:00007ffcee35e4b8 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7 RAX: ffffffffffffffda RBX: 00007fe0145a03f0 RCX: 00007fe01452c9f9 RDX: 000000000000003c RSI: 00000000000000e7 RDI: 0000000000000000 RBP: 0000000000000000 R08: ffffffffffffffc0 R09: 0000000100000000 R10: 0000000000000012 R11: 0000000000000246 R12: 00007fe0145a03f0 R13: 0000000000000001 R14: 0000000000000000 R15: 0000000000000001 Allocated by task 3596: kasan_save_stack+0x1e/0x50 mm/kasan/common.c:38 mm/kasan/common.c:38 kasan_set_track mm/kasan/common.c:46 [inline] set_alloc_info mm/kasan/common.c:434 [inline] ____kasan_kmalloc mm/kasan/common.c:513 [inline] ____kasan_kmalloc mm/kasan/common.c:472 [inline] kasan_set_track mm/kasan/common.c:46 [inline] mm/kasan/common.c:522 set_alloc_info mm/kasan/common.c:434 [inline] mm/kasan/common.c:522 ____kasan_kmalloc mm/kasan/common.c:513 [inline] mm/kasan/common.c:522 ____kasan_kmalloc mm/kasan/common.c:472 [inline] mm/kasan/common.c:522 __kasan_kmalloc+0xa9/0xd0 mm/kasan/common.c:522 mm/kasan/common.c:522 kmalloc include/linux/slab.h:590 [inline] kzalloc include/linux/slab.h:724 [inline] kmalloc include/linux/slab.h:590 [inline] drivers/gpu/drm/vgem/vgem_drv.c:98 kzalloc include/linux/slab.h:724 [inline] drivers/gpu/drm/vgem/vgem_drv.c:98 vgem_gem_create_object+0x38/0xa0 drivers/gpu/drm/vgem/vgem_drv.c:98 drivers/gpu/drm/vgem/vgem_drv.c:98 __drm_gem_shmem_create+0x80/0x470 drivers/gpu/drm/drm_gem_shmem_helper.c:55 drivers/gpu/drm/drm_gem_shmem_helper.c:55 drm_gem_shmem_create drivers/gpu/drm/drm_gem_shmem_helper.c:117 [inline] drm_gem_shmem_create drivers/gpu/drm/drm_gem_shmem_helper.c:117 [inline] drivers/gpu/drm/drm_gem_shmem_helper.c:423 drm_gem_shmem_create_with_handle+0x26/0x100 drivers/gpu/drm/drm_gem_shmem_helper.c:423 drivers/gpu/drm/drm_gem_shmem_helper.c:423 drm_gem_shmem_dumb_create+0x13f/0x290 drivers/gpu/drm/drm_gem_shmem_helper.c:539 drivers/gpu/drm/drm_gem_shmem_helper.c:539 drm_mode_create_dumb+0x26c/0x2f0 drivers/gpu/drm/drm_dumb_buffers.c:96 drivers/gpu/drm/drm_dumb_buffers.c:96 drm_ioctl_kernel+0x27d/0x4e0 drivers/gpu/drm/drm_ioctl.c:782 drivers/gpu/drm/drm_ioctl.c:782 drm_ioctl+0x51e/0x9d0 drivers/gpu/drm/drm_ioctl.c:885 drivers/gpu/drm/drm_ioctl.c:885 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:874 [inline] __se_sys_ioctl fs/ioctl.c:860 [inline] vfs_ioctl fs/ioctl.c:51 [inline] fs/ioctl.c:860 __do_sys_ioctl fs/ioctl.c:874 [inline] fs/ioctl.c:860 __se_sys_ioctl fs/ioctl.c:860 [inline] fs/ioctl.c:860 __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:860 fs/ioctl.c:860 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_x64 arch/x86/entry/common.c:50 [inline] arch/x86/entry/common.c:80 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae Freed by task 3596: kasan_save_stack+0x1e/0x50 mm/kasan/common.c:38 mm/kasan/common.c:38 kasan_set_track+0x21/0x30 mm/kasan/common.c:46 mm/kasan/common.c:46 kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:370 mm/kasan/generic.c:370 ____kasan_slab_free mm/kasan/common.c:366 [inline] ____kasan_slab_free mm/kasan/common.c:328 [inline] ____kasan_slab_free mm/kasan/common.c:366 [inline] mm/kasan/common.c:374 ____kasan_slab_free mm/kasan/common.c:328 [inline] mm/kasan/common.c:374 __kasan_slab_free+0xff/0x130 mm/kasan/common.c:374 mm/kasan/common.c:374 kasan_slab_free include/linux/kasan.h:235 [inline] slab_free_hook mm/slub.c:1723 [inline] kasan_slab_free include/linux/kasan.h:235 [inline] mm/slub.c:1749 slab_free_hook mm/slub.c:1723 [inline] mm/slub.c:1749 slab_free_freelist_hook+0x8b/0x1c0 mm/slub.c:1749 mm/slub.c:1749 slab_free mm/slub.c:3513 [inline] slab_free mm/slub.c:3513 [inline] mm/slub.c:4561 kfree+0xf6/0x560 mm/slub.c:4561 mm/slub.c:4561 drm_gem_object_free+0x58/0x80 drivers/gpu/drm/drm_gem.c:972 drivers/gpu/drm/drm_gem.c:972 kref_put include/linux/kref.h:65 [inline] __drm_gem_object_put include/drm/drm_gem.h:371 [inline] drm_gem_object_put include/drm/drm_gem.h:384 [inline] kref_put include/linux/kref.h:65 [inline] drivers/gpu/drm/drm_gem.c:1132 __drm_gem_object_put include/drm/drm_gem.h:371 [inline] drivers/gpu/drm/drm_gem.c:1132 drm_gem_object_put include/drm/drm_gem.h:384 [inline] drivers/gpu/drm/drm_gem.c:1132 drm_gem_mmap+0x4aa/0x680 drivers/gpu/drm/drm_gem.c:1132 drivers/gpu/drm/drm_gem.c:1132 call_mmap include/linux/fs.h:2167 [inline] call_mmap include/linux/fs.h:2167 [inline] mm/mmap.c:1786 mmap_region+0xd8c/0x1650 mm/mmap.c:1786 mm/mmap.c:1786 do_mmap+0x869/0xfb0 mm/mmap.c:1575 mm/mmap.c:1575 vm_mmap_pgoff+0x1b7/0x290 mm/util.c:519 mm/util.c:519 ksys_mmap_pgoff+0x40d/0x5a0 mm/mmap.c:1623 mm/mmap.c:1623 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_x64 arch/x86/entry/common.c:50 [inline] arch/x86/entry/common.c:80 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae The buggy address belongs to the object at ffff888078de9000 which belongs to the cache kmalloc-1k of size 1024 The buggy address is located 552 bytes inside of 1024-byte region [ffff888078de9000, ffff888078de9400) The buggy address belongs to the page: page:ffffea0001e37a00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x78de8 head:ffffea0001e37a00 order:3 compound_mapcount:0 compound_pincount:0 flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000010200 0000000000000000 dead000000000122 ffff888010c41dc0 raw: 0000000000000000 0000000080100010 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 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 3594, ts 50106996374, free_ts 50054496628 prep_new_page mm/page_alloc.c:2418 [inline] prep_new_page mm/page_alloc.c:2418 [inline] mm/page_alloc.c:4149 get_page_from_freelist+0xa72/0x2f50 mm/page_alloc.c:4149 mm/page_alloc.c:4149 __alloc_pages+0x1b2/0x500 mm/page_alloc.c:5369 mm/page_alloc.c:5369 alloc_pages+0x1a7/0x300 mm/mempolicy.c:2191 mm/mempolicy.c:2191 alloc_slab_page mm/slub.c:1793 [inline] allocate_slab mm/slub.c:1930 [inline] alloc_slab_page mm/slub.c:1793 [inline] mm/slub.c:1993 allocate_slab mm/slub.c:1930 [inline] mm/slub.c:1993 new_slab+0x32d/0x4a0 mm/slub.c:1993 mm/slub.c:1993 ___slab_alloc+0x918/0xfe0 mm/slub.c:3022 mm/slub.c:3022 __slab_alloc.constprop.0+0x4d/0xa0 mm/slub.c:3109 mm/slub.c:3109 slab_alloc_node mm/slub.c:3200 [inline] slab_alloc_node mm/slub.c:3200 [inline] mm/slub.c:4956 __kmalloc_node_track_caller+0x2cb/0x360 mm/slub.c:4956 mm/slub.c:4956 kmalloc_reserve net/core/skbuff.c:354 [inline] kmalloc_reserve net/core/skbuff.c:354 [inline] net/core/skbuff.c:426 __alloc_skb+0xde/0x340 net/core/skbuff.c:426 net/core/skbuff.c:426 alloc_skb_fclone include/linux/skbuff.h:1176 [inline] alloc_skb_fclone include/linux/skbuff.h:1176 [inline] net/ipv4/tcp.c:861 tcp_stream_alloc_skb+0x66/0x910 net/ipv4/tcp.c:861 net/ipv4/tcp.c:861 tcp_sendmsg_locked+0xaba/0x3040 net/ipv4/tcp.c:1281 net/ipv4/tcp.c:1281 tcp_sendmsg+0x2b/0x40 net/ipv4/tcp.c:1440 net/ipv4/tcp.c:1440 inet_sendmsg+0x99/0xe0 net/ipv4/af_inet.c:819 net/ipv4/af_inet.c:819 sock_sendmsg_nosec net/socket.c:704 [inline] sock_sendmsg_nosec net/socket.c:704 [inline] net/socket.c:724 sock_sendmsg+0xcf/0x120 net/socket.c:724 net/socket.c:724 sock_write_iter+0x289/0x3c0 net/socket.c:1057 net/socket.c:1057 call_write_iter include/linux/fs.h:2162 [inline] call_write_iter include/linux/fs.h:2162 [inline] fs/read_write.c:503 new_sync_write+0x429/0x660 fs/read_write.c:503 fs/read_write.c:503 vfs_write+0x7cd/0xae0 fs/read_write.c:590 fs/read_write.c:590 page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1338 [inline] reset_page_owner include/linux/page_owner.h:24 [inline] mm/page_alloc.c:1389 free_pages_prepare mm/page_alloc.c:1338 [inline] mm/page_alloc.c:1389 free_pcp_prepare+0x374/0x870 mm/page_alloc.c:1389 mm/page_alloc.c:1389 free_unref_page_prepare mm/page_alloc.c:3309 [inline] free_unref_page_prepare mm/page_alloc.c:3309 [inline] mm/page_alloc.c:3388 free_unref_page+0x19/0x690 mm/page_alloc.c:3388 mm/page_alloc.c:3388 __put_page+0x27a/0x470 mm/swap.c:128 mm/swap.c:128 folio_put include/linux/mm.h:1237 [inline] put_page include/linux/mm.h:1255 [inline] folio_put include/linux/mm.h:1237 [inline] kernel/exit.c:871 put_page include/linux/mm.h:1255 [inline] kernel/exit.c:871 do_exit+0x204f/0x2b40 kernel/exit.c:871 kernel/exit.c:871 do_group_exit+0x125/0x310 kernel/exit.c:929 kernel/exit.c:929 __do_sys_exit_group kernel/exit.c:940 [inline] __se_sys_exit_group kernel/exit.c:938 [inline] __do_sys_exit_group kernel/exit.c:940 [inline] kernel/exit.c:938 __se_sys_exit_group kernel/exit.c:938 [inline] kernel/exit.c:938 __x64_sys_exit_group+0x3a/0x50 kernel/exit.c:938 kernel/exit.c:938 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_x64 arch/x86/entry/common.c:50 [inline] arch/x86/entry/common.c:80 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae Memory state around the buggy address: ffff888078de9100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888078de9180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff888078de9200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff888078de9280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888078de9300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================