* [syzbot] [dri?] KASAN: slab-use-after-free Read in drm_gem_object_release_handle
@ 2026-04-13 17:16 syzbot
2026-04-14 0:16 ` Forwarded: [PATCH] drm/gem: fix use-after-free in drm_gem_release syzbot
` (7 more replies)
0 siblings, 8 replies; 16+ messages in thread
From: syzbot @ 2026-04-13 17:16 UTC (permalink / raw)
To: airlied, dri-devel, linux-kernel, maarten.lankhorst, mripard,
simona, syzkaller-bugs, tzimmermann
Hello,
syzbot found the following issue on:
HEAD commit: f5459048c38a Merge tag 'i2c-for-7.0-final' of git://git.ke..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=1028d106580000
kernel config: https://syzkaller.appspot.com/x/.config?x=6754c86e8d9e4c91
dashboard link: https://syzkaller.appspot.com/bug?extid=b2e951687503f32f74ce
compiler: Debian clang version 21.1.8 (++20251221033036+2078da43e25a-1~exp1~20251221153213.50), Debian LLD 21.1.8
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1428d106580000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=17509036580000
Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/530844b89fdc/disk-f5459048.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/551ba51d047c/vmlinux-f5459048.xz
kernel image: https://storage.googleapis.com/syzbot-assets/9e6a44490566/bzImage-f5459048.xz
IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+b2e951687503f32f74ce@syzkaller.appspotmail.com
==================================================================
BUG: KASAN: slab-use-after-free in drm_gem_object_release_handle+0x4b/0x1e0 drivers/gpu/drm/drm_gem.c:374
Read of size 8 at addr ffff88806c6ffa88 by task syz.1.18/6089
CPU: 1 UID: 0 PID: 6089 Comm: syz.1.18 Not tainted syzkaller #0 PREEMPT(full)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/18/2026
Call Trace:
<TASK>
dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120
print_address_description mm/kasan/report.c:378 [inline]
print_report+0xba/0x230 mm/kasan/report.c:482
kasan_report+0x117/0x150 mm/kasan/report.c:595
drm_gem_object_release_handle+0x4b/0x1e0 drivers/gpu/drm/drm_gem.c:374
idr_for_each+0x1c6/0x2a0 lib/idr.c:210
drm_gem_release+0x28/0x40 drivers/gpu/drm/drm_gem.c:1088
drm_file_free+0x729/0xa00 drivers/gpu/drm/drm_file.c:261
drm_close_helper drivers/gpu/drm/drm_file.c:290 [inline]
drm_release+0x2de/0x3f0 drivers/gpu/drm/drm_file.c:438
__fput+0x44f/0xa70 fs/file_table.c:469
task_work_run+0x1d9/0x270 kernel/task_work.c:233
resume_user_mode_work include/linux/resume_user_mode.h:50 [inline]
__exit_to_user_mode_loop kernel/entry/common.c:67 [inline]
exit_to_user_mode_loop+0xed/0x480 kernel/entry/common.c:98
__exit_to_user_mode_prepare include/linux/irq-entry-common.h:226 [inline]
syscall_exit_to_user_mode_prepare include/linux/irq-entry-common.h:256 [inline]
syscall_exit_to_user_mode include/linux/entry-common.h:325 [inline]
do_syscall_64+0x32d/0xf80 arch/x86/entry/syscall_64.c:100
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7efc3279c819
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:00007ffc28821858 EFLAGS: 00000246 ORIG_RAX: 00000000000001b4
RAX: 0000000000000000 RBX: 00007ffc28821940 RCX: 00007efc3279c819
RDX: 0000000000000000 RSI: 000000000000001e RDI: 0000000000000003
RBP: 000000000001956f R08: 0000000000000001 R09: 0000000000000000
R10: 0000001b2f520000 R11: 0000000000000246 R12: 00007ffc28821980
R13: 00007efc32a1609c R14: 00000000000195b1 R15: 00007efc32a16090
</TASK>
Allocated by task 6090:
kasan_save_stack mm/kasan/common.c:57 [inline]
kasan_save_track+0x3e/0x80 mm/kasan/common.c:78
poison_kmalloc_redzone mm/kasan/common.c:398 [inline]
__kasan_kmalloc+0x93/0xb0 mm/kasan/common.c:415
kasan_kmalloc include/linux/kasan.h:263 [inline]
__kmalloc_cache_noprof+0x31c/0x660 mm/slub.c:5380
kmalloc_noprof include/linux/slab.h:950 [inline]
kzalloc_noprof include/linux/slab.h:1188 [inline]
__drm_gem_shmem_create+0xc4/0x2e0 drivers/gpu/drm/drm_gem_shmem_helper.c:130
drm_gem_shmem_create drivers/gpu/drm/drm_gem_shmem_helper.c:157 [inline]
drm_gem_shmem_create_with_handle drivers/gpu/drm/drm_gem_shmem_helper.c:460 [inline]
drm_gem_shmem_dumb_create+0x72/0x120 drivers/gpu/drm/drm_gem_shmem_helper.c:549
drm_mode_create_dumb drivers/gpu/drm/drm_dumb_buffers.c:227 [inline]
drm_mode_create_dumb_ioctl+0x2bd/0x340 drivers/gpu/drm/drm_dumb_buffers.c:236
drm_ioctl_kernel+0x2df/0x3b0 drivers/gpu/drm/drm_ioctl.c:804
drm_ioctl+0x6ba/0xb80 drivers/gpu/drm/drm_ioctl.c:901
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:597 [inline]
__se_sys_ioctl+0xfc/0x170 fs/ioctl.c:583
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x14d/0xf80 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Freed by task 6093:
kasan_save_stack mm/kasan/common.c:57 [inline]
kasan_save_track+0x3e/0x80 mm/kasan/common.c:78
kasan_save_free_info+0x46/0x50 mm/kasan/generic.c:584
poison_slab_object mm/kasan/common.c:253 [inline]
__kasan_slab_free+0x5c/0x80 mm/kasan/common.c:285
kasan_slab_free include/linux/kasan.h:235 [inline]
slab_free_hook mm/slub.c:2685 [inline]
slab_free mm/slub.c:6165 [inline]
kfree+0x1c1/0x630 mm/slub.c:6483
drm_gem_object_release_handle+0xc2/0x1e0 drivers/gpu/drm/drm_gem.c:385
drm_gem_handle_delete+0x7b/0xb0 drivers/gpu/drm/drm_gem.c:413
drm_ioctl_kernel+0x2df/0x3b0 drivers/gpu/drm/drm_ioctl.c:804
drm_ioctl+0x6ba/0xb80 drivers/gpu/drm/drm_ioctl.c:901
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:597 [inline]
__se_sys_ioctl+0xfc/0x170 fs/ioctl.c:583
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x14d/0xf80 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
The buggy address belongs to the object at ffff88806c6ff800
which belongs to the cache kmalloc-1k of size 1024
The buggy address is located 648 bytes inside of
freed 1024-byte region [ffff88806c6ff800, ffff88806c6ffc00)
The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x6c6f8
head: order:3 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0xfff00000000040(head|node=0|zone=1|lastcpupid=0x7ff)
page_type: f5(slab)
raw: 00fff00000000040 ffff88813fea6dc0 dead000000000100 dead000000000122
raw: 0000000000000000 0000000800100010 00000000f5000000 0000000000000000
head: 00fff00000000040 ffff88813fea6dc0 dead000000000100 dead000000000122
head: 0000000000000000 0000000800100010 00000000f5000000 0000000000000000
head: 00fff00000000003 ffffea0001b1be01 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 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 5954, tgid 5954 (syz-executor), ts 103695420380, free_ts 92416780237
set_page_owner include/linux/page_owner.h:32 [inline]
post_alloc_hook+0x231/0x280 mm/page_alloc.c:1889
prep_new_page mm/page_alloc.c:1897 [inline]
get_page_from_freelist+0x24dc/0x2580 mm/page_alloc.c:3962
__alloc_frozen_pages_noprof+0x18d/0x380 mm/page_alloc.c:5250
alloc_slab_page mm/slub.c:3292 [inline]
allocate_slab+0x77/0x660 mm/slub.c:3481
new_slab mm/slub.c:3539 [inline]
refill_objects+0x331/0x3c0 mm/slub.c:7175
refill_sheaf mm/slub.c:2812 [inline]
__pcs_replace_empty_main+0x2e6/0x730 mm/slub.c:4615
alloc_from_pcs mm/slub.c:4717 [inline]
slab_alloc_node mm/slub.c:4851 [inline]
__do_kmalloc_node mm/slub.c:5259 [inline]
__kmalloc_node_noprof+0x577/0x7c0 mm/slub.c:5266
kmalloc_node_noprof include/linux/slab.h:1081 [inline]
qdisc_alloc+0x92/0x9e0 net/sched/sch_generic.c:951
qdisc_create_dflt+0x8e/0x510 net/sched/sch_generic.c:1006
attach_one_default_qdisc net/sched/sch_generic.c:1172 [inline]
netdev_for_each_tx_queue include/linux/netdevice.h:2684 [inline]
attach_default_qdiscs net/sched/sch_generic.c:1190 [inline]
dev_activate+0x378/0x1150 net/sched/sch_generic.c:1249
__dev_open+0x67a/0x830 net/core/dev.c:1711
__dev_change_flags+0x1f7/0x690 net/core/dev.c:9781
netif_change_flags+0x88/0x1a0 net/core/dev.c:9844
do_setlink+0xf82/0x4590 net/core/rtnetlink.c:3180
rtnl_changelink net/core/rtnetlink.c:3798 [inline]
__rtnl_newlink net/core/rtnetlink.c:3971 [inline]
rtnl_newlink+0x15ad/0x1bb0 net/core/rtnetlink.c:4108
rtnetlink_rcv_msg+0x7d5/0xbe0 net/core/rtnetlink.c:6994
page last free pid 5854 tgid 5854 stack trace:
reset_page_owner include/linux/page_owner.h:25 [inline]
__free_pages_prepare mm/page_alloc.c:1433 [inline]
__free_frozen_pages+0xc2b/0xdb0 mm/page_alloc.c:2978
vfree+0x25a/0x400 mm/vmalloc.c:3479
kcov_put kernel/kcov.c:442 [inline]
kcov_close+0x28/0x50 kernel/kcov.c:543
__fput+0x44f/0xa70 fs/file_table.c:469
task_work_run+0x1d9/0x270 kernel/task_work.c:233
exit_task_work include/linux/task_work.h:40 [inline]
do_exit+0x70f/0x23c0 kernel/exit.c:976
do_group_exit+0x21b/0x2d0 kernel/exit.c:1118
get_signal+0x1284/0x1330 kernel/signal.c:3034
arch_do_signal_or_restart+0xbc/0x830 arch/x86/kernel/signal.c:337
__exit_to_user_mode_loop kernel/entry/common.c:64 [inline]
exit_to_user_mode_loop+0x86/0x480 kernel/entry/common.c:98
__exit_to_user_mode_prepare include/linux/irq-entry-common.h:226 [inline]
syscall_exit_to_user_mode_prepare include/linux/irq-entry-common.h:256 [inline]
syscall_exit_to_user_mode include/linux/entry-common.h:325 [inline]
do_syscall_64+0x32d/0xf80 arch/x86/entry/syscall_64.c:100
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Memory state around the buggy address:
ffff88806c6ff980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88806c6ffa00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88806c6ffa80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88806c6ffb00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88806c6ffb80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@googlegroups.com.
syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title
If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.
If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)
If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report
If you want to undo deduplication, reply with:
#syz undup
^ permalink raw reply [flat|nested] 16+ messages in thread
* Forwarded: [PATCH] drm/gem: fix use-after-free in drm_gem_release
2026-04-13 17:16 [syzbot] [dri?] KASAN: slab-use-after-free Read in drm_gem_object_release_handle syzbot
@ 2026-04-14 0:16 ` syzbot
2026-04-14 1:32 ` syzbot
` (6 subsequent siblings)
7 siblings, 0 replies; 16+ messages in thread
From: syzbot @ 2026-04-14 0:16 UTC (permalink / raw)
To: linux-kernel, syzkaller-bugs
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.
***
Subject: [PATCH] drm/gem: fix use-after-free in drm_gem_release
Author: kartikey406@gmail.com
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
drm_gem_release() calls idr_for_each() with
drm_gem_object_release_handle() as callback. A concurrent
drm_gem_handle_delete() can free the GEM object between the time
idr_for_each() reads the pointer and drm_gem_object_release_handle()
uses it, causing a use-after-free.
Fix this by splitting the operation into two phases:
1. Under table_lock, walk the IDR using a new collect callback that
only increments each object's reference count and adds it to a
local list. Only atomic operations are performed here so holding
a spinlock is safe.
2. Outside the lock, iterate the local list and call
drm_gem_object_release_handle() on each object safely. Drop our
reference afterwards and destroy the IDR only after all objects
have been properly released.
Holding a reference during phase 1 ensures that a concurrent
drm_gem_handle_delete() cannot free any object while we are still
using it.
Reported-by: syzbot+b2e951687503f32f74ce@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=b2e951687503f32f74ce
Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
---
drivers/gpu/drm/drm_gem.c | 39 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 38 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index 891c3bff5ae0..ee9939356de4 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -1073,6 +1073,30 @@ drm_gem_open(struct drm_device *dev, struct drm_file *file_private)
spin_lock_init(&file_private->table_lock);
}
+struct drm_gem_object_entry {
+ struct drm_gem_object *obj;
+ struct list_head head;
+};
+
+static int drm_gem_object_collect(int id, void *ptr, void *data)
+{
+ struct drm_gem_object_entry *entry;
+ struct drm_gem_object *obj = ptr;
+ struct list_head *list = data;
+
+ if (!obj)
+ return 0;
+
+ entry = kmalloc_obj(*entry, GFP_ATOMIC);
+ if (!entry)
+ return -ENOMEM;
+
+ drm_gem_object_get(obj);
+ entry->obj = obj;
+ list_add(&entry->head, list);
+ return 0;
+}
+
/**
* drm_gem_release - release file-private GEM resources
* @dev: drm_device which is being closed by userspace
@@ -1085,8 +1109,21 @@ drm_gem_open(struct drm_device *dev, struct drm_file *file_private)
void
drm_gem_release(struct drm_device *dev, struct drm_file *file_private)
{
+ struct drm_gem_object_entry *entry, *tmp;
+ LIST_HEAD(list);
+
+ spin_lock(&file_private->table_lock);
idr_for_each(&file_private->object_idr,
- &drm_gem_object_release_handle, file_private);
+ &drm_gem_object_collect, &list);
+ spin_unlock(&file_private->table_lock);
+
+ list_for_each_entry_safe(entry, tmp, &list, head) {
+ list_del(&entry->head);
+ drm_gem_object_release_handle(0, entry->obj, file_private);
+ drm_gem_object_put(entry->obj);
+ kfree(entry);
+ }
+
idr_destroy(&file_private->object_idr);
}
--
2.43.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [syzbot] [dri?] KASAN: slab-use-after-free Read in drm_gem_object_release_handle
[not found] <20260414001626.60471-1-kartikey406@gmail.com>
@ 2026-04-14 0:36 ` syzbot
0 siblings, 0 replies; 16+ messages in thread
From: syzbot @ 2026-04-14 0:36 UTC (permalink / raw)
To: kartikey406, linux-kernel, syzkaller-bugs
Hello,
syzbot has tested the proposed patch but the reproducer is still triggering an issue:
KASAN: slab-use-after-free Write in drm_gem_object_collect
==================================================================
BUG: KASAN: slab-use-after-free in instrument_atomic_read_write include/linux/instrumented.h:112 [inline]
BUG: KASAN: slab-use-after-free in atomic_fetch_add_relaxed include/linux/atomic/atomic-instrumented.h:252 [inline]
BUG: KASAN: slab-use-after-free in __refcount_add include/linux/refcount.h:283 [inline]
BUG: KASAN: slab-use-after-free in __refcount_inc include/linux/refcount.h:366 [inline]
BUG: KASAN: slab-use-after-free in refcount_inc include/linux/refcount.h:383 [inline]
BUG: KASAN: slab-use-after-free in kref_get include/linux/kref.h:45 [inline]
BUG: KASAN: slab-use-after-free in drm_gem_object_get include/drm/drm_gem.h:558 [inline]
BUG: KASAN: slab-use-after-free in drm_gem_object_collect+0x79/0x1d0 drivers/gpu/drm/drm_gem.c:1094
Write of size 4 at addr ffff88802be56000 by task syz.1.58/6660
CPU: 1 UID: 0 PID: 6660 Comm: syz.1.58 Not tainted syzkaller #0 PREEMPT(full)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/18/2026
Call Trace:
<TASK>
dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120
print_address_description mm/kasan/report.c:378 [inline]
print_report+0xba/0x230 mm/kasan/report.c:482
kasan_report+0x117/0x150 mm/kasan/report.c:595
check_region_inline mm/kasan/generic.c:-1 [inline]
kasan_check_range+0x264/0x2c0 mm/kasan/generic.c:200
instrument_atomic_read_write include/linux/instrumented.h:112 [inline]
atomic_fetch_add_relaxed include/linux/atomic/atomic-instrumented.h:252 [inline]
__refcount_add include/linux/refcount.h:283 [inline]
__refcount_inc include/linux/refcount.h:366 [inline]
refcount_inc include/linux/refcount.h:383 [inline]
kref_get include/linux/kref.h:45 [inline]
drm_gem_object_get include/drm/drm_gem.h:558 [inline]
drm_gem_object_collect+0x79/0x1d0 drivers/gpu/drm/drm_gem.c:1094
idr_for_each+0x1c6/0x2a0 lib/idr.c:210
drm_gem_release+0xe9/0x3c0 drivers/gpu/drm/drm_gem.c:1116
drm_file_free+0x729/0xa00 drivers/gpu/drm/drm_file.c:261
drm_close_helper drivers/gpu/drm/drm_file.c:290 [inline]
drm_release+0x2de/0x3f0 drivers/gpu/drm/drm_file.c:438
__fput+0x44f/0xa60 fs/file_table.c:510
task_work_run+0x1d9/0x270 kernel/task_work.c:233
resume_user_mode_work include/linux/resume_user_mode.h:50 [inline]
__exit_to_user_mode_loop kernel/entry/common.c:67 [inline]
exit_to_user_mode_loop+0xed/0x480 kernel/entry/common.c:98
__exit_to_user_mode_prepare include/linux/irq-entry-common.h:226 [inline]
syscall_exit_to_user_mode_prepare include/linux/irq-entry-common.h:256 [inline]
syscall_exit_to_user_mode include/linux/entry-common.h:325 [inline]
do_syscall_64+0x32d/0xf80 arch/x86/entry/syscall_64.c:100
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f805839c819
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:00007ffc11639678 EFLAGS: 00000246 ORIG_RAX: 00000000000001b4
RAX: 0000000000000000 RBX: 00007ffc11639760 RCX: 00007f805839c819
RDX: 0000000000000000 RSI: 000000000000001e RDI: 0000000000000003
RBP: 000000000001e823 R08: 0000000000000001 R09: 0000000000000000
R10: 0000001b30420000 R11: 0000000000000246 R12: 00007ffc116397a0
R13: 00007f805861609c R14: 000000000001e864 R15: 00007f8058616090
</TASK>
Allocated by task 6663:
kasan_save_stack mm/kasan/common.c:57 [inline]
kasan_save_track+0x3e/0x80 mm/kasan/common.c:78
poison_kmalloc_redzone mm/kasan/common.c:398 [inline]
__kasan_kmalloc+0x93/0xb0 mm/kasan/common.c:415
kasan_kmalloc include/linux/kasan.h:263 [inline]
__kmalloc_cache_noprof+0x31c/0x660 mm/slub.c:5380
kmalloc_noprof include/linux/slab.h:950 [inline]
kzalloc_noprof include/linux/slab.h:1188 [inline]
__drm_gem_shmem_create+0xc4/0x2e0 drivers/gpu/drm/drm_gem_shmem_helper.c:130
drm_gem_shmem_create drivers/gpu/drm/drm_gem_shmem_helper.c:157 [inline]
drm_gem_shmem_create_with_handle drivers/gpu/drm/drm_gem_shmem_helper.c:460 [inline]
drm_gem_shmem_dumb_create+0x72/0x120 drivers/gpu/drm/drm_gem_shmem_helper.c:549
drm_mode_create_dumb drivers/gpu/drm/drm_dumb_buffers.c:227 [inline]
drm_mode_create_dumb_ioctl+0x2bd/0x340 drivers/gpu/drm/drm_dumb_buffers.c:236
drm_ioctl_kernel+0x2df/0x3b0 drivers/gpu/drm/drm_ioctl.c:804
drm_ioctl+0x6ba/0xb80 drivers/gpu/drm/drm_ioctl.c:901
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:597 [inline]
__se_sys_ioctl+0xfc/0x170 fs/ioctl.c:583
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x14d/0xf80 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Freed by task 6664:
kasan_save_stack mm/kasan/common.c:57 [inline]
kasan_save_track+0x3e/0x80 mm/kasan/common.c:78
kasan_save_free_info+0x46/0x50 mm/kasan/generic.c:584
poison_slab_object mm/kasan/common.c:253 [inline]
__kasan_slab_free+0x5c/0x80 mm/kasan/common.c:285
kasan_slab_free include/linux/kasan.h:235 [inline]
slab_free_hook mm/slub.c:2685 [inline]
slab_free mm/slub.c:6165 [inline]
kfree+0x1c1/0x630 mm/slub.c:6483
drm_gem_handle_delete+0x7b/0xb0 drivers/gpu/drm/drm_gem.c:413
drm_ioctl_kernel+0x2df/0x3b0 drivers/gpu/drm/drm_ioctl.c:804
drm_ioctl+0x6ba/0xb80 drivers/gpu/drm/drm_ioctl.c:901
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:597 [inline]
__se_sys_ioctl+0xfc/0x170 fs/ioctl.c:583
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x14d/0xf80 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
The buggy address belongs to the object at ffff88802be56000
which belongs to the cache kmalloc-1k of size 1024
The buggy address is located 0 bytes inside of
freed 1024-byte region [ffff88802be56000, ffff88802be56400)
The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x2be50
head: order:3 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0xfff00000000040(head|node=0|zone=1|lastcpupid=0x7ff)
page_type: f5(slab)
raw: 00fff00000000040 ffff88813fea7dc0 dead000000000100 dead000000000122
raw: 0000000000000000 0000000800100010 00000000f5000000 0000000000000000
head: 00fff00000000040 ffff88813fea7dc0 dead000000000100 dead000000000122
head: 0000000000000000 0000000800100010 00000000f5000000 0000000000000000
head: 00fff00000000003 ffffea0000af9401 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 0xd2820(GFP_ATOMIC|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 5933, tgid 5933 (syz-executor), ts 79731270511, free_ts 79726565820
set_page_owner include/linux/page_owner.h:32 [inline]
post_alloc_hook+0x231/0x280 mm/page_alloc.c:1889
prep_new_page mm/page_alloc.c:1897 [inline]
get_page_from_freelist+0x24dc/0x2580 mm/page_alloc.c:3962
__alloc_frozen_pages_noprof+0x18d/0x380 mm/page_alloc.c:5250
alloc_slab_page mm/slub.c:3292 [inline]
allocate_slab+0x77/0x660 mm/slub.c:3481
new_slab mm/slub.c:3539 [inline]
refill_objects+0x331/0x3c0 mm/slub.c:7175
refill_sheaf mm/slub.c:2812 [inline]
__pcs_replace_empty_main+0x2e6/0x730 mm/slub.c:4615
alloc_from_pcs mm/slub.c:4717 [inline]
slab_alloc_node mm/slub.c:4851 [inline]
__kmalloc_cache_noprof+0x392/0x660 mm/slub.c:5375
kmalloc_noprof include/linux/slab.h:950 [inline]
kzalloc_noprof include/linux/slab.h:1188 [inline]
batadv_hardif_add_interface net/batman-adv/hard-interface.c:874 [inline]
batadv_hard_if_event+0xe7a/0x1700 net/batman-adv/hard-interface.c:958
notifier_call_chain+0x1be/0x400 kernel/notifier.c:85
call_netdevice_notifiers_extack net/core/dev.c:2287 [inline]
call_netdevice_notifiers net/core/dev.c:2301 [inline]
register_netdevice+0x173a/0x1cf0 net/core/dev.c:11479
team_newlink+0x120/0x170 drivers/net/team/team_core.c:2226
rtnl_newlink_create+0x329/0xb70 net/core/rtnetlink.c:3862
__rtnl_newlink net/core/rtnetlink.c:3993 [inline]
rtnl_newlink+0x166a/0x1bb0 net/core/rtnetlink.c:4108
rtnetlink_rcv_msg+0x7d5/0xbe0 net/core/rtnetlink.c:6994
netlink_rcv_skb+0x232/0x4b0 net/netlink/af_netlink.c:2550
netlink_unicast_kernel net/netlink/af_netlink.c:1318 [inline]
netlink_unicast+0x80f/0x9b0 net/netlink/af_netlink.c:1344
page last free pid 5933 tgid 5933 stack trace:
reset_page_owner include/linux/page_owner.h:25 [inline]
__free_pages_prepare mm/page_alloc.c:1433 [inline]
__free_frozen_pages+0xc2b/0xdb0 mm/page_alloc.c:2978
__slab_free+0x263/0x2b0 mm/slub.c:5573
qlink_free mm/kasan/quarantine.c:163 [inline]
qlist_free_all+0x97/0x100 mm/kasan/quarantine.c:179
kasan_quarantine_reduce+0x148/0x160 mm/kasan/quarantine.c:286
__kasan_slab_alloc+0x22/0x80 mm/kasan/common.c:350
kasan_slab_alloc include/linux/kasan.h:253 [inline]
slab_post_alloc_hook mm/slub.c:4538 [inline]
slab_alloc_node mm/slub.c:4866 [inline]
__kmalloc_cache_noprof+0x2ba/0x660 mm/slub.c:5375
kmalloc_noprof include/linux/slab.h:950 [inline]
kzalloc_noprof include/linux/slab.h:1188 [inline]
ref_tracker_alloc+0x15a/0x4c0 lib/ref_tracker.c:270
__netdev_tracker_alloc include/linux/netdevice.h:4436 [inline]
netdev_hold include/linux/netdevice.h:4465 [inline]
netdev_queue_add_kobject net/core/net-sysfs.c:1994 [inline]
netdev_queue_update_kobjects+0x1d1/0x6c0 net/core/net-sysfs.c:2056
register_queue_kobjects net/core/net-sysfs.c:2119 [inline]
netdev_register_kobject+0x258/0x310 net/core/net-sysfs.c:2362
register_netdevice+0x12c0/0x1cf0 net/core/dev.c:11441
bond_newlink+0x48/0xd0 drivers/net/bonding/bond_netlink.c:601
rtnl_newlink_create+0x329/0xb70 net/core/rtnetlink.c:3862
__rtnl_newlink net/core/rtnetlink.c:3993 [inline]
rtnl_newlink+0x166a/0x1bb0 net/core/rtnetlink.c:4108
rtnetlink_rcv_msg+0x7d5/0xbe0 net/core/rtnetlink.c:6994
netlink_rcv_skb+0x232/0x4b0 net/netlink/af_netlink.c:2550
netlink_unicast_kernel net/netlink/af_netlink.c:1318 [inline]
netlink_unicast+0x80f/0x9b0 net/netlink/af_netlink.c:1344
Memory state around the buggy address:
ffff88802be55f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff88802be55f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88802be56000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88802be56080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88802be56100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
Tested on:
commit: b8f82cb0 Merge tag 'landlock-7.1-rc1' of git://git.ker..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=15003b02580000
kernel config: https://syzkaller.appspot.com/x/.config?x=6c5ea45f4cdebd8e
dashboard link: https://syzkaller.appspot.com/bug?extid=b2e951687503f32f74ce
compiler: Debian clang version 21.1.8 (++20251221033036+2078da43e25a-1~exp1~20251221153213.50), Debian LLD 21.1.8
patch: https://syzkaller.appspot.com/x/patch.diff?x=10413cd2580000
^ permalink raw reply [flat|nested] 16+ messages in thread
* Forwarded: [PATCH] drm/gem: fix use-after-free in drm_gem_release
2026-04-13 17:16 [syzbot] [dri?] KASAN: slab-use-after-free Read in drm_gem_object_release_handle syzbot
2026-04-14 0:16 ` Forwarded: [PATCH] drm/gem: fix use-after-free in drm_gem_release syzbot
@ 2026-04-14 1:32 ` syzbot
2026-04-14 5:00 ` [syzbot] [dri?] KASAN: slab-use-after-free Read in drm_gem_object_release_handle Hillf Danton
` (5 subsequent siblings)
7 siblings, 0 replies; 16+ messages in thread
From: syzbot @ 2026-04-14 1:32 UTC (permalink / raw)
To: linux-kernel, syzkaller-bugs
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.
***
Subject: [PATCH] drm/gem: fix use-after-free in drm_gem_release
Author: kartikey406@gmail.com
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
KASAN reported a use-after-free in drm_gem_object_release_handle
when drm_gem_release() races with drm_gem_handle_delete().
drm_gem_release() calls idr_for_each() which gives out object
pointers, but a concurrent drm_gem_handle_delete() can free the
object before drm_gem_object_release_handle() gets to use it.
Fix this by splitting the operation into two phases:
Phase 1: Walk the IDR under table_lock. For each object, atomically
replace its IDR slot with NULL using idr_replace() so that a
concurrent drm_gem_handle_delete() sees NULL and bails out with
-EINVAL. Grab a reference on the object and collect it into a local
list. Only atomic operations are performed here so holding a
spinlock is safe.
Phase 2: Outside the lock, iterate the local list and call
drm_gem_object_release_handle() on each object safely. Drop our
reference afterwards. Destroy the IDR only after all objects have
been properly released.
The idr_replace(NULL) in phase 1 is the key: it mirrors what
drm_gem_handle_delete() itself does to atomically claim ownership
of an object, ensuring that each object is processed by exactly
one path.
Reported-by: syzbot+b2e951687503f32f74ce@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=b2e951687503f32f74ce
Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
---
drivers/gpu/drm/drm_gem.c | 49 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 48 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index 891c3bff5ae0..9ec1f03c6383 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -1073,6 +1073,37 @@ drm_gem_open(struct drm_device *dev, struct drm_file *file_private)
spin_lock_init(&file_private->table_lock);
}
+struct drm_gem_object_entry {
+ struct drm_gem_object *obj;
+ struct list_head head;
+};
+
+struct drm_gem_collect_data {
+ struct drm_file *file_priv;
+ struct list_head list;
+};
+
+static int drm_gem_object_collect(int id, void *ptr, void *data)
+{
+ struct drm_gem_collect_data *cd = data;
+ struct drm_gem_object_entry *entry;
+ struct drm_gem_object *obj;
+
+ /* Atomically claim the slot → handle_delete sees NULL, bails */
+ obj = idr_replace(&cd->file_priv->object_idr, NULL, id);
+ if (IS_ERR_OR_NULL(obj))
+ return 0;
+
+ entry = kmalloc(sizeof(*entry), GFP_ATOMIC);
+ if (!entry)
+ return -ENOMEM;
+
+ drm_gem_object_get(obj);
+ entry->obj = obj;
+ list_add(&entry->head, &cd->list);
+ return 0;
+}
+
/**
* drm_gem_release - release file-private GEM resources
* @dev: drm_device which is being closed by userspace
@@ -1085,8 +1116,24 @@ drm_gem_open(struct drm_device *dev, struct drm_file *file_private)
void
drm_gem_release(struct drm_device *dev, struct drm_file *file_private)
{
+ struct drm_gem_object_entry *entry, *tmp;
+ struct drm_gem_collect_data cd = {
+ .file_priv = file_private,
+ };
+ INIT_LIST_HEAD(&cd.list);
+
+ spin_lock(&file_private->table_lock);
idr_for_each(&file_private->object_idr,
- &drm_gem_object_release_handle, file_private);
+ &drm_gem_object_collect, &cd);
+ spin_unlock(&file_private->table_lock);
+
+ list_for_each_entry_safe(entry, tmp, &cd.list, head) {
+ list_del(&entry->head);
+ drm_gem_object_release_handle(0, entry->obj, file_private);
+ drm_gem_object_put(entry->obj);
+ kfree(entry);
+ }
+
idr_destroy(&file_private->object_idr);
}
--
2.43.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [syzbot] [dri?] KASAN: slab-use-after-free Read in drm_gem_object_release_handle
[not found] <20260414013225.64095-1-kartikey406@gmail.com>
@ 2026-04-14 1:50 ` syzbot
0 siblings, 0 replies; 16+ messages in thread
From: syzbot @ 2026-04-14 1:50 UTC (permalink / raw)
To: kartikey406, linux-kernel, syzkaller-bugs
Hello,
syzbot has tested the proposed patch but the reproducer is still triggering an issue:
KASAN: slab-use-after-free Write in drm_gem_object_collect
==================================================================
BUG: KASAN: slab-use-after-free in instrument_atomic_read_write include/linux/instrumented.h:112 [inline]
BUG: KASAN: slab-use-after-free in atomic_fetch_add_relaxed include/linux/atomic/atomic-instrumented.h:252 [inline]
BUG: KASAN: slab-use-after-free in __refcount_add include/linux/refcount.h:283 [inline]
BUG: KASAN: slab-use-after-free in __refcount_inc include/linux/refcount.h:366 [inline]
BUG: KASAN: slab-use-after-free in refcount_inc include/linux/refcount.h:383 [inline]
BUG: KASAN: slab-use-after-free in kref_get include/linux/kref.h:45 [inline]
BUG: KASAN: slab-use-after-free in drm_gem_object_get include/drm/drm_gem.h:558 [inline]
BUG: KASAN: slab-use-after-free in drm_gem_object_collect+0xbb/0x210 drivers/gpu/drm/drm_gem.c:1101
Write of size 4 at addr ffff88805fd7c000 by task syz.3.278/7348
CPU: 0 UID: 0 PID: 7348 Comm: syz.3.278 Not tainted syzkaller #0 PREEMPT(full)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/18/2026
Call Trace:
<TASK>
dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120
print_address_description mm/kasan/report.c:378 [inline]
print_report+0xba/0x230 mm/kasan/report.c:482
kasan_report+0x117/0x150 mm/kasan/report.c:595
check_region_inline mm/kasan/generic.c:-1 [inline]
kasan_check_range+0x264/0x2c0 mm/kasan/generic.c:200
instrument_atomic_read_write include/linux/instrumented.h:112 [inline]
atomic_fetch_add_relaxed include/linux/atomic/atomic-instrumented.h:252 [inline]
__refcount_add include/linux/refcount.h:283 [inline]
__refcount_inc include/linux/refcount.h:366 [inline]
refcount_inc include/linux/refcount.h:383 [inline]
kref_get include/linux/kref.h:45 [inline]
drm_gem_object_get include/drm/drm_gem.h:558 [inline]
drm_gem_object_collect+0xbb/0x210 drivers/gpu/drm/drm_gem.c:1101
idr_for_each+0x1c6/0x2a0 lib/idr.c:210
drm_gem_release+0x103/0x3f0 drivers/gpu/drm/drm_gem.c:1126
drm_file_free+0x729/0xa00 drivers/gpu/drm/drm_file.c:261
drm_close_helper drivers/gpu/drm/drm_file.c:290 [inline]
drm_release+0x2de/0x3f0 drivers/gpu/drm/drm_file.c:438
__fput+0x44f/0xa60 fs/file_table.c:510
task_work_run+0x1d9/0x270 kernel/task_work.c:233
resume_user_mode_work include/linux/resume_user_mode.h:50 [inline]
__exit_to_user_mode_loop kernel/entry/common.c:67 [inline]
exit_to_user_mode_loop+0xed/0x480 kernel/entry/common.c:98
__exit_to_user_mode_prepare include/linux/irq-entry-common.h:226 [inline]
syscall_exit_to_user_mode_prepare include/linux/irq-entry-common.h:256 [inline]
syscall_exit_to_user_mode include/linux/entry-common.h:325 [inline]
do_syscall_64+0x33e/0xf80 arch/x86/entry/syscall_64.c:100
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f6d7f19c819
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:00007fffed5fcaf8 EFLAGS: 00000246 ORIG_RAX: 00000000000001b4
RAX: 0000000000000000 RBX: 00007fffed5fcbe0 RCX: 00007f6d7f19c819
RDX: 0000000000000000 RSI: 000000000000001e RDI: 0000000000000003
RBP: 000000000001f748 R08: 0000000000000001 R09: 0000000000000000
R10: 0000001b30620000 R11: 0000000000000246 R12: 00007fffed5fcc20
R13: 00007f6d7f41609c R14: 000000000001f783 R15: 00007f6d7f416090
</TASK>
Allocated by task 7352:
kasan_save_stack mm/kasan/common.c:57 [inline]
kasan_save_track+0x3e/0x80 mm/kasan/common.c:78
poison_kmalloc_redzone mm/kasan/common.c:398 [inline]
__kasan_kmalloc+0x93/0xb0 mm/kasan/common.c:415
kasan_kmalloc include/linux/kasan.h:263 [inline]
__kmalloc_cache_noprof+0x31c/0x660 mm/slub.c:5380
kmalloc_noprof include/linux/slab.h:950 [inline]
kzalloc_noprof include/linux/slab.h:1188 [inline]
__drm_gem_shmem_create+0xc4/0x2e0 drivers/gpu/drm/drm_gem_shmem_helper.c:130
drm_gem_shmem_create drivers/gpu/drm/drm_gem_shmem_helper.c:157 [inline]
drm_gem_shmem_create_with_handle drivers/gpu/drm/drm_gem_shmem_helper.c:460 [inline]
drm_gem_shmem_dumb_create+0x72/0x120 drivers/gpu/drm/drm_gem_shmem_helper.c:549
drm_mode_create_dumb drivers/gpu/drm/drm_dumb_buffers.c:227 [inline]
drm_mode_create_dumb_ioctl+0x2bd/0x340 drivers/gpu/drm/drm_dumb_buffers.c:236
drm_ioctl_kernel+0x2df/0x3b0 drivers/gpu/drm/drm_ioctl.c:804
drm_ioctl+0x6ba/0xb80 drivers/gpu/drm/drm_ioctl.c:901
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:597 [inline]
__se_sys_ioctl+0xfc/0x170 fs/ioctl.c:583
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x15f/0xf80 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Freed by task 7354:
kasan_save_stack mm/kasan/common.c:57 [inline]
kasan_save_track+0x3e/0x80 mm/kasan/common.c:78
kasan_save_free_info+0x46/0x50 mm/kasan/generic.c:584
poison_slab_object mm/kasan/common.c:253 [inline]
__kasan_slab_free+0x5c/0x80 mm/kasan/common.c:285
kasan_slab_free include/linux/kasan.h:235 [inline]
slab_free_hook mm/slub.c:2685 [inline]
slab_free mm/slub.c:6165 [inline]
kfree+0x1c1/0x630 mm/slub.c:6483
drm_gem_handle_delete+0x7b/0xb0 drivers/gpu/drm/drm_gem.c:413
drm_ioctl_kernel+0x2df/0x3b0 drivers/gpu/drm/drm_ioctl.c:804
drm_ioctl+0x6ba/0xb80 drivers/gpu/drm/drm_ioctl.c:901
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:597 [inline]
__se_sys_ioctl+0xfc/0x170 fs/ioctl.c:583
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x15f/0xf80 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
The buggy address belongs to the object at ffff88805fd7c000
which belongs to the cache kmalloc-1k of size 1024
The buggy address is located 0 bytes inside of
freed 1024-byte region [ffff88805fd7c000, ffff88805fd7c400)
The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x5fd78
head: order:3 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0xfff00000000040(head|node=0|zone=1|lastcpupid=0x7ff)
page_type: f5(slab)
raw: 00fff00000000040 ffff88813fea7dc0 dead000000000100 dead000000000122
raw: 0000000000000000 0000000800100010 00000000f5000000 0000000000000000
head: 00fff00000000040 ffff88813fea7dc0 dead000000000100 dead000000000122
head: 0000000000000000 0000000800100010 00000000f5000000 0000000000000000
head: 00fff00000000003 ffffea00017f5e01 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 0xd2820(GFP_ATOMIC|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 0, tgid 0 (swapper/1), ts 115363717071, free_ts 110501992001
set_page_owner include/linux/page_owner.h:32 [inline]
post_alloc_hook+0x231/0x280 mm/page_alloc.c:1889
prep_new_page mm/page_alloc.c:1897 [inline]
get_page_from_freelist+0x24dc/0x2580 mm/page_alloc.c:3962
__alloc_frozen_pages_noprof+0x18d/0x380 mm/page_alloc.c:5250
alloc_slab_page mm/slub.c:3292 [inline]
allocate_slab+0x77/0x660 mm/slub.c:3481
new_slab mm/slub.c:3539 [inline]
refill_objects+0x331/0x3c0 mm/slub.c:7175
refill_sheaf mm/slub.c:2812 [inline]
__pcs_replace_empty_main+0x2e6/0x730 mm/slub.c:4615
alloc_from_pcs mm/slub.c:4717 [inline]
slab_alloc_node mm/slub.c:4851 [inline]
__do_kmalloc_node mm/slub.c:5259 [inline]
__kmalloc_noprof+0x474/0x760 mm/slub.c:5272
kmalloc_noprof include/linux/slab.h:954 [inline]
kzalloc_noprof include/linux/slab.h:1188 [inline]
ieee802_11_parse_elems_full+0x159/0x2ab0 net/mac80211/parse.c:1051
ieee802_11_parse_elems net/mac80211/ieee80211_i.h:2480 [inline]
ieee80211_inform_bss+0x161/0x1160 net/mac80211/scan.c:79
rdev_inform_bss net/wireless/rdev-ops.h:418 [inline]
cfg80211_inform_single_bss_data+0xd08/0x1b70 net/wireless/scan.c:2372
cfg80211_inform_bss_data+0x266/0x3c40 net/wireless/scan.c:3226
cfg80211_inform_bss_frame_data+0x3c7/0x760 net/wireless/scan.c:3317
ieee80211_bss_info_update+0x794/0xa40 net/mac80211/scan.c:230
ieee80211_scan_rx+0x552/0xa40 net/mac80211/scan.c:364
__ieee80211_rx_handle_packet net/mac80211/rx.c:5305 [inline]
ieee80211_rx_list+0x29e5/0x3710 net/mac80211/rx.c:5588
ieee80211_rx_napi+0x1b1/0x3e0 net/mac80211/rx.c:5611
page last free pid 6257 tgid 6257 stack trace:
reset_page_owner include/linux/page_owner.h:25 [inline]
__free_pages_prepare mm/page_alloc.c:1433 [inline]
__free_frozen_pages+0xc2b/0xdb0 mm/page_alloc.c:2978
vfree+0x25a/0x400 mm/vmalloc.c:3479
kcov_put kernel/kcov.c:442 [inline]
kcov_close+0x28/0x50 kernel/kcov.c:543
__fput+0x44f/0xa60 fs/file_table.c:510
task_work_run+0x1d9/0x270 kernel/task_work.c:233
exit_task_work include/linux/task_work.h:40 [inline]
do_exit+0x70f/0x23c0 kernel/exit.c:976
do_group_exit+0x21b/0x2d0 kernel/exit.c:1118
get_signal+0x1284/0x1330 kernel/signal.c:3038
arch_do_signal_or_restart+0xbc/0x830 arch/x86/kernel/signal.c:337
__exit_to_user_mode_loop kernel/entry/common.c:64 [inline]
exit_to_user_mode_loop+0x86/0x480 kernel/entry/common.c:98
__exit_to_user_mode_prepare include/linux/irq-entry-common.h:226 [inline]
syscall_exit_to_user_mode_prepare include/linux/irq-entry-common.h:256 [inline]
syscall_exit_to_user_mode include/linux/entry-common.h:325 [inline]
do_syscall_64+0x33e/0xf80 arch/x86/entry/syscall_64.c:100
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Memory state around the buggy address:
ffff88805fd7bf00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff88805fd7bf80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88805fd7c000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88805fd7c080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88805fd7c100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
Tested on:
commit: d568788b Merge tag 'hardening-v7.1-rc1' of git://git.k..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=16807b02580000
kernel config: https://syzkaller.appspot.com/x/.config?x=a5efbbca3dd2f716
dashboard link: https://syzkaller.appspot.com/bug?extid=b2e951687503f32f74ce
compiler: Debian clang version 21.1.8 (++20251221033036+2078da43e25a-1~exp1~20251221153213.50), Debian LLD 21.1.8
patch: https://syzkaller.appspot.com/x/patch.diff?x=113e68ce580000
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [syzbot] [dri?] KASAN: slab-use-after-free Read in drm_gem_object_release_handle
2026-04-13 17:16 [syzbot] [dri?] KASAN: slab-use-after-free Read in drm_gem_object_release_handle syzbot
2026-04-14 0:16 ` Forwarded: [PATCH] drm/gem: fix use-after-free in drm_gem_release syzbot
2026-04-14 1:32 ` syzbot
@ 2026-04-14 5:00 ` Hillf Danton
2026-04-14 5:26 ` syzbot
2026-04-14 5:49 ` Forwarded: [PATCH] drm/gem: fix use-after-free in drm_gem_release syzbot
` (4 subsequent siblings)
7 siblings, 1 reply; 16+ messages in thread
From: Hillf Danton @ 2026-04-14 5:00 UTC (permalink / raw)
To: syzbot; +Cc: linux-kernel, syzkaller-bugs
> Date: Mon, 13 Apr 2026 10:16:36 -0700 [thread overview]
> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit: f5459048c38a Merge tag 'i2c-for-7.0-final' of git://git.ke..
> git tree: upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=1028d106580000
> kernel config: https://syzkaller.appspot.com/x/.config?x=6754c86e8d9e4c91
> dashboard link: https://syzkaller.appspot.com/bug?extid=b2e951687503f32f74ce
> compiler: Debian clang version 21.1.8 (++20251221033036+2078da43e25a-1~exp1~20251221153213.50), Debian LLD 21.1.8
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1428d106580000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=17509036580000
#syz test
--- x/drivers/gpu/drm/drm_gem.c
+++ y/drivers/gpu/drm/drm_gem.c
@@ -387,6 +387,23 @@ drm_gem_object_release_handle(int id, vo
return 0;
}
+static int
+drm_gem_object_release_idr_handle(int id, void *ptr, void *data)
+{
+ struct drm_file *filp = data;
+ struct drm_gem_object *obj, *tmp = ptr;
+
+ spin_lock(&filp->table_lock);
+ obj = idr_replace(&filp->object_idr, NULL, id);
+ spin_unlock(&filp->table_lock);
+ if (IS_ERR_OR_NULL(obj))
+ return 0;
+ if (obj != tmp)
+ return 0;
+ drm_gem_object_release_handle(id, obj, filp);
+ return 0;
+}
+
/**
* drm_gem_handle_delete - deletes the given file-private handle
* @filp: drm file-private structure to use for the handle look up
@@ -1086,7 +1103,7 @@ void
drm_gem_release(struct drm_device *dev, struct drm_file *file_private)
{
idr_for_each(&file_private->object_idr,
- &drm_gem_object_release_handle, file_private);
+ &drm_gem_object_release_idr_handle, file_private);
idr_destroy(&file_private->object_idr);
}
--
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [syzbot] [dri?] KASAN: slab-use-after-free Read in drm_gem_object_release_handle
2026-04-14 5:00 ` [syzbot] [dri?] KASAN: slab-use-after-free Read in drm_gem_object_release_handle Hillf Danton
@ 2026-04-14 5:26 ` syzbot
0 siblings, 0 replies; 16+ messages in thread
From: syzbot @ 2026-04-14 5:26 UTC (permalink / raw)
To: hdanton, linux-kernel, syzkaller-bugs
Hello,
syzbot has tested the proposed patch but the reproducer is still triggering an issue:
KFENCE: use-after-free read in drm_gem_object_release_handle
==================================================================
BUG: KFENCE: use-after-free read in drm_gem_object_release_handle+0x47/0x1e0 drivers/gpu/drm/drm_gem.c:374
Use-after-free read at 0xffff88823be98e88 (in kfence-#75):
drm_gem_object_release_handle+0x47/0x1e0 drivers/gpu/drm/drm_gem.c:374
drm_gem_object_release_idr_handle+0x69/0x80 drivers/gpu/drm/drm_gem.c:403
idr_for_each+0x1c6/0x2a0 lib/idr.c:210
drm_gem_release+0x28/0x40 drivers/gpu/drm/drm_gem.c:1105
drm_file_free+0x729/0xa00 drivers/gpu/drm/drm_file.c:261
drm_close_helper drivers/gpu/drm/drm_file.c:290 [inline]
drm_release+0x2de/0x3f0 drivers/gpu/drm/drm_file.c:438
__fput+0x44f/0xa60 fs/file_table.c:510
task_work_run+0x1d9/0x270 kernel/task_work.c:233
resume_user_mode_work include/linux/resume_user_mode.h:50 [inline]
__exit_to_user_mode_loop kernel/entry/common.c:67 [inline]
exit_to_user_mode_loop+0xed/0x480 kernel/entry/common.c:98
__exit_to_user_mode_prepare include/linux/irq-entry-common.h:226 [inline]
syscall_exit_to_user_mode_prepare include/linux/irq-entry-common.h:256 [inline]
syscall_exit_to_user_mode include/linux/entry-common.h:325 [inline]
do_syscall_64+0x33e/0xf80 arch/x86/entry/syscall_64.c:100
entry_SYSCALL_64_after_hwframe+0x77/0x7f
kfence-#75: 0xffff88823be98c00-0xffff88823be98ee7, size=744, cache=kmalloc-1k
allocated by task 6583 on cpu 0 at 133.209896s (0.096709s ago):
kmalloc_noprof include/linux/slab.h:950 [inline]
kzalloc_noprof include/linux/slab.h:1188 [inline]
__drm_gem_shmem_create+0xc4/0x2e0 drivers/gpu/drm/drm_gem_shmem_helper.c:130
drm_gem_shmem_create drivers/gpu/drm/drm_gem_shmem_helper.c:157 [inline]
drm_gem_shmem_create_with_handle drivers/gpu/drm/drm_gem_shmem_helper.c:460 [inline]
drm_gem_shmem_dumb_create+0x72/0x120 drivers/gpu/drm/drm_gem_shmem_helper.c:549
drm_mode_create_dumb drivers/gpu/drm/drm_dumb_buffers.c:227 [inline]
drm_mode_create_dumb_ioctl+0x2bd/0x340 drivers/gpu/drm/drm_dumb_buffers.c:236
drm_ioctl_kernel+0x2df/0x3b0 drivers/gpu/drm/drm_ioctl.c:804
drm_ioctl+0x6ba/0xb80 drivers/gpu/drm/drm_ioctl.c:901
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:597 [inline]
__se_sys_ioctl+0xfc/0x170 fs/ioctl.c:583
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x15f/0xf80 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
freed by task 6585 on cpu 1 at 133.211010s (0.147010s ago):
drm_gem_handle_delete+0x7b/0xb0 drivers/gpu/drm/drm_gem.c:430
drm_ioctl_kernel+0x2df/0x3b0 drivers/gpu/drm/drm_ioctl.c:804
drm_ioctl+0x6ba/0xb80 drivers/gpu/drm/drm_ioctl.c:901
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:597 [inline]
__se_sys_ioctl+0xfc/0x170 fs/ioctl.c:583
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x15f/0xf80 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
CPU: 1 UID: 0 PID: 6581 Comm: syz.1.67 Not tainted syzkaller #0 PREEMPT(full)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/18/2026
RIP: 0010:drm_gem_object_release_handle+0x47/0x1e0 drivers/gpu/drm/drm_gem.c:374
Code: 5f 6c 62 fc 4d 85 f6 0f 84 9e 00 00 00 4c 8d bb 88 02 00 00 4c 89 f8 48 c1 e8 03 42 80 3c 28 00 74 08 4c 89 ff e8 59 c1 cc fc <4d> 8b 3f 49 83 c7 10 4c 89 f8 48 c1 e8 03 42 80 3c 28 00 74 08 4c
RSP: 0018:ffffc90003f27ad8 EFLAGS: 00010246
RAX: 1ffff110477d31d1 RBX: ffff88823be98c00 RCX: ffff888054fa1e80
RDX: 0000000000000000 RSI: ffff88823be98c00 RDI: 0000000000000080
RBP: 0000000000000080 R08: ffff8880321950e3 R09: 1ffff11006432a1c
R10: dffffc0000000000 R11: ffffed1006432a1d R12: ffff8880321950e0
R13: dffffc0000000000 R14: ffff888032195000 R15: ffff88823be98e88
FS: 000055557167a500(0000) GS:ffff88812554b000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: ffff88823be98e88 CR3: 000000006dd68000 CR4: 00000000003526f0
Call Trace:
<TASK>
drm_gem_object_release_idr_handle+0x69/0x80 drivers/gpu/drm/drm_gem.c:403
idr_for_each+0x1c6/0x2a0 lib/idr.c:210
drm_gem_release+0x28/0x40 drivers/gpu/drm/drm_gem.c:1105
drm_file_free+0x729/0xa00 drivers/gpu/drm/drm_file.c:261
drm_close_helper drivers/gpu/drm/drm_file.c:290 [inline]
drm_release+0x2de/0x3f0 drivers/gpu/drm/drm_file.c:438
__fput+0x44f/0xa60 fs/file_table.c:510
task_work_run+0x1d9/0x270 kernel/task_work.c:233
resume_user_mode_work include/linux/resume_user_mode.h:50 [inline]
__exit_to_user_mode_loop kernel/entry/common.c:67 [inline]
exit_to_user_mode_loop+0xed/0x480 kernel/entry/common.c:98
__exit_to_user_mode_prepare include/linux/irq-entry-common.h:226 [inline]
syscall_exit_to_user_mode_prepare include/linux/irq-entry-common.h:256 [inline]
syscall_exit_to_user_mode include/linux/entry-common.h:325 [inline]
do_syscall_64+0x33e/0xf80 arch/x86/entry/syscall_64.c:100
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f246c99c819
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:00007ffd35630618 EFLAGS: 00000246 ORIG_RAX: 00000000000001b4
RAX: 0000000000000000 RBX: 00007ffd35630700 RCX: 00007f246c99c819
RDX: 0000000000000000 RSI: 000000000000001e RDI: 0000000000000003
RBP: 000000000002082e R08: 0000000000000001 R09: 0000000000000000
R10: 0000001b32820000 R11: 0000000000000246 R12: 00007ffd35630740
R13: 00007f246cc1609c R14: 0000000000020866 R15: 00007f246cc16090
</TASK>
==================================================================
----------------
Code disassembly (best guess), 3 bytes skipped:
0: fc cld
1: 4d 85 f6 test %r14,%r14
4: 0f 84 9e 00 00 00 je 0xa8
a: 4c 8d bb 88 02 00 00 lea 0x288(%rbx),%r15
11: 4c 89 f8 mov %r15,%rax
14: 48 c1 e8 03 shr $0x3,%rax
18: 42 80 3c 28 00 cmpb $0x0,(%rax,%r13,1)
1d: 74 08 je 0x27
1f: 4c 89 ff mov %r15,%rdi
22: e8 59 c1 cc fc call 0xfcccc180
* 27: 4d 8b 3f mov (%r15),%r15 <-- trapping instruction
2a: 49 83 c7 10 add $0x10,%r15
2e: 4c 89 f8 mov %r15,%rax
31: 48 c1 e8 03 shr $0x3,%rax
35: 42 80 3c 28 00 cmpb $0x0,(%rax,%r13,1)
3a: 74 08 je 0x44
3c: 4c rex.WR
Tested on:
commit: d60bc140 Merge tag 'pwrseq-updates-for-v7.1-rc1' of gi..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=157e7cd2580000
kernel config: https://syzkaller.appspot.com/x/.config?x=85bd86f990609a1
dashboard link: https://syzkaller.appspot.com/bug?extid=b2e951687503f32f74ce
compiler: Debian clang version 21.1.8 (++20251221033036+2078da43e25a-1~exp1~20251221153213.50), Debian LLD 21.1.8
patch: https://syzkaller.appspot.com/x/patch.diff?x=12673036580000
^ permalink raw reply [flat|nested] 16+ messages in thread
* Forwarded: [PATCH] drm/gem: fix use-after-free in drm_gem_release
2026-04-13 17:16 [syzbot] [dri?] KASAN: slab-use-after-free Read in drm_gem_object_release_handle syzbot
` (2 preceding siblings ...)
2026-04-14 5:00 ` [syzbot] [dri?] KASAN: slab-use-after-free Read in drm_gem_object_release_handle Hillf Danton
@ 2026-04-14 5:49 ` syzbot
2026-04-14 8:46 ` [syzbot] [dri?] KASAN: slab-use-after-free Read in drm_gem_object_release_handle Hillf Danton
` (3 subsequent siblings)
7 siblings, 0 replies; 16+ messages in thread
From: syzbot @ 2026-04-14 5:49 UTC (permalink / raw)
To: linux-kernel, syzkaller-bugs
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.
***
Subject: [PATCH] drm/gem: fix use-after-free in drm_gem_release
Author: kartikey406@gmail.com
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
drm_gem_release() calls idr_for_each() to iterate over all GEM handles
and release them during file close. However, idr_for_each() does not
hold file_priv->table_lock while reading object pointers from the IDR,
which means it can race with a concurrent drm_gem_handle_delete() from
a GEM_CLOSE ioctl on another thread sharing the same file descriptor.
The race is as follows:
Thread A (close fd) Thread B (GEM_CLOSE ioctl)
drm_gem_release()
idr_for_each()
reads obj ptr from IDR
drm_gem_handle_delete()
idr_replace(NULL)
drm_gem_object_release_handle()
handle_put -> kfree(obj)
drm_gem_object_release_handle()
obj->funcs->close() <- UAF!
Fix this by replacing idr_for_each() with a manual iteration loop that
holds table_lock while reading each pointer and uses idr_replace(NULL)
to claim the handle, mirroring the pattern used by
drm_gem_handle_delete(). This ensures mutual exclusion: whichever path
claims the handle first (sets it to NULL) gets to process it, and the
other path safely skips it.
Reported-by: syzbot+b2e951687503f32f74ce@syzkaller.appspotmail.com
Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
---
drivers/gpu/drm/drm_gem.c | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index 891c3bff5ae0..b878f82146f1 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -1085,8 +1085,28 @@ drm_gem_open(struct drm_device *dev, struct drm_file *file_private)
void
drm_gem_release(struct drm_device *dev, struct drm_file *file_private)
{
- idr_for_each(&file_private->object_idr,
- &drm_gem_object_release_handle, file_private);
+ struct drm_gem_object *obj;
+ int next_id;
+
+ next_id = 0;
+ while (1) {
+ spin_lock(&file_private->table_lock);
+ obj = idr_get_next(&file_private->object_idr, &next_id);
+ if (!obj) {
+ spin_unlock(&file_private->table_lock);
+ break;
+ }
+ /* Claim the handle — same pattern as drm_gem_handle_delete */
+ idr_replace(&file_private->object_idr, NULL, next_id);
+ spin_unlock(&file_private->table_lock);
+
+ drm_gem_object_release_handle(next_id, obj, file_private);
+
+ spin_lock(&file_private->table_lock);
+ idr_remove(&file_private->object_idr, next_id);
+ spin_unlock(&file_private->table_lock);
+ next_id++;
+ }
idr_destroy(&file_private->object_idr);
}
--
2.43.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [syzbot] [dri?] KASAN: slab-use-after-free Read in drm_gem_object_release_handle
[not found] <20260414054951.69728-1-kartikey406@gmail.com>
@ 2026-04-14 6:22 ` syzbot
0 siblings, 0 replies; 16+ messages in thread
From: syzbot @ 2026-04-14 6:22 UTC (permalink / raw)
To: kartikey406, linux-kernel, syzkaller-bugs
Hello,
syzbot has tested the proposed patch but the reproducer is still triggering an issue:
KASAN: slab-use-after-free Read in drm_gem_object_release_handle
==================================================================
BUG: KASAN: slab-use-after-free in drm_gem_object_release_handle+0x47/0x1e0 drivers/gpu/drm/drm_gem.c:374
Read of size 8 at addr ffff88805834ba88 by task syz.2.37/6482
CPU: 1 UID: 0 PID: 6482 Comm: syz.2.37 Not tainted syzkaller #0 PREEMPT(full)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/18/2026
Call Trace:
<TASK>
dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120
print_address_description mm/kasan/report.c:378 [inline]
print_report+0xba/0x230 mm/kasan/report.c:482
kasan_report+0x117/0x150 mm/kasan/report.c:595
drm_gem_object_release_handle+0x47/0x1e0 drivers/gpu/drm/drm_gem.c:374
drm_gem_release+0xd4/0x180 drivers/gpu/drm/drm_gem.c:1103
drm_file_free+0x729/0xa00 drivers/gpu/drm/drm_file.c:261
drm_close_helper drivers/gpu/drm/drm_file.c:290 [inline]
drm_release+0x2de/0x3f0 drivers/gpu/drm/drm_file.c:438
__fput+0x44f/0xa60 fs/file_table.c:510
task_work_run+0x1d9/0x270 kernel/task_work.c:233
resume_user_mode_work include/linux/resume_user_mode.h:50 [inline]
__exit_to_user_mode_loop kernel/entry/common.c:67 [inline]
exit_to_user_mode_loop+0xed/0x480 kernel/entry/common.c:98
__exit_to_user_mode_prepare include/linux/irq-entry-common.h:226 [inline]
syscall_exit_to_user_mode_prepare include/linux/irq-entry-common.h:256 [inline]
syscall_exit_to_user_mode include/linux/entry-common.h:325 [inline]
do_syscall_64+0x33e/0xf80 arch/x86/entry/syscall_64.c:100
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f1cc479c819
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:00007fffa1bd2a08 EFLAGS: 00000246 ORIG_RAX: 00000000000001b4
RAX: 0000000000000000 RBX: 00007fffa1bd2af0 RCX: 00007f1cc479c819
RDX: 0000000000000000 RSI: 000000000000001e RDI: 0000000000000003
RBP: 000000000001f8d7 R08: 0000000000000001 R09: 0000000000000000
R10: 0000001b32920000 R11: 0000000000000246 R12: 00007fffa1bd2b30
R13: 00007f1cc4a1609c R14: 000000000001f91d R15: 00007f1cc4a16090
</TASK>
Allocated by task 6485:
kasan_save_stack mm/kasan/common.c:57 [inline]
kasan_save_track+0x3e/0x80 mm/kasan/common.c:78
poison_kmalloc_redzone mm/kasan/common.c:398 [inline]
__kasan_kmalloc+0x93/0xb0 mm/kasan/common.c:415
kasan_kmalloc include/linux/kasan.h:263 [inline]
__kmalloc_cache_noprof+0x31c/0x660 mm/slub.c:5380
kmalloc_noprof include/linux/slab.h:950 [inline]
kzalloc_noprof include/linux/slab.h:1188 [inline]
__drm_gem_shmem_create+0xc4/0x2e0 drivers/gpu/drm/drm_gem_shmem_helper.c:130
drm_gem_shmem_create drivers/gpu/drm/drm_gem_shmem_helper.c:157 [inline]
drm_gem_shmem_create_with_handle drivers/gpu/drm/drm_gem_shmem_helper.c:460 [inline]
drm_gem_shmem_dumb_create+0x72/0x120 drivers/gpu/drm/drm_gem_shmem_helper.c:549
drm_mode_create_dumb drivers/gpu/drm/drm_dumb_buffers.c:227 [inline]
drm_mode_create_dumb_ioctl+0x2bd/0x340 drivers/gpu/drm/drm_dumb_buffers.c:236
drm_ioctl_kernel+0x2df/0x3b0 drivers/gpu/drm/drm_ioctl.c:804
drm_ioctl+0x6ba/0xb80 drivers/gpu/drm/drm_ioctl.c:901
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:597 [inline]
__se_sys_ioctl+0xfc/0x170 fs/ioctl.c:583
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x15f/0xf80 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Freed by task 6486:
kasan_save_stack mm/kasan/common.c:57 [inline]
kasan_save_track+0x3e/0x80 mm/kasan/common.c:78
kasan_save_free_info+0x46/0x50 mm/kasan/generic.c:584
poison_slab_object mm/kasan/common.c:253 [inline]
__kasan_slab_free+0x5c/0x80 mm/kasan/common.c:285
kasan_slab_free include/linux/kasan.h:235 [inline]
slab_free_hook mm/slub.c:2685 [inline]
slab_free mm/slub.c:6165 [inline]
kfree+0x1c1/0x630 mm/slub.c:6483
drm_gem_handle_delete+0x7b/0xb0 drivers/gpu/drm/drm_gem.c:413
drm_ioctl_kernel+0x2df/0x3b0 drivers/gpu/drm/drm_ioctl.c:804
drm_ioctl+0x6ba/0xb80 drivers/gpu/drm/drm_ioctl.c:901
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:597 [inline]
__se_sys_ioctl+0xfc/0x170 fs/ioctl.c:583
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x15f/0xf80 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
The buggy address belongs to the object at ffff88805834b800
which belongs to the cache kmalloc-1k of size 1024
The buggy address is located 648 bytes inside of
freed 1024-byte region [ffff88805834b800, ffff88805834bc00)
The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x58348
head: order:3 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0xfff00000000040(head|node=0|zone=1|lastcpupid=0x7ff)
page_type: f5(slab)
raw: 00fff00000000040 ffff88813fea7dc0 dead000000000100 dead000000000122
raw: 0000000000000000 0000000800100010 00000000f5000000 0000000000000000
head: 00fff00000000040 ffff88813fea7dc0 dead000000000100 dead000000000122
head: 0000000000000000 0000000800100010 00000000f5000000 0000000000000000
head: 00fff00000000003 ffffea000160d201 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 0xd2820(GFP_ATOMIC|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 5958, tgid 5958 (kworker/1:4), ts 129229212769, free_ts 129225250555
set_page_owner include/linux/page_owner.h:32 [inline]
post_alloc_hook+0x231/0x280 mm/page_alloc.c:1889
prep_new_page mm/page_alloc.c:1897 [inline]
get_page_from_freelist+0x24dc/0x2580 mm/page_alloc.c:3962
__alloc_frozen_pages_noprof+0x18d/0x380 mm/page_alloc.c:5250
alloc_slab_page mm/slub.c:3292 [inline]
allocate_slab+0x77/0x660 mm/slub.c:3481
new_slab mm/slub.c:3539 [inline]
refill_objects+0x331/0x3c0 mm/slub.c:7175
refill_sheaf mm/slub.c:2812 [inline]
__pcs_replace_empty_main+0x2e6/0x730 mm/slub.c:4615
alloc_from_pcs mm/slub.c:4717 [inline]
slab_alloc_node mm/slub.c:4851 [inline]
__do_kmalloc_node mm/slub.c:5259 [inline]
__kmalloc_noprof+0x474/0x760 mm/slub.c:5272
kmalloc_noprof include/linux/slab.h:954 [inline]
kzalloc_noprof include/linux/slab.h:1188 [inline]
neigh_alloc net/core/neighbour.c:521 [inline]
___neigh_create+0x6d5/0x2280 net/core/neighbour.c:655
ip6_finish_output2+0x729/0x13e0 net/ipv6/ip6_output.c:128
NF_HOOK_COND include/linux/netfilter.h:307 [inline]
ip6_output+0x340/0x550 net/ipv6/ip6_output.c:246
dst_output include/net/dst.h:470 [inline]
NF_HOOK+0x177/0x4f0 include/linux/netfilter.h:318
mld_sendpack+0x8b4/0xe40 net/ipv6/mcast.c:1855
mld_send_cr net/ipv6/mcast.c:2154 [inline]
mld_ifc_work+0x835/0xe70 net/ipv6/mcast.c:2693
process_one_work kernel/workqueue.c:3288 [inline]
process_scheduled_works+0xb6e/0x18c0 kernel/workqueue.c:3371
worker_thread+0xa53/0xfc0 kernel/workqueue.c:3452
kthread+0x388/0x470 kernel/kthread.c:436
page last free pid 6179 tgid 6179 stack trace:
reset_page_owner include/linux/page_owner.h:25 [inline]
__free_pages_prepare mm/page_alloc.c:1433 [inline]
__free_frozen_pages+0xc2b/0xdb0 mm/page_alloc.c:2978
__slab_free+0x263/0x2b0 mm/slub.c:5573
qlink_free mm/kasan/quarantine.c:163 [inline]
qlist_free_all+0x97/0x100 mm/kasan/quarantine.c:179
kasan_quarantine_reduce+0x148/0x160 mm/kasan/quarantine.c:286
__kasan_slab_alloc+0x22/0x80 mm/kasan/common.c:350
kasan_slab_alloc include/linux/kasan.h:253 [inline]
slab_post_alloc_hook mm/slub.c:4538 [inline]
slab_alloc_node mm/slub.c:4866 [inline]
__do_kmalloc_node mm/slub.c:5259 [inline]
__kvmalloc_node_noprof+0x4d7/0x8a0 mm/slub.c:6752
seq_buf_alloc fs/seq_file.c:39 [inline]
seq_read_iter+0x202/0xe10 fs/seq_file.c:211
new_sync_read fs/read_write.c:493 [inline]
vfs_read+0x582/0xa70 fs/read_write.c:574
ksys_read+0x150/0x270 fs/read_write.c:717
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x15f/0xf80 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Memory state around the buggy address:
ffff88805834b980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88805834ba00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88805834ba80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88805834bb00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88805834bb80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
Tested on:
commit: d60bc140 Merge tag 'pwrseq-updates-for-v7.1-rc1' of gi..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=166a7b02580000
kernel config: https://syzkaller.appspot.com/x/.config?x=85bd86f990609a1
dashboard link: https://syzkaller.appspot.com/bug?extid=b2e951687503f32f74ce
compiler: Debian clang version 21.1.8 (++20251221033036+2078da43e25a-1~exp1~20251221153213.50), Debian LLD 21.1.8
patch: https://syzkaller.appspot.com/x/patch.diff?x=16c1d8ce580000
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [syzbot] [dri?] KASAN: slab-use-after-free Read in drm_gem_object_release_handle
2026-04-13 17:16 [syzbot] [dri?] KASAN: slab-use-after-free Read in drm_gem_object_release_handle syzbot
` (3 preceding siblings ...)
2026-04-14 5:49 ` Forwarded: [PATCH] drm/gem: fix use-after-free in drm_gem_release syzbot
@ 2026-04-14 8:46 ` Hillf Danton
2026-04-14 9:04 ` syzbot
2026-04-14 10:03 ` Hillf Danton
` (2 subsequent siblings)
7 siblings, 1 reply; 16+ messages in thread
From: Hillf Danton @ 2026-04-14 8:46 UTC (permalink / raw)
To: syzbot; +Cc: linux-kernel, syzkaller-bugs
> Date: Mon, 13 Apr 2026 10:16:36 -0700 [thread overview]
> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit: f5459048c38a Merge tag 'i2c-for-7.0-final' of git://git.ke..
> git tree: upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=1028d106580000
> kernel config: https://syzkaller.appspot.com/x/.config?x=6754c86e8d9e4c91
> dashboard link: https://syzkaller.appspot.com/bug?extid=b2e951687503f32f74ce
> compiler: Debian clang version 21.1.8 (++20251221033036+2078da43e25a-1~exp1~20251221153213.50), Debian LLD 21.1.8
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1428d106580000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=17509036580000
#syz test
--- x/drivers/gpu/drm/drm_gem.c
+++ y/drivers/gpu/drm/drm_gem.c
@@ -387,6 +387,24 @@ drm_gem_object_release_handle(int id, vo
return 0;
}
+static int
+drm_gem_object_release_idr_handle(int id, void *ptr, void *data)
+{
+ struct drm_file *filp = data;
+ struct drm_gem_object *obj, *tmp = ptr;
+
+ spin_lock(&filp->table_lock);
+ obj = idr_replace(&filp->object_idr, NULL, id);
+ idr_remove(&filp->object_idr, id);
+ spin_unlock(&filp->table_lock);
+ if (IS_ERR_OR_NULL(obj))
+ return 0;
+ if (obj != tmp)
+ return 0;
+ drm_gem_object_release_handle(id, obj, filp);
+ return 0;
+}
+
/**
* drm_gem_handle_delete - deletes the given file-private handle
* @filp: drm file-private structure to use for the handle look up
@@ -405,6 +423,7 @@ drm_gem_handle_delete(struct drm_file *f
/* Check if we currently have a reference on the object */
obj = idr_replace(&filp->object_idr, NULL, handle);
+ idr_remove(&filp->object_idr, handle);
spin_unlock(&filp->table_lock);
if (IS_ERR_OR_NULL(obj))
return -EINVAL;
@@ -412,11 +431,6 @@ drm_gem_handle_delete(struct drm_file *f
/* Release driver's reference and decrement refcount. */
drm_gem_object_release_handle(handle, obj, filp);
- /* And finally make the handle available for future allocations. */
- spin_lock(&filp->table_lock);
- idr_remove(&filp->object_idr, handle);
- spin_unlock(&filp->table_lock);
-
return 0;
}
EXPORT_SYMBOL(drm_gem_handle_delete);
@@ -1086,7 +1100,7 @@ void
drm_gem_release(struct drm_device *dev, struct drm_file *file_private)
{
idr_for_each(&file_private->object_idr,
- &drm_gem_object_release_handle, file_private);
+ &drm_gem_object_release_idr_handle, file_private);
idr_destroy(&file_private->object_idr);
}
--
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [syzbot] [dri?] KASAN: slab-use-after-free Read in drm_gem_object_release_handle
2026-04-14 8:46 ` [syzbot] [dri?] KASAN: slab-use-after-free Read in drm_gem_object_release_handle Hillf Danton
@ 2026-04-14 9:04 ` syzbot
0 siblings, 0 replies; 16+ messages in thread
From: syzbot @ 2026-04-14 9:04 UTC (permalink / raw)
To: hdanton, linux-kernel, syzkaller-bugs
Hello,
syzbot has tested the proposed patch but the reproducer is still triggering an issue:
KASAN: slab-use-after-free Read in drm_gem_object_release_handle
==================================================================
BUG: KASAN: slab-use-after-free in drm_gem_object_release_handle+0x47/0x1e0 drivers/gpu/drm/drm_gem.c:374
Read of size 8 at addr ffff8880296c6a88 by task syz.2.83/6856
CPU: 1 UID: 0 PID: 6856 Comm: syz.2.83 Not tainted syzkaller #0 PREEMPT(full)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/18/2026
Call Trace:
<TASK>
dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120
print_address_description mm/kasan/report.c:378 [inline]
print_report+0xba/0x230 mm/kasan/report.c:482
kasan_report+0x117/0x150 mm/kasan/report.c:595
drm_gem_object_release_handle+0x47/0x1e0 drivers/gpu/drm/drm_gem.c:374
drm_gem_object_release_idr_handle+0x83/0xa0 drivers/gpu/drm/drm_gem.c:404
idr_for_each+0x1c6/0x2a0 lib/idr.c:210
drm_gem_release+0x28/0x40 drivers/gpu/drm/drm_gem.c:1102
drm_file_free+0x729/0xa00 drivers/gpu/drm/drm_file.c:261
drm_close_helper drivers/gpu/drm/drm_file.c:290 [inline]
drm_release+0x2de/0x3f0 drivers/gpu/drm/drm_file.c:438
__fput+0x44f/0xa60 fs/file_table.c:510
task_work_run+0x1d9/0x270 kernel/task_work.c:233
resume_user_mode_work include/linux/resume_user_mode.h:50 [inline]
__exit_to_user_mode_loop kernel/entry/common.c:67 [inline]
exit_to_user_mode_loop+0xed/0x480 kernel/entry/common.c:98
__exit_to_user_mode_prepare include/linux/irq-entry-common.h:226 [inline]
syscall_exit_to_user_mode_prepare include/linux/irq-entry-common.h:256 [inline]
syscall_exit_to_user_mode include/linux/entry-common.h:325 [inline]
do_syscall_64+0x33e/0xf80 arch/x86/entry/syscall_64.c:100
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f736919c819
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:00007fffaf8d5118 EFLAGS: 00000246 ORIG_RAX: 00000000000001b4
RAX: 0000000000000000 RBX: 00007fffaf8d5200 RCX: 00007f736919c819
RDX: 0000000000000000 RSI: 000000000000001e RDI: 0000000000000003
RBP: 000000000001f76e R08: 0000000000000001 R09: 0000000000000000
R10: 0000001b32d20000 R11: 0000000000000246 R12: 00007fffaf8d5240
R13: 00007f736941609c R14: 000000000001f7f0 R15: 00007f7369416090
</TASK>
Allocated by task 6857:
kasan_save_stack mm/kasan/common.c:57 [inline]
kasan_save_track+0x3e/0x80 mm/kasan/common.c:78
poison_kmalloc_redzone mm/kasan/common.c:398 [inline]
__kasan_kmalloc+0x93/0xb0 mm/kasan/common.c:415
kasan_kmalloc include/linux/kasan.h:263 [inline]
__kmalloc_cache_noprof+0x31c/0x660 mm/slub.c:5380
kmalloc_noprof include/linux/slab.h:950 [inline]
kzalloc_noprof include/linux/slab.h:1188 [inline]
__drm_gem_shmem_create+0xc4/0x2e0 drivers/gpu/drm/drm_gem_shmem_helper.c:130
drm_gem_shmem_create drivers/gpu/drm/drm_gem_shmem_helper.c:157 [inline]
drm_gem_shmem_create_with_handle drivers/gpu/drm/drm_gem_shmem_helper.c:460 [inline]
drm_gem_shmem_dumb_create+0x72/0x120 drivers/gpu/drm/drm_gem_shmem_helper.c:549
drm_mode_create_dumb drivers/gpu/drm/drm_dumb_buffers.c:227 [inline]
drm_mode_create_dumb_ioctl+0x2bd/0x340 drivers/gpu/drm/drm_dumb_buffers.c:236
drm_ioctl_kernel+0x2df/0x3b0 drivers/gpu/drm/drm_ioctl.c:804
drm_ioctl+0x6ba/0xb80 drivers/gpu/drm/drm_ioctl.c:901
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:597 [inline]
__se_sys_ioctl+0xfc/0x170 fs/ioctl.c:583
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x15f/0xf80 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Freed by task 6864:
kasan_save_stack mm/kasan/common.c:57 [inline]
kasan_save_track+0x3e/0x80 mm/kasan/common.c:78
kasan_save_free_info+0x46/0x50 mm/kasan/generic.c:584
poison_slab_object mm/kasan/common.c:253 [inline]
__kasan_slab_free+0x5c/0x80 mm/kasan/common.c:285
kasan_slab_free include/linux/kasan.h:235 [inline]
slab_free_hook mm/slub.c:2685 [inline]
slab_free mm/slub.c:6165 [inline]
kfree+0x1c1/0x630 mm/slub.c:6483
drm_gem_handle_delete+0x90/0xb0 drivers/gpu/drm/drm_gem.c:432
drm_ioctl_kernel+0x2df/0x3b0 drivers/gpu/drm/drm_ioctl.c:804
drm_ioctl+0x6ba/0xb80 drivers/gpu/drm/drm_ioctl.c:901
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:597 [inline]
__se_sys_ioctl+0xfc/0x170 fs/ioctl.c:583
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x15f/0xf80 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
The buggy address belongs to the object at ffff8880296c6800
which belongs to the cache kmalloc-1k of size 1024
The buggy address is located 648 bytes inside of
freed 1024-byte region [ffff8880296c6800, ffff8880296c6c00)
The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0xffff8880296c1800 pfn:0x296c0
head: order:3 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0xfff00000000240(workingset|head|node=0|zone=1|lastcpupid=0x7ff)
page_type: f5(slab)
raw: 00fff00000000240 ffff88813fea7dc0 ffffea0001f5ea10 ffffea0000a31410
raw: ffff8880296c1800 000000080010000e 00000000f5000000 0000000000000000
head: 00fff00000000240 ffff88813fea7dc0 ffffea0001f5ea10 ffffea0000a31410
head: ffff8880296c1800 000000080010000e 00000000f5000000 0000000000000000
head: 00fff00000000003 ffffea0000a5b001 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 0xd2000(__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 619, tgid 619 (kworker/u8:7), ts 7851559667, free_ts 0
set_page_owner include/linux/page_owner.h:32 [inline]
post_alloc_hook+0x231/0x280 mm/page_alloc.c:1889
prep_new_page mm/page_alloc.c:1897 [inline]
get_page_from_freelist+0x24dc/0x2580 mm/page_alloc.c:3962
__alloc_frozen_pages_noprof+0x18d/0x380 mm/page_alloc.c:5250
alloc_slab_page mm/slub.c:3292 [inline]
allocate_slab+0x77/0x660 mm/slub.c:3481
new_slab mm/slub.c:3539 [inline]
refill_objects+0x331/0x3c0 mm/slub.c:7175
refill_sheaf mm/slub.c:2812 [inline]
__pcs_replace_empty_main+0x2e6/0x730 mm/slub.c:4615
alloc_from_pcs mm/slub.c:4717 [inline]
slab_alloc_node mm/slub.c:4851 [inline]
__kmalloc_cache_node_noprof+0x465/0x6b0 mm/slub.c:5388
kmalloc_node_noprof include/linux/slab.h:1077 [inline]
blk_mq_alloc_hctx block/blk-mq.c:4054 [inline]
blk_mq_alloc_and_init_hctx+0x17e/0xc50 block/blk-mq.c:4554
__blk_mq_realloc_hw_ctxs+0x2bd/0x670 block/blk-mq.c:4605
blk_mq_realloc_hw_ctxs block/blk-mq.c:4642 [inline]
blk_mq_init_allocated_queue+0x365/0x13e0 block/blk-mq.c:4672
blk_mq_alloc_queue+0x1ba/0x2e0 block/blk-mq.c:4454
scsi_alloc_sdev+0x7c0/0xc80 drivers/scsi/scsi_scan.c:339
scsi_probe_and_add_lun+0x200/0x4830 drivers/scsi/scsi_scan.c:1215
__scsi_scan_target+0x1f0/0xe10 drivers/scsi/scsi_scan.c:1786
scsi_scan_channel drivers/scsi/scsi_scan.c:1874 [inline]
scsi_scan_host_selected+0x372/0x690 drivers/scsi/scsi_scan.c:1903
do_scsi_scan_host drivers/scsi/scsi_scan.c:2042 [inline]
do_scan_async+0x124/0x760 drivers/scsi/scsi_scan.c:2052
page_owner free stack trace missing
Memory state around the buggy address:
ffff8880296c6980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880296c6a00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8880296c6a80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8880296c6b00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880296c6b80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
Tested on:
commit: d60bc140 Merge tag 'pwrseq-updates-for-v7.1-rc1' of gi..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=142d04ce580000
kernel config: https://syzkaller.appspot.com/x/.config?x=85bd86f990609a1
dashboard link: https://syzkaller.appspot.com/bug?extid=b2e951687503f32f74ce
compiler: Debian clang version 21.1.8 (++20251221033036+2078da43e25a-1~exp1~20251221153213.50), Debian LLD 21.1.8
patch: https://syzkaller.appspot.com/x/patch.diff?x=1284b036580000
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [syzbot] [dri?] KASAN: slab-use-after-free Read in drm_gem_object_release_handle
2026-04-13 17:16 [syzbot] [dri?] KASAN: slab-use-after-free Read in drm_gem_object_release_handle syzbot
` (4 preceding siblings ...)
2026-04-14 8:46 ` [syzbot] [dri?] KASAN: slab-use-after-free Read in drm_gem_object_release_handle Hillf Danton
@ 2026-04-14 10:03 ` Hillf Danton
2026-04-14 10:20 ` syzbot
2026-04-15 0:33 ` Hillf Danton
2026-04-15 7:50 ` Hillf Danton
7 siblings, 1 reply; 16+ messages in thread
From: Hillf Danton @ 2026-04-14 10:03 UTC (permalink / raw)
To: syzbot; +Cc: linux-kernel, syzkaller-bugs
> Date: Mon, 13 Apr 2026 10:16:36 -0700 [thread overview]
> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit: f5459048c38a Merge tag 'i2c-for-7.0-final' of git://git.ke..
> git tree: upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=1028d106580000
> kernel config: https://syzkaller.appspot.com/x/.config?x=6754c86e8d9e4c91
> dashboard link: https://syzkaller.appspot.com/bug?extid=b2e951687503f32f74ce
> compiler: Debian clang version 21.1.8 (++20251221033036+2078da43e25a-1~exp1~20251221153213.50), Debian LLD 21.1.8
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1428d106580000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=17509036580000
#syz test
--- x/drivers/gpu/drm/drm_gem.c
+++ y/drivers/gpu/drm/drm_gem.c
@@ -387,6 +387,26 @@ drm_gem_object_release_handle(int id, vo
return 0;
}
+static int
+drm_gem_object_release_idr_handle(int id, void *ptr, void *data)
+{
+ struct drm_file *filp = data;
+ struct drm_gem_object *obj, *tmp = ptr;
+
+ spin_lock(&filp->table_lock);
+ obj = idr_find(&filp->object_idr, id);
+ if (obj != tmp) {
+ spin_unlock(&filp->table_lock);
+ return 0;
+ }
+ idr_remove(&filp->object_idr, id);
+ spin_unlock(&filp->table_lock);
+ if (IS_ERR_OR_NULL(obj))
+ return 0;
+ drm_gem_object_release_handle(id, obj, filp);
+ return 0;
+}
+
/**
* drm_gem_handle_delete - deletes the given file-private handle
* @filp: drm file-private structure to use for the handle look up
@@ -404,7 +424,8 @@ drm_gem_handle_delete(struct drm_file *f
spin_lock(&filp->table_lock);
/* Check if we currently have a reference on the object */
- obj = idr_replace(&filp->object_idr, NULL, handle);
+ obj = idr_find(&filp->object_idr, handle);
+ idr_remove(&filp->object_idr, handle);
spin_unlock(&filp->table_lock);
if (IS_ERR_OR_NULL(obj))
return -EINVAL;
@@ -412,11 +433,6 @@ drm_gem_handle_delete(struct drm_file *f
/* Release driver's reference and decrement refcount. */
drm_gem_object_release_handle(handle, obj, filp);
- /* And finally make the handle available for future allocations. */
- spin_lock(&filp->table_lock);
- idr_remove(&filp->object_idr, handle);
- spin_unlock(&filp->table_lock);
-
return 0;
}
EXPORT_SYMBOL(drm_gem_handle_delete);
@@ -1086,7 +1102,7 @@ void
drm_gem_release(struct drm_device *dev, struct drm_file *file_private)
{
idr_for_each(&file_private->object_idr,
- &drm_gem_object_release_handle, file_private);
+ &drm_gem_object_release_idr_handle, file_private);
idr_destroy(&file_private->object_idr);
}
--
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [syzbot] [dri?] KASAN: slab-use-after-free Read in drm_gem_object_release_handle
2026-04-14 10:03 ` Hillf Danton
@ 2026-04-14 10:20 ` syzbot
0 siblings, 0 replies; 16+ messages in thread
From: syzbot @ 2026-04-14 10:20 UTC (permalink / raw)
To: hdanton, linux-kernel, syzkaller-bugs
Hello,
syzbot has tested the proposed patch but the reproducer is still triggering an issue:
KASAN: slab-use-after-free Read in drm_gem_object_release_handle
==================================================================
BUG: KASAN: slab-use-after-free in drm_gem_object_release_handle+0x47/0x1e0 drivers/gpu/drm/drm_gem.c:374
Read of size 8 at addr ffff888058ae0288 by task syz.1.26/6493
CPU: 1 UID: 0 PID: 6493 Comm: syz.1.26 Not tainted syzkaller #0 PREEMPT(full)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/18/2026
Call Trace:
<TASK>
dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120
print_address_description mm/kasan/report.c:378 [inline]
print_report+0xba/0x230 mm/kasan/report.c:482
kasan_report+0x117/0x150 mm/kasan/report.c:595
drm_gem_object_release_handle+0x47/0x1e0 drivers/gpu/drm/drm_gem.c:374
drm_gem_object_release_idr_handle+0x99/0xb0 drivers/gpu/drm/drm_gem.c:406
idr_for_each+0x1c6/0x2a0 lib/idr.c:210
drm_gem_release+0x28/0x40 drivers/gpu/drm/drm_gem.c:1104
drm_file_free+0x729/0xa00 drivers/gpu/drm/drm_file.c:261
drm_close_helper drivers/gpu/drm/drm_file.c:290 [inline]
drm_release+0x2de/0x3f0 drivers/gpu/drm/drm_file.c:438
__fput+0x44f/0xa60 fs/file_table.c:510
task_work_run+0x1d9/0x270 kernel/task_work.c:233
resume_user_mode_work include/linux/resume_user_mode.h:50 [inline]
__exit_to_user_mode_loop kernel/entry/common.c:67 [inline]
exit_to_user_mode_loop+0xed/0x480 kernel/entry/common.c:98
__exit_to_user_mode_prepare include/linux/irq-entry-common.h:226 [inline]
syscall_exit_to_user_mode_prepare include/linux/irq-entry-common.h:256 [inline]
syscall_exit_to_user_mode include/linux/entry-common.h:325 [inline]
do_syscall_64+0x33e/0xf80 arch/x86/entry/syscall_64.c:100
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f384cb9c819
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:00007ffea5f94ac8 EFLAGS: 00000246 ORIG_RAX: 00000000000001b4
RAX: 0000000000000000 RBX: 00007ffea5f94bb0 RCX: 00007f384cb9c819
RDX: 0000000000000000 RSI: 000000000000001e RDI: 0000000000000003
RBP: 000000000001ea55 R08: 0000000000000001 R09: 0000000000000000
R10: 0000001b30e20000 R11: 0000000000000246 R12: 00007ffea5f94bf0
R13: 00007f384ce1609c R14: 000000000001ea8b R15: 00007f384ce16090
</TASK>
Allocated by task 6494:
kasan_save_stack mm/kasan/common.c:57 [inline]
kasan_save_track+0x3e/0x80 mm/kasan/common.c:78
poison_kmalloc_redzone mm/kasan/common.c:398 [inline]
__kasan_kmalloc+0x93/0xb0 mm/kasan/common.c:415
kasan_kmalloc include/linux/kasan.h:263 [inline]
__kmalloc_cache_noprof+0x31c/0x660 mm/slub.c:5380
kmalloc_noprof include/linux/slab.h:950 [inline]
kzalloc_noprof include/linux/slab.h:1188 [inline]
__drm_gem_shmem_create+0xc4/0x2e0 drivers/gpu/drm/drm_gem_shmem_helper.c:130
drm_gem_shmem_create drivers/gpu/drm/drm_gem_shmem_helper.c:157 [inline]
drm_gem_shmem_create_with_handle drivers/gpu/drm/drm_gem_shmem_helper.c:460 [inline]
drm_gem_shmem_dumb_create+0x72/0x120 drivers/gpu/drm/drm_gem_shmem_helper.c:549
drm_mode_create_dumb drivers/gpu/drm/drm_dumb_buffers.c:227 [inline]
drm_mode_create_dumb_ioctl+0x2bd/0x340 drivers/gpu/drm/drm_dumb_buffers.c:236
drm_ioctl_kernel+0x2df/0x3b0 drivers/gpu/drm/drm_ioctl.c:804
drm_ioctl+0x6ba/0xb80 drivers/gpu/drm/drm_ioctl.c:901
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:597 [inline]
__se_sys_ioctl+0xfc/0x170 fs/ioctl.c:583
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x15f/0xf80 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Freed by task 6495:
kasan_save_stack mm/kasan/common.c:57 [inline]
kasan_save_track+0x3e/0x80 mm/kasan/common.c:78
kasan_save_free_info+0x46/0x50 mm/kasan/generic.c:584
poison_slab_object mm/kasan/common.c:253 [inline]
__kasan_slab_free+0x5c/0x80 mm/kasan/common.c:285
kasan_slab_free include/linux/kasan.h:235 [inline]
slab_free_hook mm/slub.c:2685 [inline]
slab_free mm/slub.c:6165 [inline]
kfree+0x1c1/0x630 mm/slub.c:6483
drm_gem_handle_delete+0x84/0xa0 drivers/gpu/drm/drm_gem.c:434
drm_ioctl_kernel+0x2df/0x3b0 drivers/gpu/drm/drm_ioctl.c:804
drm_ioctl+0x6ba/0xb80 drivers/gpu/drm/drm_ioctl.c:901
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:597 [inline]
__se_sys_ioctl+0xfc/0x170 fs/ioctl.c:583
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x15f/0xf80 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
The buggy address belongs to the object at ffff888058ae0000
which belongs to the cache kmalloc-1k of size 1024
The buggy address is located 648 bytes inside of
freed 1024-byte region [ffff888058ae0000, ffff888058ae0400)
The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0xffff888058ae1800 pfn:0x58ae0
head: order:3 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0xfff00000000240(workingset|head|node=0|zone=1|lastcpupid=0x7ff)
page_type: f5(slab)
raw: 00fff00000000240 ffff88813fea7dc0 ffffea0000a1de10 ffff88813fea6888
raw: ffff888058ae1800 0000000800100003 00000000f5000000 0000000000000000
head: 00fff00000000240 ffff88813fea7dc0 ffffea0000a1de10 ffff88813fea6888
head: ffff888058ae1800 0000000800100003 00000000f5000000 0000000000000000
head: 00fff00000000003 ffffea000162b801 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 0xd2820(GFP_ATOMIC|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 13, tgid 13 (kworker/u8:1), ts 125536208154, free_ts 123699282996
set_page_owner include/linux/page_owner.h:32 [inline]
post_alloc_hook+0x231/0x280 mm/page_alloc.c:1889
prep_new_page mm/page_alloc.c:1897 [inline]
get_page_from_freelist+0x24dc/0x2580 mm/page_alloc.c:3962
__alloc_frozen_pages_noprof+0x18d/0x380 mm/page_alloc.c:5250
alloc_slab_page mm/slub.c:3292 [inline]
allocate_slab+0x77/0x660 mm/slub.c:3481
new_slab mm/slub.c:3539 [inline]
refill_objects+0x331/0x3c0 mm/slub.c:7175
refill_sheaf mm/slub.c:2812 [inline]
__pcs_replace_empty_main+0x2e6/0x730 mm/slub.c:4615
alloc_from_pcs mm/slub.c:4717 [inline]
slab_alloc_node mm/slub.c:4851 [inline]
__do_kmalloc_node mm/slub.c:5259 [inline]
__kmalloc_noprof+0x474/0x760 mm/slub.c:5272
kmalloc_noprof include/linux/slab.h:954 [inline]
kzalloc_noprof include/linux/slab.h:1188 [inline]
ieee802_11_parse_elems_full+0x159/0x2ab0 net/mac80211/parse.c:1051
ieee802_11_parse_elems net/mac80211/ieee80211_i.h:2480 [inline]
ieee80211_inform_bss+0x161/0x1160 net/mac80211/scan.c:79
rdev_inform_bss net/wireless/rdev-ops.h:418 [inline]
cfg80211_inform_single_bss_data+0xd08/0x1b70 net/wireless/scan.c:2372
cfg80211_inform_bss_data+0x266/0x3c40 net/wireless/scan.c:3226
cfg80211_inform_bss_frame_data+0x3c7/0x760 net/wireless/scan.c:3317
ieee80211_bss_info_update+0x794/0xa40 net/mac80211/scan.c:230
ieee80211_rx_bss_info net/mac80211/ibss.c:1094 [inline]
ieee80211_rx_mgmt_probe_beacon net/mac80211/ibss.c:1575 [inline]
ieee80211_ibss_rx_queued_mgmt+0x1901/0x2cd0 net/mac80211/ibss.c:1602
ieee80211_iface_process_skb net/mac80211/iface.c:1748 [inline]
ieee80211_iface_work+0x84e/0x1340 net/mac80211/iface.c:1802
cfg80211_wiphy_work+0x2ab/0x4a0 net/wireless/core.c:440
page last free pid 6361 tgid 6361 stack trace:
reset_page_owner include/linux/page_owner.h:25 [inline]
__free_pages_prepare mm/page_alloc.c:1433 [inline]
__free_frozen_pages+0xc2b/0xdb0 mm/page_alloc.c:2978
__slab_free+0x263/0x2b0 mm/slub.c:5573
qlink_free mm/kasan/quarantine.c:163 [inline]
qlist_free_all+0x97/0x100 mm/kasan/quarantine.c:179
kasan_quarantine_reduce+0x148/0x160 mm/kasan/quarantine.c:286
__kasan_slab_alloc+0x22/0x80 mm/kasan/common.c:350
kasan_slab_alloc include/linux/kasan.h:253 [inline]
slab_post_alloc_hook mm/slub.c:4538 [inline]
slab_alloc_node mm/slub.c:4866 [inline]
__do_kmalloc_node mm/slub.c:5259 [inline]
__kmalloc_noprof+0x316/0x760 mm/slub.c:5272
kmalloc_noprof include/linux/slab.h:954 [inline]
kzalloc_noprof include/linux/slab.h:1188 [inline]
fib6_info_alloc+0x30/0xf0 net/ipv6/ip6_fib.c:155
ip6_route_info_create+0x142/0x860 net/ipv6/route.c:3818
ip6_route_add+0x49/0x1b0 net/ipv6/route.c:3947
addrconf_prefix_route+0x3a2/0x480 net/ipv6/addrconf.c:2487
add_v4_addrs+0x5a6/0x7e0 net/ipv6/addrconf.c:3264
addrconf_sit_config net/ipv6/addrconf.c:3520 [inline]
addrconf_init_auto_addrs+0x248/0xa50 net/ipv6/addrconf.c:3558
addrconf_notify+0xb1e/0x1050 net/ipv6/addrconf.c:3744
notifier_call_chain+0x1be/0x400 kernel/notifier.c:85
call_netdevice_notifiers_extack net/core/dev.c:2287 [inline]
call_netdevice_notifiers net/core/dev.c:2301 [inline]
__dev_notify_flags+0x1a9/0x310 net/core/dev.c:9820
netif_change_flags+0xe8/0x1a0 net/core/dev.c:9849
Memory state around the buggy address:
ffff888058ae0180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888058ae0200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888058ae0280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888058ae0300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888058ae0380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
Tested on:
commit: d60bc140 Merge tag 'pwrseq-updates-for-v7.1-rc1' of gi..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=13d304ce580000
kernel config: https://syzkaller.appspot.com/x/.config?x=85bd86f990609a1
dashboard link: https://syzkaller.appspot.com/bug?extid=b2e951687503f32f74ce
compiler: Debian clang version 21.1.8 (++20251221033036+2078da43e25a-1~exp1~20251221153213.50), Debian LLD 21.1.8
patch: https://syzkaller.appspot.com/x/patch.diff?x=11597b02580000
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [syzbot] [dri?] KASAN: slab-use-after-free Read in drm_gem_object_release_handle
2026-04-13 17:16 [syzbot] [dri?] KASAN: slab-use-after-free Read in drm_gem_object_release_handle syzbot
` (5 preceding siblings ...)
2026-04-14 10:03 ` Hillf Danton
@ 2026-04-15 0:33 ` Hillf Danton
2026-04-15 3:54 ` syzbot
2026-04-15 7:50 ` Hillf Danton
7 siblings, 1 reply; 16+ messages in thread
From: Hillf Danton @ 2026-04-15 0:33 UTC (permalink / raw)
To: syzbot; +Cc: linux-kernel, syzkaller-bugs
> Date: Mon, 13 Apr 2026 10:16:36 -0700 [thread overview]
> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit: f5459048c38a Merge tag 'i2c-for-7.0-final' of git://git.ke..
> git tree: upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=1028d106580000
> kernel config: https://syzkaller.appspot.com/x/.config?x=6754c86e8d9e4c91
> dashboard link: https://syzkaller.appspot.com/bug?extid=b2e951687503f32f74ce
> compiler: Debian clang version 21.1.8 (++20251221033036+2078da43e25a-1~exp1~20251221153213.50), Debian LLD 21.1.8
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1428d106580000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=17509036580000
#syz test
--- x/drivers/gpu/drm/drm_gem.c
+++ y/drivers/gpu/drm/drm_gem.c
@@ -404,7 +404,8 @@ drm_gem_handle_delete(struct drm_file *f
spin_lock(&filp->table_lock);
/* Check if we currently have a reference on the object */
- obj = idr_replace(&filp->object_idr, NULL, handle);
+ obj = idr_find(&filp->object_idr, handle);
+ idr_remove(&filp->object_idr, handle);
spin_unlock(&filp->table_lock);
if (IS_ERR_OR_NULL(obj))
return -EINVAL;
@@ -412,11 +413,6 @@ drm_gem_handle_delete(struct drm_file *f
/* Release driver's reference and decrement refcount. */
drm_gem_object_release_handle(handle, obj, filp);
- /* And finally make the handle available for future allocations. */
- spin_lock(&filp->table_lock);
- idr_remove(&filp->object_idr, handle);
- spin_unlock(&filp->table_lock);
-
return 0;
}
EXPORT_SYMBOL(drm_gem_handle_delete);
@@ -1085,8 +1081,20 @@ drm_gem_open(struct drm_device *dev, str
void
drm_gem_release(struct drm_device *dev, struct drm_file *file_private)
{
- idr_for_each(&file_private->object_idr,
- &drm_gem_object_release_handle, file_private);
+ struct drm_gem_object *obj;
+ int id;
+
+ for (;;) {
+ id = 0;
+ spin_lock(&file_private->table_lock);
+ obj = idr_get_next(&file_private->object_idr, &id);
+ if (obj)
+ idr_remove(&file_private->object_idr, id);
+ spin_unlock(&file_private->table_lock);
+ if (!obj)
+ break;
+ drm_gem_object_release_handle(id, obj, file_private);
+ }
idr_destroy(&file_private->object_idr);
}
--
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [syzbot] [dri?] KASAN: slab-use-after-free Read in drm_gem_object_release_handle
2026-04-15 0:33 ` Hillf Danton
@ 2026-04-15 3:54 ` syzbot
0 siblings, 0 replies; 16+ messages in thread
From: syzbot @ 2026-04-15 3:54 UTC (permalink / raw)
To: hdanton, linux-kernel, syzkaller-bugs
Hello,
syzbot has tested the proposed patch but the reproducer is still triggering an issue:
KASAN: slab-use-after-free Read in drm_gem_object_release_handle
==================================================================
BUG: KASAN: slab-use-after-free in drm_gem_object_release_handle+0x47/0x1e0 drivers/gpu/drm/drm_gem.c:374
Read of size 8 at addr ffff88802868ba78 by task syz.4.82/6783
CPU: 0 UID: 0 PID: 6783 Comm: syz.4.82 Not tainted syzkaller #0 PREEMPT(full)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/18/2026
Call Trace:
<TASK>
dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120
print_address_description mm/kasan/report.c:378 [inline]
print_report+0xba/0x230 mm/kasan/report.c:482
kasan_report+0x117/0x150 mm/kasan/report.c:595
drm_gem_object_release_handle+0x47/0x1e0 drivers/gpu/drm/drm_gem.c:374
drm_gem_release+0xd2/0x170 drivers/gpu/drm/drm_gem.c:1096
drm_file_free+0x729/0xa00 drivers/gpu/drm/drm_file.c:261
drm_close_helper drivers/gpu/drm/drm_file.c:290 [inline]
drm_release+0x2de/0x3f0 drivers/gpu/drm/drm_file.c:438
__fput+0x44f/0xa60 fs/file_table.c:510
task_work_run+0x1d9/0x270 kernel/task_work.c:233
resume_user_mode_work include/linux/resume_user_mode.h:50 [inline]
__exit_to_user_mode_loop kernel/entry/common.c:67 [inline]
exit_to_user_mode_loop+0xed/0x480 kernel/entry/common.c:98
__exit_to_user_mode_prepare include/linux/irq-entry-common.h:207 [inline]
syscall_exit_to_user_mode_prepare include/linux/irq-entry-common.h:238 [inline]
syscall_exit_to_user_mode include/linux/entry-common.h:328 [inline]
do_syscall_64+0x33e/0xf80 arch/x86/entry/syscall_64.c:100
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f7a5259c819
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:00007fff2b485db8 EFLAGS: 00000246 ORIG_RAX: 00000000000001b4
RAX: 0000000000000000 RBX: 00007f7a52817da0 RCX: 00007f7a5259c819
RDX: 0000000000000000 RSI: 000000000000001e RDI: 0000000000000003
RBP: 00007f7a52817da0 R08: 00007f7a52816038 R09: 0000000000000000
R10: 000000000003fdc0 R11: 0000000000000246 R12: 000000000002456b
R13: 00007f7a5281609c R14: 000000000002426f R15: 00007f7a52816090
</TASK>
Allocated by task 6785:
kasan_save_stack mm/kasan/common.c:57 [inline]
kasan_save_track+0x3e/0x80 mm/kasan/common.c:78
poison_kmalloc_redzone mm/kasan/common.c:398 [inline]
__kasan_kmalloc+0x93/0xb0 mm/kasan/common.c:415
kasan_kmalloc include/linux/kasan.h:263 [inline]
__kmalloc_cache_noprof+0x31c/0x660 mm/slub.c:5380
kmalloc_noprof include/linux/slab.h:950 [inline]
kzalloc_noprof include/linux/slab.h:1188 [inline]
__drm_gem_shmem_create+0xc4/0x2e0 drivers/gpu/drm/drm_gem_shmem_helper.c:130
drm_gem_shmem_create drivers/gpu/drm/drm_gem_shmem_helper.c:157 [inline]
drm_gem_shmem_create_with_handle drivers/gpu/drm/drm_gem_shmem_helper.c:460 [inline]
drm_gem_shmem_dumb_create+0x72/0x120 drivers/gpu/drm/drm_gem_shmem_helper.c:549
drm_mode_create_dumb drivers/gpu/drm/drm_dumb_buffers.c:227 [inline]
drm_mode_create_dumb_ioctl+0x2bd/0x340 drivers/gpu/drm/drm_dumb_buffers.c:236
drm_ioctl_kernel+0x2df/0x3b0 drivers/gpu/drm/drm_ioctl.c:804
drm_ioctl+0x6ba/0xb80 drivers/gpu/drm/drm_ioctl.c:901
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:597 [inline]
__se_sys_ioctl+0xfc/0x170 fs/ioctl.c:583
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x15f/0xf80 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Freed by task 6785:
kasan_save_stack mm/kasan/common.c:57 [inline]
kasan_save_track+0x3e/0x80 mm/kasan/common.c:78
kasan_save_free_info+0x46/0x50 mm/kasan/generic.c:584
poison_slab_object mm/kasan/common.c:253 [inline]
__kasan_slab_free+0x5c/0x80 mm/kasan/common.c:285
kasan_slab_free include/linux/kasan.h:235 [inline]
slab_free_hook mm/slub.c:2685 [inline]
slab_free mm/slub.c:6165 [inline]
kfree+0x1c1/0x620 mm/slub.c:6483
drm_gem_object_free drivers/gpu/drm/drm_gem.c:1138 [inline]
kref_put include/linux/kref.h:65 [inline]
__drm_gem_object_put include/drm/drm_gem.h:565 [inline]
drm_gem_object_put include/drm/drm_gem.h:578 [inline]
drm_gem_change_handle_ioctl+0x392/0x4d0 drivers/gpu/drm/drm_gem.c:1052
drm_ioctl_kernel+0x2df/0x3b0 drivers/gpu/drm/drm_ioctl.c:804
drm_ioctl+0x6ba/0xb80 drivers/gpu/drm/drm_ioctl.c:901
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:597 [inline]
__se_sys_ioctl+0xfc/0x170 fs/ioctl.c:583
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x15f/0xf80 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
The buggy address belongs to the object at ffff88802868b800
which belongs to the cache kmalloc-1k of size 1024
The buggy address is located 632 bytes inside of
freed 1024-byte region [ffff88802868b800, ffff88802868bc00)
The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x28688
head: order:3 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0xfff00000000040(head|node=0|zone=1|lastcpupid=0x7ff)
page_type: f5(slab)
raw: 00fff00000000040 ffff88813fe2cdc0 dead000000000100 dead000000000122
raw: 0000000000000000 0000000800100010 00000000f5000000 0000000000000000
head: 00fff00000000040 ffff88813fe2cdc0 dead000000000100 dead000000000122
head: 0000000000000000 0000000800100010 00000000f5000000 0000000000000000
head: 00fff00000000003 ffffea0000a1a201 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 0xd2000(__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 69, tgid 69 (kworker/u8:4), ts 7935238695, free_ts 0
set_page_owner include/linux/page_owner.h:32 [inline]
post_alloc_hook+0x231/0x280 mm/page_alloc.c:1889
prep_new_page mm/page_alloc.c:1897 [inline]
get_page_from_freelist+0x24dc/0x2580 mm/page_alloc.c:3962
__alloc_frozen_pages_noprof+0x18d/0x380 mm/page_alloc.c:5250
alloc_slab_page mm/slub.c:3292 [inline]
allocate_slab+0x77/0x660 mm/slub.c:3481
new_slab mm/slub.c:3539 [inline]
refill_objects+0x331/0x3c0 mm/slub.c:7175
refill_sheaf mm/slub.c:2812 [inline]
__pcs_replace_empty_main+0x2e6/0x730 mm/slub.c:4615
alloc_from_pcs mm/slub.c:4717 [inline]
slab_alloc_node mm/slub.c:4851 [inline]
__do_kmalloc_node mm/slub.c:5259 [inline]
__kmalloc_node_noprof+0x577/0x7c0 mm/slub.c:5266
kmalloc_node_noprof include/linux/slab.h:1081 [inline]
blk_alloc_flush_queue+0xe2/0x230 block/blk-flush.c:492
blk_mq_init_hctx block/blk-mq.c:4019 [inline]
blk_mq_alloc_and_init_hctx+0x79e/0xc50 block/blk-mq.c:4558
__blk_mq_realloc_hw_ctxs+0x2bd/0x670 block/blk-mq.c:4605
blk_mq_realloc_hw_ctxs block/blk-mq.c:4642 [inline]
blk_mq_init_allocated_queue+0x365/0x13e0 block/blk-mq.c:4672
blk_mq_alloc_queue+0x1ba/0x2e0 block/blk-mq.c:4454
scsi_alloc_sdev+0x7c0/0xc80 drivers/scsi/scsi_scan.c:339
scsi_probe_and_add_lun+0x200/0x4830 drivers/scsi/scsi_scan.c:1215
__scsi_scan_target+0x1f0/0xe10 drivers/scsi/scsi_scan.c:1786
scsi_scan_channel drivers/scsi/scsi_scan.c:1874 [inline]
scsi_scan_host_selected+0x372/0x690 drivers/scsi/scsi_scan.c:1903
page_owner free stack trace missing
Memory state around the buggy address:
ffff88802868b900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88802868b980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88802868ba00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88802868ba80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88802868bb00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
Tested on:
commit: 91a4855d Merge tag 'net-next-7.1' of git://git.kernel...
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=1079fb02580000
kernel config: https://syzkaller.appspot.com/x/.config?x=95729ed00549063a
dashboard link: https://syzkaller.appspot.com/bug?extid=b2e951687503f32f74ce
compiler: Debian clang version 21.1.8 (++20251221033036+2078da43e25a-1~exp1~20251221153213.50), Debian LLD 21.1.8
patch: https://syzkaller.appspot.com/x/patch.diff?x=112238ce580000
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [syzbot] [dri?] KASAN: slab-use-after-free Read in drm_gem_object_release_handle
2026-04-13 17:16 [syzbot] [dri?] KASAN: slab-use-after-free Read in drm_gem_object_release_handle syzbot
` (6 preceding siblings ...)
2026-04-15 0:33 ` Hillf Danton
@ 2026-04-15 7:50 ` Hillf Danton
7 siblings, 0 replies; 16+ messages in thread
From: Hillf Danton @ 2026-04-15 7:50 UTC (permalink / raw)
To: syzbot; +Cc: linux-kernel, syzkaller-bugs
> Date: Mon, 13 Apr 2026 10:16:36 -0700 [thread overview]
> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit: f5459048c38a Merge tag 'i2c-for-7.0-final' of git://git.ke..
> git tree: upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=1028d106580000
> kernel config: https://syzkaller.appspot.com/x/.config?x=6754c86e8d9e4c91
> dashboard link: https://syzkaller.appspot.com/bug?extid=b2e951687503f32f74ce
> compiler: Debian clang version 21.1.8 (++20251221033036+2078da43e25a-1~exp1~20251221153213.50), Debian LLD 21.1.8
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1428d106580000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=17509036580000
#syz test
--- x/drivers/gpu/drm/drm_gem.c
+++ y/drivers/gpu/drm/drm_gem.c
@@ -404,7 +404,8 @@ drm_gem_handle_delete(struct drm_file *f
spin_lock(&filp->table_lock);
/* Check if we currently have a reference on the object */
- obj = idr_replace(&filp->object_idr, NULL, handle);
+ obj = idr_find(&filp->object_idr, handle);
+ idr_remove(&filp->object_idr, handle);
spin_unlock(&filp->table_lock);
if (IS_ERR_OR_NULL(obj))
return -EINVAL;
@@ -412,11 +413,6 @@ drm_gem_handle_delete(struct drm_file *f
/* Release driver's reference and decrement refcount. */
drm_gem_object_release_handle(handle, obj, filp);
- /* And finally make the handle available for future allocations. */
- spin_lock(&filp->table_lock);
- idr_remove(&filp->object_idr, handle);
- spin_unlock(&filp->table_lock);
-
return 0;
}
EXPORT_SYMBOL(drm_gem_handle_delete);
@@ -1085,9 +1081,23 @@ drm_gem_open(struct drm_device *dev, str
void
drm_gem_release(struct drm_device *dev, struct drm_file *file_private)
{
- idr_for_each(&file_private->object_idr,
- &drm_gem_object_release_handle, file_private);
+ struct drm_gem_object *obj;
+ int id;
+
+ mutex_lock(&file_private->prime.lock);
+ for (;;) {
+ id = 0;
+ spin_lock(&file_private->table_lock);
+ obj = idr_get_next(&file_private->object_idr, &id);
+ if (obj)
+ idr_remove(&file_private->object_idr, id);
+ spin_unlock(&file_private->table_lock);
+ if (!obj)
+ break;
+ drm_gem_object_release_handle(id, obj, file_private);
+ }
idr_destroy(&file_private->object_idr);
+ mutex_unlock(&file_private->prime.lock);
}
/**
--
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2026-04-15 7:52 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-13 17:16 [syzbot] [dri?] KASAN: slab-use-after-free Read in drm_gem_object_release_handle syzbot
2026-04-14 0:16 ` Forwarded: [PATCH] drm/gem: fix use-after-free in drm_gem_release syzbot
2026-04-14 1:32 ` syzbot
2026-04-14 5:00 ` [syzbot] [dri?] KASAN: slab-use-after-free Read in drm_gem_object_release_handle Hillf Danton
2026-04-14 5:26 ` syzbot
2026-04-14 5:49 ` Forwarded: [PATCH] drm/gem: fix use-after-free in drm_gem_release syzbot
2026-04-14 8:46 ` [syzbot] [dri?] KASAN: slab-use-after-free Read in drm_gem_object_release_handle Hillf Danton
2026-04-14 9:04 ` syzbot
2026-04-14 10:03 ` Hillf Danton
2026-04-14 10:20 ` syzbot
2026-04-15 0:33 ` Hillf Danton
2026-04-15 3:54 ` syzbot
2026-04-15 7:50 ` Hillf Danton
[not found] <20260414001626.60471-1-kartikey406@gmail.com>
2026-04-14 0:36 ` syzbot
[not found] <20260414013225.64095-1-kartikey406@gmail.com>
2026-04-14 1:50 ` syzbot
[not found] <20260414054951.69728-1-kartikey406@gmail.com>
2026-04-14 6:22 ` syzbot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox