================================================================== BUG: KASAN: use-after-free in drm_gem_object_release_handle+0xa1/0xb0 drivers/gpu/drm/drm_gem.c:238 Read of size 8 at addr ffff888020a321e8 by task syz-executor.2/6423 CPU: 0 PID: 6423 Comm: syz-executor.2 Not tainted 6.0.0-rc5-syzkaller-00025-g3245cb65fd91 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/26/2022 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106 print_address_description mm/kasan/report.c:317 [inline] print_report.cold+0x2ba/0x6e9 mm/kasan/report.c:433 kasan_report+0xb1/0x1e0 mm/kasan/report.c:495 drm_gem_object_release_handle+0xa1/0xb0 drivers/gpu/drm/drm_gem.c:238 idr_for_each+0x113/0x220 lib/idr.c:208 drm_gem_release+0x22/0x30 drivers/gpu/drm/drm_gem.c:917 drm_file_free.part.0+0x805/0xb80 drivers/gpu/drm/drm_file.c:281 drm_file_free drivers/gpu/drm/drm_file.c:248 [inline] drm_close_helper.isra.0+0x17d/0x1f0 drivers/gpu/drm/drm_file.c:308 drm_release+0x1e6/0x530 drivers/gpu/drm/drm_file.c:495 __fput+0x277/0x9d0 fs/file_table.c:320 task_work_run+0xdd/0x1a0 kernel/task_work.c:177 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline] exit_to_user_mode_loop kernel/entry/common.c:169 [inline] exit_to_user_mode_prepare+0x23c/0x250 kernel/entry/common.c:201 __syscall_exit_to_user_mode_work kernel/entry/common.c:283 [inline] syscall_exit_to_user_mode+0x19/0x50 kernel/entry/common.c:294 do_syscall_64+0x42/0xb0 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7efebce3c04b Code: 0f 05 48 3d 00 f0 ff ff 77 45 c3 0f 1f 40 00 48 83 ec 18 89 7c 24 0c e8 63 fc ff ff 8b 7c 24 0c 41 89 c0 b8 03 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 35 44 89 c7 89 44 24 0c e8 a1 fc ff ff 8b 44 RSP: 002b:00007ffc17634d20 EFLAGS: 00000293 ORIG_RAX: 0000000000000003 RAX: 0000000000000000 RBX: 0000000000000004 RCX: 00007efebce3c04b RDX: 00007efebcfa08d0 RSI: ffffffffffffffff RDI: 0000000000000003 RBP: 00007efebcf9d980 R08: 0000000000000000 R09: 00007efebcfa08d8 R10: 00007ffc17634e20 R11: 0000000000000293 R12: 000000000006ad61 R13: 00007ffc17634e20 R14: 00007efebcf9bf80 R15: 0000000000000032 Allocated by task 6425: kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38 kasan_set_track mm/kasan/common.c:45 [inline] set_alloc_info mm/kasan/common.c:437 [inline] ____kasan_kmalloc mm/kasan/common.c:516 [inline] ____kasan_kmalloc mm/kasan/common.c:475 [inline] __kasan_kmalloc+0xa6/0xd0 mm/kasan/common.c:525 kasan_kmalloc include/linux/kasan.h:234 [inline] kmem_cache_alloc_trace+0x25a/0x460 mm/slab.c:3559 kmalloc include/linux/slab.h:600 [inline] kzalloc include/linux/slab.h:733 [inline] vgem_gem_create_object+0x38/0xb0 drivers/gpu/drm/vgem/vgem_drv.c:98 __drm_gem_shmem_create+0x80/0x480 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+0x13c/0x380 drivers/gpu/drm/drm_gem_shmem_helper.c:534 drm_mode_create_dumb+0x26c/0x2f0 drivers/gpu/drm/drm_dumb_buffers.c:96 drm_ioctl_kernel+0x27d/0x4e0 drivers/gpu/drm/drm_ioctl.c:782 drm_ioctl+0x51e/0x9d0 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 fs/ioctl.c:856 [inline] __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:856 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd Freed by task 6425: kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38 kasan_set_track+0x21/0x30 mm/kasan/common.c:45 kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:370 ____kasan_slab_free mm/kasan/common.c:367 [inline] ____kasan_slab_free+0x13d/0x1a0 mm/kasan/common.c:329 kasan_slab_free include/linux/kasan.h:200 [inline] __cache_free mm/slab.c:3418 [inline] kfree+0x173/0x390 mm/slab.c:3786 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+0x4fc/0x770 drivers/gpu/drm/drm_gem.c:1119 call_mmap include/linux/fs.h:2192 [inline] mmap_region+0xbff/0x1460 mm/mmap.c:1752 do_mmap+0x863/0xfa0 mm/mmap.c:1540 vm_mmap_pgoff+0x1ab/0x270 mm/util.c:552 ksys_mmap_pgoff+0x41b/0x5a0 mm/mmap.c:1586 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd The buggy address belongs to the object at ffff888020a32000 which belongs to the cache kmalloc-1k of size 1024 The buggy address is located 488 bytes inside of 1024-byte region [ffff888020a32000, ffff888020a32400) The buggy address belongs to the physical page: page:ffffea0000828c80 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x20a32 flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000000200 ffffea00005b6b88 ffffea0000930a48 ffff888011840700 raw: 0000000000000000 ffff888020a32000 0000000100000002 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 0x2c20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_THISNODE), pid 3604, tgid 3604 (syz-fuzzer), ts 118435809223, free_ts 116136445358 prep_new_page mm/page_alloc.c:2532 [inline] get_page_from_freelist+0x109b/0x2ce0 mm/page_alloc.c:4283 __alloc_pages+0x1c7/0x510 mm/page_alloc.c:5515 __alloc_pages_node include/linux/gfp.h:243 [inline] kmem_getpages mm/slab.c:1363 [inline] cache_grow_begin+0x75/0x360 mm/slab.c:2569 cache_alloc_refill+0x27f/0x380 mm/slab.c:2942 ____cache_alloc mm/slab.c:3018 [inline] ____cache_alloc mm/slab.c:3001 [inline] slab_alloc_node mm/slab.c:3220 [inline] kmem_cache_alloc_node_trace+0x50a/0x570 mm/slab.c:3601 __do_kmalloc_node mm/slab.c:3623 [inline] __kmalloc_node_track_caller+0x38/0x60 mm/slab.c:3638 kmalloc_reserve net/core/skbuff.c:362 [inline] __alloc_skb+0xd9/0x2f0 net/core/skbuff.c:434 alloc_skb_fclone include/linux/skbuff.h:1307 [inline] tcp_stream_alloc_skb+0x38/0x580 net/ipv4/tcp.c:861 tcp_sendmsg_locked+0xc36/0x2f80 net/ipv4/tcp.c:1325 tcp_sendmsg+0x2b/0x40 net/ipv4/tcp.c:1483 inet_sendmsg+0x99/0xe0 net/ipv4/af_inet.c:819 sock_sendmsg_nosec net/socket.c:714 [inline] sock_sendmsg+0xcf/0x120 net/socket.c:734 sock_write_iter+0x291/0x3d0 net/socket.c:1108 call_write_iter include/linux/fs.h:2187 [inline] new_sync_write fs/read_write.c:491 [inline] vfs_write+0x9e9/0xdd0 fs/read_write.c:578 ksys_write+0x1e8/0x250 fs/read_write.c:631 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 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+0x5e4/0xd20 mm/page_alloc.c:1499 free_unref_page_prepare mm/page_alloc.c:3380 [inline] free_unref_page+0x19/0x4d0 mm/page_alloc.c:3476 slab_destroy mm/slab.c:1615 [inline] slabs_destroy+0x89/0xc0 mm/slab.c:1635 cache_flusharray mm/slab.c:3389 [inline] ___cache_free+0x2a8/0x3d0 mm/slab.c:3452 qlink_free mm/kasan/quarantine.c:168 [inline] qlist_free_all+0x4f/0x1b0 mm/kasan/quarantine.c:187 kasan_quarantine_reduce+0x180/0x200 mm/kasan/quarantine.c:294 __kasan_slab_alloc+0x97/0xb0 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/slab.c:3232 [inline] kmem_cache_alloc_node+0x2f1/0x560 mm/slab.c:3583 __alloc_skb+0x210/0x2f0 net/core/skbuff.c:422 alloc_skb_fclone include/linux/skbuff.h:1307 [inline] tcp_stream_alloc_skb+0x38/0x580 net/ipv4/tcp.c:861 tcp_sendmsg_locked+0xc36/0x2f80 net/ipv4/tcp.c:1325 tcp_sendmsg+0x2b/0x40 net/ipv4/tcp.c:1483 inet_sendmsg+0x99/0xe0 net/ipv4/af_inet.c:819 sock_sendmsg_nosec net/socket.c:714 [inline] sock_sendmsg+0xcf/0x120 net/socket.c:734 sock_write_iter+0x291/0x3d0 net/socket.c:1108 call_write_iter include/linux/fs.h:2187 [inline] new_sync_write fs/read_write.c:491 [inline] vfs_write+0x9e9/0xdd0 fs/read_write.c:578 Memory state around the buggy address: ffff888020a32080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888020a32100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff888020a32180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff888020a32200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888020a32280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================