* [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
` (12 more replies)
0 siblings, 13 replies; 23+ 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] 23+ 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
` (11 subsequent siblings)
12 siblings, 0 replies; 23+ 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] 23+ 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
` (10 subsequent siblings)
12 siblings, 0 replies; 23+ 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] 23+ 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
` (9 subsequent siblings)
12 siblings, 1 reply; 23+ 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] 23+ 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; 23+ 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] 23+ 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
` (8 subsequent siblings)
12 siblings, 0 replies; 23+ 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] 23+ 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
` (7 subsequent siblings)
12 siblings, 1 reply; 23+ 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] 23+ 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; 23+ 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] 23+ 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
` (6 subsequent siblings)
12 siblings, 1 reply; 23+ 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] 23+ 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; 23+ 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] 23+ 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
` (5 subsequent siblings)
12 siblings, 1 reply; 23+ 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] 23+ 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; 23+ 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] 23+ 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
2026-04-15 8:50 ` syzbot
2026-04-15 11:19 ` Hillf Danton
` (4 subsequent siblings)
12 siblings, 1 reply; 23+ 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] 23+ messages in thread
* Re: [syzbot] [dri?] KASAN: slab-use-after-free Read in drm_gem_object_release_handle
2026-04-15 7:50 ` Hillf Danton
@ 2026-04-15 8:50 ` syzbot
0 siblings, 0 replies; 23+ messages in thread
From: syzbot @ 2026-04-15 8:50 UTC (permalink / raw)
To: hdanton, linux-kernel, syzkaller-bugs
Hello,
syzbot has tested the proposed patch but the reproducer is still triggering an issue:
possible deadlock in drm_gem_object_release_handle
============================================
WARNING: possible recursive locking detected
syzkaller #0 Not tainted
--------------------------------------------
syz.2.19/6521 is trying to acquire lock:
ffff88801d349388 (&prime_fpriv->lock){+.+.}-{4:4}, at: drm_gem_object_release_handle+0x98/0x1e0 drivers/gpu/drm/drm_gem.c:377
but task is already holding lock:
ffff88801d349388 (&prime_fpriv->lock){+.+.}-{4:4}, at: drm_gem_release+0x90/0x190 drivers/gpu/drm/drm_gem.c:1087
other info that might help us debug this:
Possible unsafe locking scenario:
CPU0
----
lock(&prime_fpriv->lock);
lock(&prime_fpriv->lock);
*** DEADLOCK ***
May be due to missing lock nesting notation
1 lock held by syz.2.19/6521:
#0: ffff88801d349388 (&prime_fpriv->lock){+.+.}-{4:4}, at: drm_gem_release+0x90/0x190 drivers/gpu/drm/drm_gem.c:1087
stack backtrace:
CPU: 1 UID: 0 PID: 6521 Comm: syz.2.19 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_deadlock_bug+0x279/0x290 kernel/locking/lockdep.c:3041
check_deadlock kernel/locking/lockdep.c:3093 [inline]
validate_chain kernel/locking/lockdep.c:3895 [inline]
__lock_acquire+0x253f/0x2cf0 kernel/locking/lockdep.c:5237
lock_acquire+0x106/0x350 kernel/locking/lockdep.c:5868
__mutex_lock_common kernel/locking/mutex.c:632 [inline]
__mutex_lock+0x1a3/0x1550 kernel/locking/mutex.c:806
drm_gem_object_release_handle+0x98/0x1e0 drivers/gpu/drm/drm_gem.c:377
drm_gem_release+0xe5/0x190 drivers/gpu/drm/drm_gem.c:1097
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:0x7f141259c819
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:00007ffcebeea6c8 EFLAGS: 00000246 ORIG_RAX: 00000000000001b4
RAX: 0000000000000000 RBX: 00007ffcebeea7b0 RCX: 00007f141259c819
RDX: 0000000000000000 RSI: 000000000000001e RDI: 0000000000000003
RBP: 000000000001fd63 R08: 0000000000000001 R09: 0000000000000000
R10: 0000001b31120000 R11: 0000000000000246 R12: 00007ffcebeea7f0
R13: 00007f141281609c R14: 000000000001fdc6 R15: 00007f1412816090
</TASK>
Tested on:
commit: 1f5ffc67 Fix mismerge of the arm64 / timer-core interr..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=145ebb16580000
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=150dfcd2580000
^ permalink raw reply [flat|nested] 23+ 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
` (7 preceding siblings ...)
2026-04-15 7:50 ` Hillf Danton
@ 2026-04-15 11:19 ` Hillf Danton
2026-04-15 11:44 ` syzbot
2026-04-16 0:44 ` Hillf Danton
` (3 subsequent siblings)
12 siblings, 1 reply; 23+ messages in thread
From: Hillf Danton @ 2026-04-15 11:19 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,22 @@ 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;
+ mutex_lock(&file_private->prime.lock);
+ 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);
+ mutex_unlock(&file_private->prime.lock);
+ if (!obj)
+ break;
+ drm_gem_object_release_handle(id, obj, file_private);
+ }
idr_destroy(&file_private->object_idr);
}
--
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [syzbot] [dri?] KASAN: slab-use-after-free Read in drm_gem_object_release_handle
2026-04-15 11:19 ` Hillf Danton
@ 2026-04-15 11:44 ` syzbot
0 siblings, 0 replies; 23+ messages in thread
From: syzbot @ 2026-04-15 11:44 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 ffff88802afb9278 by task syz.1.182/7005
CPU: 1 UID: 0 PID: 7005 Comm: syz.1.182 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+0xe8/0x190 drivers/gpu/drm/drm_gem.c:1098
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:0x7faf5959c819
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:00007ffdb67de818 EFLAGS: 00000246 ORIG_RAX: 00000000000001b4
RAX: 0000000000000000 RBX: 00007ffdb67de900 RCX: 00007faf5959c819
RDX: 0000000000000000 RSI: 000000000000001e RDI: 0000000000000003
RBP: 000000000001ff8e R08: 0000000000000001 R09: 0000000000000000
R10: 0000001b2c220000 R11: 0000000000000246 R12: 00007ffdb67de940
R13: 00007faf5981609c R14: 000000000001ffcf R15: 00007faf59816090
</TASK>
Allocated by task 7007:
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 7008:
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_handle_delete+0x84/0xa0 drivers/gpu/drm/drm_gem.c:414
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 ffff88802afb9000
which belongs to the cache kmalloc-1k of size 1024
The buggy address is located 632 bytes inside of
freed 1024-byte region [ffff88802afb9000, ffff88802afb9400)
The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x2afb8
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 ffffea0000abee01 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 12, tgid 12 (kworker/u8:0), ts 131001296136, free_ts 130963840270
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:2518 [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+0xcf9/0x1af0 net/wireless/scan.c:2372
cfg80211_inform_bss_data+0x266/0x3c40 net/wireless/scan.c:3226
cfg80211_inform_bss_frame_data+0x3c7/0x730 net/wireless/scan.c:3317
ieee80211_bss_info_update+0x794/0xa40 net/mac80211/scan.c:230
ieee80211_rx_bss_info net/mac80211/ibss.c:1088 [inline]
ieee80211_rx_mgmt_probe_beacon net/mac80211/ibss.c:1569 [inline]
ieee80211_ibss_rx_queued_mgmt+0x1901/0x2cb0 net/mac80211/ibss.c:1596
ieee80211_iface_process_skb net/mac80211/iface.c:1795 [inline]
ieee80211_iface_work+0x845/0x1380 net/mac80211/iface.c:1849
cfg80211_wiphy_work+0x2cf/0x460 net/wireless/core.c:513
page last free pid 6998 tgid 6998 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]
tomoyo_encode2 security/tomoyo/realpath.c:45 [inline]
tomoyo_encode+0x28b/0x550 security/tomoyo/realpath.c:80
tomoyo_path_perm+0x318/0x560 security/tomoyo/file.c:836
tomoyo_path_symlink+0xab/0xf0 security/tomoyo/tomoyo.c:212
security_path_symlink+0x16f/0x360 security/security.c:1502
filename_symlinkat+0x134/0x410 fs/namei.c:5666
__do_sys_symlinkat fs/namei.c:5688 [inline]
__se_sys_symlinkat+0x4e/0x2b0 fs/namei.c:5683
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:
ffff88802afb9100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88802afb9180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88802afb9200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88802afb9280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88802afb9300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
Tested on:
commit: 1f5ffc67 Fix mismerge of the arm64 / timer-core interr..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=13a4e906580000
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=143538ce580000
^ permalink raw reply [flat|nested] 23+ 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
` (8 preceding siblings ...)
2026-04-15 11:19 ` Hillf Danton
@ 2026-04-16 0:44 ` Hillf Danton
2026-04-16 4:52 ` syzbot
2026-04-16 2:59 ` Edward Adam Davis
` (2 subsequent siblings)
12 siblings, 1 reply; 23+ messages in thread
From: Hillf Danton @ 2026-04-16 0:44 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
@@ -401,22 +401,20 @@ drm_gem_handle_delete(struct drm_file *f
{
struct drm_gem_object *obj;
+ mutex_lock(&filp->prime.lock);
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);
+ mutex_unlock(&filp->prime.lock);
+
if (IS_ERR_OR_NULL(obj))
return -EINVAL;
-
/* 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 +1083,22 @@ 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;
+ mutex_lock(&file_private->prime.lock);
+ 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);
+ mutex_unlock(&file_private->prime.lock);
+ if (!obj)
+ break;
+ drm_gem_object_release_handle(id, obj, file_private);
+ }
idr_destroy(&file_private->object_idr);
}
--
^ permalink raw reply [flat|nested] 23+ 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
` (9 preceding siblings ...)
2026-04-16 0:44 ` Hillf Danton
@ 2026-04-16 2:59 ` Edward Adam Davis
2026-04-16 5:13 ` syzbot
2026-04-16 8:19 ` Hillf Danton
2026-04-16 8:57 ` [PATCH] drm: Avoid the chaotic interleaving of change and delete handle Edward Adam Davis
12 siblings, 1 reply; 23+ messages in thread
From: Edward Adam Davis @ 2026-04-16 2:59 UTC (permalink / raw)
To: syzbot+b2e951687503f32f74ce; +Cc: linux-kernel, syzkaller-bugs
#syz test
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index 891c3bff5ae0..63a8d7e980b5 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -374,14 +374,8 @@ drm_gem_object_release_handle(int id, void *ptr, void *data)
if (obj->funcs->close)
obj->funcs->close(obj, file_priv);
- mutex_lock(&file_priv->prime.lock);
-
drm_prime_remove_buf_handle(&file_priv->prime, id);
-
- mutex_unlock(&file_priv->prime.lock);
-
drm_vma_node_revoke(&obj->vma_node, file_priv);
-
drm_gem_object_handle_put_unlocked(obj);
return 0;
@@ -401,13 +395,16 @@ drm_gem_handle_delete(struct drm_file *filp, u32 handle)
{
struct drm_gem_object *obj;
+ mutex_lock(&filp->prime.lock);
spin_lock(&filp->table_lock);
/* Check if we currently have a reference on the object */
obj = idr_replace(&filp->object_idr, NULL, handle);
spin_unlock(&filp->table_lock);
- if (IS_ERR_OR_NULL(obj))
+ if (IS_ERR_OR_NULL(obj)) {
+ mutex_unlock(&filp->prime.lock);
return -EINVAL;
+ }
/* Release driver's reference and decrement refcount. */
drm_gem_object_release_handle(handle, obj, filp);
@@ -416,6 +413,7 @@ drm_gem_handle_delete(struct drm_file *filp, u32 handle)
spin_lock(&filp->table_lock);
idr_remove(&filp->object_idr, handle);
spin_unlock(&filp->table_lock);
+ mutex_unlock(&filp->prime.lock);
return 0;
}
@@ -1012,17 +1010,18 @@ int drm_gem_change_handle_ioctl(struct drm_device *dev, void *data,
return -EINVAL;
handle = args->new_handle;
+ mutex_lock(&file_priv->prime.lock);
obj = drm_gem_object_lookup(file_priv, args->handle);
- if (!obj)
+ if (!obj) {
+ mutex_unlock(&file_priv->prime.lock);
return -ENOENT;
+ }
if (args->handle == handle) {
ret = 0;
- goto out;
+ goto out_unlock;
}
- mutex_lock(&file_priv->prime.lock);
-
spin_lock(&file_priv->table_lock);
ret = idr_alloc(&file_priv->object_idr, obj, handle, handle + 1,
GFP_NOWAIT);
@@ -1051,9 +1050,8 @@ int drm_gem_change_handle_ioctl(struct drm_device *dev, void *data,
spin_unlock(&file_priv->table_lock);
out_unlock:
- mutex_unlock(&file_priv->prime.lock);
-out:
drm_gem_object_put(obj);
+ mutex_unlock(&file_priv->prime.lock);
return ret;
}
@@ -1085,8 +1083,10 @@ 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)
{
+ mutex_lock(&file_private->prime.lock);
idr_for_each(&file_private->object_idr,
&drm_gem_object_release_handle, file_private);
+ mutex_unlock(&file_private->prime.lock);
idr_destroy(&file_private->object_idr);
}
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [syzbot] [dri?] KASAN: slab-use-after-free Read in drm_gem_object_release_handle
2026-04-16 0:44 ` Hillf Danton
@ 2026-04-16 4:52 ` syzbot
0 siblings, 0 replies; 23+ messages in thread
From: syzbot @ 2026-04-16 4:52 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 ffff888035e4c278 by task syz.1.169/7028
CPU: 1 UID: 0 PID: 7028 Comm: syz.1.169 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+0x55/0x1e0 mm/kasan/report.c:378
print_report+0x58/0x70 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+0xe8/0x190 drivers/gpu/drm/drm_gem.c:1118
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:0x7f4a7e79c819
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:00007ffd28753448 EFLAGS: 00000246 ORIG_RAX: 00000000000001b4
RAX: 0000000000000000 RBX: 00007ffd28753530 RCX: 00007f4a7e79c819
RDX: 0000000000000000 RSI: 000000000000001e RDI: 0000000000000003
RBP: 000000000001f80f R08: 0000000000000001 R09: 0000000000000000
R10: 0000001b30a20000 R11: 0000000000000246 R12: 00007ffd28753570
R13: 00007f4a7ea1609c R14: 000000000001f863 R15: 00007f4a7ea16090
</TASK>
Allocated by task 7032:
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:5415
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:464 [inline]
drm_gem_shmem_dumb_create+0x72/0x120 drivers/gpu/drm/drm_gem_shmem_helper.c:553
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 7033:
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:2689 [inline]
slab_free mm/slub.c:6246 [inline]
kfree+0x1c5/0x640 mm/slub.c:6561
drm_gem_handle_delete+0xa3/0xc0 drivers/gpu/drm/drm_gem.c:416
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 ffff888035e4c000
which belongs to the cache kmalloc-1k of size 1024
The buggy address is located 632 bytes inside of
freed 1024-byte region [ffff888035e4c000, ffff888035e4c400)
The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x35e48
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 ffff88813fe29dc0 dead000000000100 dead000000000122
raw: 0000000000000000 0000000800100010 00000000f5000000 0000000000000000
head: 00fff00000000040 ffff88813fe29dc0 dead000000000100 dead000000000122
head: 0000000000000000 0000000800100010 00000000f5000000 0000000000000000
head: 00fff00000000003 fffffffffffffe01 00000000ffffffff 00000000ffffffff
head: ffffffffffffffff 0000000000000000 00000000ffffffff 0000000000000008
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask 0xd2820(GFP_ATOMIC|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 129, tgid 129 (kworker/u8:6), ts 129037001160, free_ts 129034880394
set_page_owner include/linux/page_owner.h:32 [inline]
post_alloc_hook+0x231/0x280 mm/page_alloc.c:1860
prep_new_page mm/page_alloc.c:1868 [inline]
get_page_from_freelist+0x24ba/0x2540 mm/page_alloc.c:3948
__alloc_frozen_pages_noprof+0x18d/0x380 mm/page_alloc.c:5228
alloc_slab_page mm/slub.c:3278 [inline]
allocate_slab+0x77/0x660 mm/slub.c:3467
new_slab mm/slub.c:3525 [inline]
refill_objects+0x339/0x3d0 mm/slub.c:7251
refill_sheaf mm/slub.c:2816 [inline]
__pcs_replace_empty_main+0x321/0x720 mm/slub.c:4651
alloc_from_pcs mm/slub.c:4749 [inline]
slab_alloc_node mm/slub.c:4883 [inline]
__do_kmalloc_node mm/slub.c:5294 [inline]
__kmalloc_noprof+0x474/0x760 mm/slub.c:5307
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:2518 [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+0xcf9/0x1af0 net/wireless/scan.c:2372
cfg80211_inform_bss_data+0x266/0x3c40 net/wireless/scan.c:3226
cfg80211_inform_bss_frame_data+0x3c7/0x730 net/wireless/scan.c:3317
ieee80211_bss_info_update+0x794/0xa40 net/mac80211/scan.c:230
ieee80211_rx_bss_info net/mac80211/ibss.c:1088 [inline]
ieee80211_rx_mgmt_probe_beacon net/mac80211/ibss.c:1569 [inline]
ieee80211_ibss_rx_queued_mgmt+0x1901/0x2cb0 net/mac80211/ibss.c:1596
ieee80211_iface_process_skb net/mac80211/iface.c:1795 [inline]
ieee80211_iface_work+0x845/0x1380 net/mac80211/iface.c:1849
cfg80211_wiphy_work+0x2cf/0x460 net/wireless/core.c:513
page last free pid 7008 tgid 7008 stack trace:
reset_page_owner include/linux/page_owner.h:25 [inline]
__free_pages_prepare mm/page_alloc.c:1404 [inline]
__free_frozen_pages+0xbc7/0xd30 mm/page_alloc.c:2945
__slab_free+0x274/0x2c0 mm/slub.c:5608
qlink_free mm/kasan/quarantine.c:163 [inline]
qlist_free_all+0x99/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:4569 [inline]
slab_alloc_node mm/slub.c:4898 [inline]
kmem_cache_alloc_noprof+0x2bc/0x650 mm/slub.c:4905
alloc_filename fs/namei.c:142 [inline]
do_getname+0x2e/0x250 fs/namei.c:182
getname include/linux/fs.h:2533 [inline]
getname_maybe_null include/linux/fs.h:2540 [inline]
class_filename_maybe_null_constructor include/linux/fs.h:2564 [inline]
vfs_fstatat+0x45/0x170 fs/stat.c:368
__do_sys_newfstatat fs/stat.c:538 [inline]
__se_sys_newfstatat fs/stat.c:532 [inline]
__x64_sys_newfstatat+0x151/0x200 fs/stat.c:532
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:
ffff888035e4c100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888035e4c180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888035e4c200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888035e4c280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888035e4c300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
Tested on:
commit: 1d51b370 Merge tag 'jfs-7.1' of github.com:kleikamp/li..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=125881ba580000
kernel config: https://syzkaller.appspot.com/x/.config?x=769ed9499e4e3d7d
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=17f344ce580000
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [syzbot] [dri?] KASAN: slab-use-after-free Read in drm_gem_object_release_handle
2026-04-16 2:59 ` Edward Adam Davis
@ 2026-04-16 5:13 ` syzbot
0 siblings, 0 replies; 23+ messages in thread
From: syzbot @ 2026-04-16 5:13 UTC (permalink / raw)
To: eadavis, linux-kernel, syzkaller-bugs
Hello,
syzbot has tested the proposed patch and the reproducer did not trigger any issue:
Reported-by: syzbot+b2e951687503f32f74ce@syzkaller.appspotmail.com
Tested-by: syzbot+b2e951687503f32f74ce@syzkaller.appspotmail.com
Tested on:
commit: 1d51b370 Merge tag 'jfs-7.1' of github.com:kleikamp/li..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=157881ba580000
kernel config: https://syzkaller.appspot.com/x/.config?x=769ed9499e4e3d7d
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=16181a6a580000
Note: testing is done by a robot and is best-effort only.
^ permalink raw reply [flat|nested] 23+ 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
` (10 preceding siblings ...)
2026-04-16 2:59 ` Edward Adam Davis
@ 2026-04-16 8:19 ` Hillf Danton
2026-04-16 9:03 ` syzbot
2026-04-16 8:57 ` [PATCH] drm: Avoid the chaotic interleaving of change and delete handle Edward Adam Davis
12 siblings, 1 reply; 23+ messages in thread
From: Hillf Danton @ 2026-04-16 8:19 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
@@ -401,22 +401,20 @@ drm_gem_handle_delete(struct drm_file *f
{
struct drm_gem_object *obj;
+ mutex_lock(&filp->prime.lock);
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);
+ mutex_unlock(&filp->prime.lock);
+
if (IS_ERR_OR_NULL(obj))
return -EINVAL;
-
/* 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);
@@ -1012,17 +1010,20 @@ int drm_gem_change_handle_ioctl(struct d
return -EINVAL;
handle = args->new_handle;
+ mutex_lock(&file_priv->prime.lock);
+
obj = drm_gem_object_lookup(file_priv, args->handle);
- if (!obj)
+ if (!obj) {
+ mutex_unlock(&file_priv->prime.lock);
return -ENOENT;
+ }
if (args->handle == handle) {
+ mutex_unlock(&file_priv->prime.lock);
ret = 0;
goto out;
}
- mutex_lock(&file_priv->prime.lock);
-
spin_lock(&file_priv->table_lock);
ret = idr_alloc(&file_priv->object_idr, obj, handle, handle + 1,
GFP_NOWAIT);
@@ -1085,8 +1086,22 @@ 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;
+ mutex_lock(&file_private->prime.lock);
+ 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);
+ mutex_unlock(&file_private->prime.lock);
+ if (!obj)
+ break;
+ drm_gem_object_release_handle(id, obj, file_private);
+ }
idr_destroy(&file_private->object_idr);
}
--
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH] drm: Avoid the chaotic interleaving of change and delete handle
2026-04-13 17:16 [syzbot] [dri?] KASAN: slab-use-after-free Read in drm_gem_object_release_handle syzbot
` (11 preceding siblings ...)
2026-04-16 8:19 ` Hillf Danton
@ 2026-04-16 8:57 ` Edward Adam Davis
12 siblings, 0 replies; 23+ messages in thread
From: Edward Adam Davis @ 2026-04-16 8:57 UTC (permalink / raw)
To: syzbot+b2e951687503f32f74ce
Cc: airlied, dri-devel, linux-kernel, maarten.lankhorst, mripard,
simona, syzkaller-bugs, tzimmermann
First, let's take a look at how GEM object is freed:
CPU0 CPU1
==== ====
drm_gem_change_handle_ioctl()
drm_gem_object_lookup() // got GEM obj and refcnt is 2
... blocks on prime.lock
drm_gem_handle_delete()
drm_gem_object_release_handle()
... acquires prime.lock
drm_prime_remove_buf_handle()
... unlock prime.lock
drm_gem_object_handle_put_unlocked()
drm_gem_object_put() // obj refcnt is 1
... acquires prime.lock
drm_gem_object_put() // obj refcnt is 0
drm_gem_shmem_free() // obj is freed
After a GEM object has been freed, a Use-After-Free vulnerability [1]
is triggered when closes the DRM file, as the drm_gem_release() function
attempts to access the already-freed GEM object.
Adjust the change handle ioctl and handle delete ioctl to be atomic
operations; this prevents simultaneous change and delete operations
on the same GEM object from interfering with the release of the GEM
object during the closing of the DRM file.
[1]
BUG: KASAN: slab-use-after-free in drm_gem_object_release_handle+0x4b/0x1e0 drivers/gpu/drm/drm_gem.c:374
Call Trace:
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
Allocated by task 6090:
__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
Freed by task 6093:
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
Fixes: 53096728b891 ("drm: Add DRM prime interface to reassign GEM handle")
Reported-by: syzbot+b2e951687503f32f74ce@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=b2e951687503f32f74ce
Tested-by: syzbot+b2e951687503f32f74ce@syzkaller.appspotmail.com
Signed-off-by: Edward Adam Davis <eadavis@qq.com>
---
drivers/gpu/drm/drm_gem.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index 891c3bff5ae0..63a8d7e980b5 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -374,14 +374,8 @@ drm_gem_object_release_handle(int id, void *ptr, void *data)
if (obj->funcs->close)
obj->funcs->close(obj, file_priv);
- mutex_lock(&file_priv->prime.lock);
-
drm_prime_remove_buf_handle(&file_priv->prime, id);
-
- mutex_unlock(&file_priv->prime.lock);
-
drm_vma_node_revoke(&obj->vma_node, file_priv);
-
drm_gem_object_handle_put_unlocked(obj);
return 0;
@@ -401,13 +395,16 @@ drm_gem_handle_delete(struct drm_file *filp, u32 handle)
{
struct drm_gem_object *obj;
+ mutex_lock(&filp->prime.lock);
spin_lock(&filp->table_lock);
/* Check if we currently have a reference on the object */
obj = idr_replace(&filp->object_idr, NULL, handle);
spin_unlock(&filp->table_lock);
- if (IS_ERR_OR_NULL(obj))
+ if (IS_ERR_OR_NULL(obj)) {
+ mutex_unlock(&filp->prime.lock);
return -EINVAL;
+ }
/* Release driver's reference and decrement refcount. */
drm_gem_object_release_handle(handle, obj, filp);
@@ -416,6 +413,7 @@ drm_gem_handle_delete(struct drm_file *filp, u32 handle)
spin_lock(&filp->table_lock);
idr_remove(&filp->object_idr, handle);
spin_unlock(&filp->table_lock);
+ mutex_unlock(&filp->prime.lock);
return 0;
}
@@ -1012,17 +1010,18 @@ int drm_gem_change_handle_ioctl(struct drm_device *dev, void *data,
return -EINVAL;
handle = args->new_handle;
+ mutex_lock(&file_priv->prime.lock);
obj = drm_gem_object_lookup(file_priv, args->handle);
- if (!obj)
+ if (!obj) {
+ mutex_unlock(&file_priv->prime.lock);
return -ENOENT;
+ }
if (args->handle == handle) {
ret = 0;
- goto out;
+ goto out_unlock;
}
- mutex_lock(&file_priv->prime.lock);
-
spin_lock(&file_priv->table_lock);
ret = idr_alloc(&file_priv->object_idr, obj, handle, handle + 1,
GFP_NOWAIT);
@@ -1051,9 +1050,8 @@ int drm_gem_change_handle_ioctl(struct drm_device *dev, void *data,
spin_unlock(&file_priv->table_lock);
out_unlock:
- mutex_unlock(&file_priv->prime.lock);
-out:
drm_gem_object_put(obj);
+ mutex_unlock(&file_priv->prime.lock);
return ret;
}
@@ -1085,8 +1083,10 @@ 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)
{
+ mutex_lock(&file_private->prime.lock);
idr_for_each(&file_private->object_idr,
&drm_gem_object_release_handle, file_private);
+ mutex_unlock(&file_private->prime.lock);
idr_destroy(&file_private->object_idr);
}
--
2.43.0
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [syzbot] [dri?] KASAN: slab-use-after-free Read in drm_gem_object_release_handle
2026-04-16 8:19 ` Hillf Danton
@ 2026-04-16 9:03 ` syzbot
0 siblings, 0 replies; 23+ messages in thread
From: syzbot @ 2026-04-16 9:03 UTC (permalink / raw)
To: hdanton, linux-kernel, syzkaller-bugs
Hello,
syzbot has tested the proposed patch and the reproducer did not trigger any issue:
Reported-by: syzbot+b2e951687503f32f74ce@syzkaller.appspotmail.com
Tested-by: syzbot+b2e951687503f32f74ce@syzkaller.appspotmail.com
Tested on:
commit: 1d51b370 Merge tag 'jfs-7.1' of github.com:kleikamp/li..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=10b5e906580000
kernel config: https://syzkaller.appspot.com/x/.config?x=769ed9499e4e3d7d
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=154398ce580000
Note: testing is done by a robot and is best-effort only.
^ permalink raw reply [flat|nested] 23+ messages in thread
end of thread, other threads:[~2026-04-16 9:05 UTC | newest]
Thread overview: 23+ 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
2026-04-15 8:50 ` syzbot
2026-04-15 11:19 ` Hillf Danton
2026-04-15 11:44 ` syzbot
2026-04-16 0:44 ` Hillf Danton
2026-04-16 4:52 ` syzbot
2026-04-16 2:59 ` Edward Adam Davis
2026-04-16 5:13 ` syzbot
2026-04-16 8:19 ` Hillf Danton
2026-04-16 9:03 ` syzbot
2026-04-16 8:57 ` [PATCH] drm: Avoid the chaotic interleaving of change and delete handle Edward Adam Davis
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.