| 0/0 |
2026/05/31 01:11 |
flow |
assessment-security |
1h06m
Results: map[DenialOfService:true Explanation:Based on the analysis of the provided kernel bug report and the source code,
here is the assessment of the bug:
**Bug Mechanism and Deadlock:**
The bug is a classic deadlock in the `virtio-gpu` driver involving the
`dev->clientlist_mutex` lock and the virtqueue free space wait condition.
1. A process (such as the `swapper/0:1` init task during device probe, or a
process executing `drm_lastclose`) acquires the `dev->clientlist_mutex` and
begins queuing commands to the virtio-gpu device (e.g., for a modeset commit).
If the virtqueue becomes full, the process blocks in
`virtio_gpu_queue_ctrl_sgs`, waiting for `vq->num_free >= elemcnt`.
2. Concurrently, the VM host triggers a configuration change interrupt
(`VIRTIO_GPU_EVENT_DISPLAY`), which causes `virtio_gpu_config_changed_work_func`
to queue a `get_display_info` command.
3. When the host responds to the `get_display_info` command, the kernel worker
thread (`kworker/0:0:9`) executes `virtio_gpu_dequeue_ctrl_func` to process the
response.
4. The worker invokes the response callback
`virtio_gpu_cmd_get_display_info_cb`, which in turn calls
`drm_kms_helper_hotplug_event()` -> `drm_client_dev_hotplug()`.
5. `drm_client_dev_hotplug()` attempts to acquire the `dev->clientlist_mutex`
and blocks because it is already held by the first process.
6. Because the worker thread is blocked on the mutex, it cannot finish
processing the responses and free the virtqueue buffers (`vbufs`). Consequently,
`vq->num_free` never increases.
7. The first process waits forever for the virtqueue to have free space,
resulting in a complete deadlock.
**Security Impact:**
* **Exploitable:** No. This is a logical deadlock and does not involve memory
corruption, out-of-bounds accesses, or use-after-free conditions. It cannot be
exploited for privilege escalation or arbitrary code execution.
* **Denial Of Service:** Yes. The deadlock hangs the kernel tasks involved
(including the system init task if triggered during boot, or the DRM worker
queues), leading to a system freeze or unkillable processes (D-state).
* **VM Host Trigger in The Confidential Computing Context:** Yes. In a
Confidential Computing environment (like AMD SEV or Intel TDX) where the VM Host
is considered untrusted, a malicious host can intentionally inject the
`VIRTIO_GPU_EVENT_DISPLAY` config change interrupt at the exact moment the guest
kernel is holding the `clientlist_mutex` (e.g., during boot probe or when an
unprivileged user closes the DRM device file, triggering `drm_lastclose`). This
allows the untrusted host to reliably cause a Denial of Service in the guest
kernel.
* **Accessible From Unprivileged Processes:** No. While an unprivileged user can
trigger the `drm_lastclose` path by opening and closing `/dev/dri/card0`, they
cannot trigger the required concurrent hotplug event
(`VIRTIO_GPU_EVENT_DISPLAY`) on the virtio-gpu device. The deadlock strictly
requires the host to inject the configuration change interrupt. Exploitable:false FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:false RemoteTrigger:false Unprivileged:false UserNamespace:false VMGuestTrigger:false VMHostTrigger:true]
|
| 1/1 |
2026/05/31 01:11 |
action |
syz-repro-to-c-repro |
0m
Results:
|
| 2/1 |
2026/05/31 01:11 |
action |
kernel-checkouter |
1m
Results: map[KernelSrc:/app/workdir/cache/src/ffc167b784a6078e3205b3f1296c15555f7c118e]
|
| 3/1 |
2026/05/31 01:13 |
action |
kernel-builder |
34m
Results: map[KernelObj:/app/workdir/cache/build/15a7656e6898b9c07de035cfd5d6ed7ab003ac26]
|
| 4/1 |
2026/05/31 01:47 |
action |
codesearch-prepare |
22m
Results: map[Index:codesearch-index]
|
| 5/1 |
2026/05/31 02:09 |
agent |
expert |
8m
Model:
Results: map[DenialOfService:true Exploitable:false FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:false RemoteTrigger:false Unprivileged:false UserNamespace:false VMGuestTrigger:false VMHostTrigger:true]
Instruction: You are an experienced Linux kernel security engineer. Your task is to analyze given kernel bug report
and determine its security impact based on the following dimensions.
Use the provided tools to examine the source code, check for capability checks (e.g., capable(), ns_capable()),
and understand the nature of the bug. Analyze the given kernel build and configuration.
You can check the kernel config by grepping ".config" file; you can check kernel cmdline by grepping
".config" file for "CONFIG_CMDLINE=". Assume sysctl parameters have default values.
But analyze for the corresponding production build w/o debugging tools enabled (like KASAN, KMSAN, UBSAN).
Try different strategies when analyzing the bug:
- think of ways in which the vulnerable code is unreachable
- or the other way around: try to come up with different ideas of how an unprivileged user can reach the bug
If still unsure err on the side of the bug being non-exploitable/not-accessible.
In the final reply, provide a reasoning for your assessment.
Analysis dimensions:
* Exploitable:
Determine if the bug can result in memory corruption or elevated privileges.
Memory safety issues are almost always exploitable (KASAN or UBSAN reports for use-after-free, out-of-bounds;
refcounting issues, corrupted lists, etc). When kernel is crashing on a completely wild pointer access
(e.g. user-space address, or non-canonical address, but not on NULL or address corresponding to KASAN shadow
for NULL address), including both data accesses and control transfers, that also usually implies possibility
of exploitation. Such reports usually say "unable to handle kernel paging request".
Uses of uninitialized values detected by KMSAN may be exploitable b/c attacker frequently can affect uninit
values with spraying techniques. However, for these exploitability depends on how exactly the uninit value
is used in the code, and what it affects.
Think of what happens after the bug is triggered. Some bugs cause kernel panic and halt execution,
they are harder to exploit. For example, BUG reports halts the kernel. However, WARNING reports don't halt
execution in production builds. Debug bug detection tools (like KASAN, KMSAN, KCSAN, UBSAN) are also not enabled
in production builds, so attacker can freely exploit these bugs w/o being detected by these tools.
If you see an integer overflow, think how the overflowed value used later (if it's used as allocation size,
or an array index). If you see an out-of-bounds read, think if it's followed by an out-of-bounds write as well.
Some KCSAN data-races may be exploitable by skilled attackers as well. Think what data structures got corrupted
as the result of data races and how. However, note that kernel has lots of "benign" data races that don't lead
to any runtime misbehavior at all.
* Denial Of Service:
Determine if the bug can result in denial-of-service. Most bugs can, since they cause system crash,
hangs, deadlocks, or resource leaks. This is mostly applicable to WARNING bugs that won't cause system crash
in production. For these think what will be consequences of the violation of the kernel assumptions flagged
by the WARNING. In some cases the unexpected condition is also properly handled by the normal control flow
(e.g. with "if (WARN_ON(...))"), these won't cause denial-of-service. If the condition is not handled,
then it may or may not cause denial-of-service.
* Accessible From Unprivileged Processes:
Determine if the bug can be reached from a typical (non-root) user process that does NOT have any special capabilities
(like CAP_SYS_ADMIN, CAP_NET_ADMIN, CAP_NET_RAW, CAP_PERFMON) or access to device nodes restricted to root.
Assume that unprivileged_bpf_disabled=1, that is eBPF loading is not accessible. However, cBPF (classical BPF)
is still accessible to non-root processes.
Assume that user namespaces are not accessible, that is, the process cannot get the mentioned capabilities even
within a new user namespace (checked by ns_capable() function in the kernel sources).
* Accessible From User Namespaces:
Determine if the bug can be reached within a user-namespace where the process has all capabilities
(including CAP_SYS_ADMIN, CAP_NET_ADMIN, CAP_NET_RAW, CAP_PERFMON). Such capabilities are checked with ns_capable()
function in the kernel sources.
* VM Guest Trigger:
Determine if the bug can be triggered from the context of a typical KVM guest (e.g., set up by a QEMU VMM).
Consider accesses to standard Linux host paravirtualized features (virtio-blk, virtio-net, etc.),
and handling of VM exits in the KVM code.
* VM Host Trigger in The Confidential Computing Context:
Determine if the bug can be triggered in a confidential computing guest kernel from the context of a KVM host.
Consider access to standard Linux guest paravirtualized features (virtio-blk, virtio-net, etc.).
* Ethernet Network Trigger:
Determine if the bug can be triggered by processing ingress network Ethernet traffic, either directly (network stack)
or via drivers exposed to network data.
* Other Remote Trigger:
Determine if the bug can be triggered by processing remote traffic other than Ethernet (Wifi, Bluetooth, NFC, etc).
* Peripheral Trigger:
Determine if the bug can be triggered via an untrusted peripheral device that can be physically plugged
into a system, such as a USB device or a niche hardware driver handling external hardware inputs.
This is particularly important for mobile and desktop environments where users can plug in unknown devices.
* Malicious Filesystem Trigger:
Determine if the bug can be triggered by the kernel mounting and parsing a malicious filesystem image.
This is highly critical for Desktop and Mobile environments where external media or downloaded images
might be auto-mounted.
Don't make assumptions about the kernel source code (it may be different from what you assume it is).
Extensively use the provided code access tools (codesearch-*, git-*, grepper, etc)
to examine the actual source code, and confirm any assumptions.
Prefer calling several tools at the same time to save round-trips.
Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.
Prompt:
The kernel bug report is:
INFO: task swapper/0:1 blocked for more than 143 seconds.
Not tainted syzkaller #0
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:swapper/0 state:D stack:19368 pid:1 tgid:1 ppid:0 task_flags:0x0140 flags:0x00080000
Call Trace:
<TASK>
context_switch kernel/sched/core.c:5298 [inline]
__schedule+0x15dd/0x52d0 kernel/sched/core.c:6911
__schedule_loop kernel/sched/core.c:6993 [inline]
schedule+0x164/0x360 kernel/sched/core.c:7008
virtio_gpu_queue_ctrl_sgs drivers/gpu/drm/virtio/virtgpu_vq.c:399 [inline]
virtio_gpu_queue_fenced_ctrl_buffer+0x760/0x1090 drivers/gpu/drm/virtio/virtgpu_vq.c:500
virtio_gpu_resource_flush drivers/gpu/drm/virtio/virtgpu_plane.c:226 [inline]
virtio_gpu_primary_plane_update+0xcff/0x13a0 drivers/gpu/drm/virtio/virtgpu_plane.c:301
drm_atomic_helper_commit_planes+0x60f/0xec0 drivers/gpu/drm/drm_atomic_helper.c:3038
drm_atomic_helper_commit_tail+0x5f/0x500 drivers/gpu/drm/drm_atomic_helper.c:1989
commit_tail+0x29a/0x3a0 drivers/gpu/drm/drm_atomic_helper.c:2074
drm_atomic_helper_commit+0xa6e/0xb10 drivers/gpu/drm/drm_atomic_helper.c:2312
drm_atomic_commit+0x246/0x2b0 drivers/gpu/drm/drm_atomic.c:1775
drm_client_modeset_commit_atomic+0x660/0x7e0 drivers/gpu/drm/drm_client_modeset.c:1104
drm_client_modeset_commit_locked+0xcb/0x4d0 drivers/gpu/drm/drm_client_modeset.c:1207
pan_display_atomic drivers/gpu/drm/drm_fb_helper.c:1207 [inline]
drm_fb_helper_pan_display+0x3e7/0xbd0 drivers/gpu/drm/drm_fb_helper.c:1267
fb_pan_display+0x39e/0x680 drivers/video/fbdev/core/fbmem.c:193
bit_update_start+0x4c/0x1e0 drivers/video/fbdev/core/bitblit.c:405
fbcon_switch+0x127e/0x2040 drivers/video/fbdev/core/fbcon.c:2211
redraw_screen+0x586/0xec0 drivers/tty/vt/vt.c:960
con2fb_init_display drivers/video/fbdev/core/fbcon.c:857 [inline]
set_con2fb_map+0xabb/0xfc0 drivers/video/fbdev/core/fbcon.c:918
do_fb_registered drivers/video/fbdev/core/fbcon.c:3023 [inline]
fbcon_fb_registered+0x24e/0x610 drivers/video/fbdev/core/fbcon.c:3043
do_register_framebuffer drivers/video/fbdev/core/fbmem.c:512 [inline]
register_framebuffer+0x738/0x8d0 drivers/video/fbdev/core/fbmem.c:579
__drm_fb_helper_initial_config_and_unlock+0x14f1/0x1b90 drivers/gpu/drm/drm_fb_helper.c:1668
drm_fbdev_client_hotplug+0x16c/0x230 drivers/gpu/drm/clients/drm_fbdev_client.c:66
drm_client_register+0x172/0x210 drivers/gpu/drm/drm_client.c:143
drm_fbdev_client_setup+0x1a0/0x3f0 drivers/gpu/drm/clients/drm_fbdev_client.c:168
drm_client_setup+0x107/0x220 drivers/gpu/drm/clients/drm_client_setup.c:46
virtio_gpu_probe+0x23a/0x2a0 drivers/gpu/drm/virtio/virtgpu_drv.c:111
virtio_dev_probe+0xd93/0x1050 drivers/virtio/virtio.c:347
call_driver_probe drivers/base/dd.c:-1 [inline]
really_probe+0x267/0xaf0 drivers/base/dd.c:721
__driver_probe_device+0x18c/0x320 drivers/base/dd.c:863
driver_probe_device+0x4f/0x240 drivers/base/dd.c:893
__driver_attach+0x34c/0x640 drivers/base/dd.c:1287
bus_for_each_dev+0x23b/0x2c0 drivers/base/bus.c:383
bus_add_driver+0x345/0x670 drivers/base/bus.c:756
driver_register+0x23a/0x320 drivers/base/driver.c:249
virtio_gpu_driver_init+0x96/0x110 drivers/gpu/drm/virtio/virtgpu_drv.c:195
do_one_initcall+0x250/0x8d0 init/main.c:1382
do_initcall_level+0x104/0x190 init/main.c:1444
do_initcalls+0x59/0xa0 init/main.c:1460
kernel_init_freeable+0x2a6/0x3e0 init/main.c:1692
kernel_init+0x1d/0x1d0 init/main.c:1582
ret_from_fork+0x51e/0xb90 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
</TASK>
INFO: task kworker/0:0:9 blocked for more than 143 seconds.
Not tainted syzkaller #0
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:kworker/0:0 state:D stack:27584 pid:9 tgid:9 ppid:2 task_flags:0x4208060 flags:0x00080000
Workqueue: events virtio_gpu_dequeue_ctrl_func
Call Trace:
<TASK>
context_switch kernel/sched/core.c:5298 [inline]
__schedule+0x15dd/0x52d0 kernel/sched/core.c:6911
__schedule_loop kernel/sched/core.c:6993 [inline]
schedule+0x164/0x360 kernel/sched/core.c:7008
schedule_preempt_disabled+0x13/0x30 kernel/sched/core.c:7065
__mutex_lock_common kernel/locking/mutex.c:692 [inline]
__mutex_lock+0x7fe/0x1300 kernel/locking/mutex.c:776
drm_client_dev_hotplug+0xdc/0x4f0 drivers/gpu/drm/drm_client_event.c:98
virtio_gpu_dequeue_ctrl_func+0x506/0x8c0 drivers/gpu/drm/virtio/virtgpu_vq.c:265
process_one_work kernel/workqueue.c:3276 [inline]
process_scheduled_works+0xb6e/0x18c0 kernel/workqueue.c:3359
worker_thread+0xa53/0xfc0 kernel/workqueue.c:3440
kthread+0x388/0x470 kernel/kthread.c:436
ret_from_fork+0x51e/0xb90 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
</TASK>
INFO: task kworker/0:2:54 blocked for more than 143 seconds.
Not tainted syzkaller #0
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:kworker/0:2 state:D stack:26208 pid:54 tgid:54 ppid:2 task_flags:0x4208060 flags:0x00080000
Workqueue: events drm_fb_helper_damage_work
Call Trace:
<TASK>
context_switch kernel/sched/core.c:5298 [inline]
__schedule+0x15dd/0x52d0 kernel/sched/core.c:6911
__schedule_loop kernel/sched/core.c:6993 [inline]
schedule+0x164/0x360 kernel/sched/core.c:7008
schedule_preempt_disabled+0x13/0x30 kernel/sched/core.c:7065
__mutex_lock_common kernel/locking/mutex.c:692 [inline]
__mutex_lock+0x7fe/0x1300 kernel/locking/mutex.c:776
drm_fb_helper_fb_dirty drivers/gpu/drm/drm_fb_helper.c:235 [inline]
drm_fb_helper_damage_work+0x125/0x750 drivers/gpu/drm/drm_fb_helper.c:274
process_one_work kernel/workqueue.c:3276 [inline]
process_scheduled_works+0xb6e/0x18c0 kernel/workqueue.c:3359
worker_thread+0xa53/0xfc0 kernel/workqueue.c:3440
kthread+0x388/0x470 kernel/kthread.c:436
ret_from_fork+0x51e/0xb90 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
</TASK>
Showing all locks held in the system:
10 locks held by swapper/0/1:
#0: ffff888032d8f1b8 (&dev->mutex){....}-{4:4}, at: device_lock include/linux/device.h:949 [inline]
#0: ffff888032d8f1b8 (&dev->mutex){....}-{4:4}, at: __device_driver_lock drivers/base/dd.c:1166 [inline]
#0: ffff888032d8f1b8 (&dev->mutex){....}-{4:4}, at: __driver_attach+0x341/0x640 drivers/base/dd.c:1286
#1: ffff88801f7dc278 (&dev->clientlist_mutex){+.+.}-{4:4}, at: drm_client_register+0x4f/0x210 drivers/gpu/drm/drm_client.c:129
#2: ffffffff8ef5edc8 (registration_lock){+.+.}-{4:4}, at: register_framebuffer+0x8d/0x8d0 drivers/video/fbdev/core/fbmem.c:578
#3: ffffffff8e750a00 (console_lock){+.+.}-{0:0}, at: fbcon_fb_registered+0x49/0x610 drivers/video/fbdev/core/fbcon.c:3039
#4: ffff88801ccbaa80 (&helper->lock){+.+.}-{4:4}, at: drm_fb_helper_pan_display+0xbe/0xbd0 drivers/gpu/drm/drm_fb_helper.c:1260
#5: ffff88801f7dc130 (&dev->master_mutex){+.+.}-{4:4}, at: drm_master_internal_acquire+0x20/0x80 drivers/gpu/drm/drm_auth.c:435
#6: ffff88801ccba898 (&client->modeset_mutex){+.+.}-{4:4}, at: drm_client_modeset_commit_locked+0x4c/0x4d0 drivers/gpu/drm/drm_client_modeset.c:1205
#7: ffffc900001aeb10 (crtc_ww_class_acquire){+.+.}-{0:0}, at: drm_client_modeset_commit_atomic+0x11a/0x7e0 drivers/gpu/drm/drm_client_modeset.c:1043
#8: ffffc900001aeb38 (crtc_ww_class_mutex){+.+.}-{4:4}, at: drm_client_modeset_commit_atomic+0x11a/0x7e0 drivers/gpu/drm/drm_client_modeset.c:1043
#9: ffffffff8f063cb8 (drm_unplug_srcu){.+.+}-{0:0}, at: srcu_lock_acquire include/linux/srcu.h:187 [inline]
#9: ffffffff8f063cb8 (drm_unplug_srcu){.+.+}-{0:0}, at: srcu_read_lock include/linux/srcu.h:294 [inline]
#9: ffffffff8f063cb8 (drm_unplug_srcu){.+.+}-{0:0}, at: drm_dev_enter+0x49/0x150 drivers/gpu/drm/drm_drv.c:451
3 locks held by kworker/0:0/9:
#0: ffff88801aca6948 ((wq_completion)events){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3251 [inline]
#0: ffff88801aca6948 ((wq_completion)events){+.+.}-{0:0}, at: process_scheduled_works+0xa52/0x18c0 kernel/workqueue.c:3359
#1: ffffc9000022fc40 ((work_completion)(&vgvq->dequeue_work)){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3252 [inline]
#1: ffffc9000022fc40 ((work_completion)(&vgvq->dequeue_work)){+.+.}-{0:0}, at: process_scheduled_works+0xa8d/0x18c0 kernel/workqueue.c:3359
#2: ffff88801f7dc278 (&dev->clientlist_mutex){+.+.}-{4:4}, at: drm_client_dev_hotplug+0xdc/0x4f0 drivers/gpu/drm/drm_client_event.c:98
1 lock held by khungtaskd/25:
#0: ffffffff8e75e5e0 (rcu_read_lock){....}-{1:3}, at: rcu_lock_acquire include/linux/rcupdate.h:312 [inline]
#0: ffffffff8e75e5e0 (rcu_read_lock){....}-{1:3}, at: rcu_read_lock include/linux/rcupdate.h:850 [inline]
#0: ffffffff8e75e5e0 (rcu_read_lock){....}-{1:3}, at: debug_show_all_locks+0x2e/0x180 kernel/locking/lockdep.c:6775
2 locks held by kworker/u4:4/52:
#0: ffff88801ac94148 ((wq_completion)events_unbound){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3251 [inline]
#0: ffff88801ac94148 ((wq_completion)events_unbound){+.+.}-{0:0}, at: process_scheduled_works+0xa52/0x18c0 kernel/workqueue.c:3359
#1: ffffc90000affc40 ((work_completion)(&(&kfence_timer)->work)){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3252 [inline]
#1: ffffc90000affc40 ((work_completion)(&(&kfence_timer)->work)){+.+.}-{0:0}, at: process_scheduled_works+0xa8d/0x18c0 kernel/workqueue.c:3359
3 locks held by kworker/0:2/54:
#0: ffff88801aca6948 ((wq_completion)events){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3251 [inline]
#0: ffff88801aca6948 ((wq_completion)events){+.+.}-{0:0}, at: process_scheduled_works+0xa52/0x18c0 kernel/workqueue.c:3359
#1: ffffc90000b0fc40 ((work_completion)(&helper->damage_work)){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3252 [inline]
#1: ffffc90000b0fc40 ((work_completion)(&helper->damage_work)){+.+.}-{0:0}, at: process_scheduled_works+0xa8d/0x18c0 kernel/workqueue.c:3359
#2: ffff88801ccbaa80 (&helper->lock){+.+.}-{4:4}, at: drm_fb_helper_fb_dirty drivers/gpu/drm/drm_fb_helper.c:235 [inline]
#2: ffff88801ccbaa80 (&helper->lock){+.+.}-{4:4}, at: drm_fb_helper_damage_work+0x125/0x750 drivers/gpu/drm/drm_fb_helper.c:274
=============================================
Reply: Based on the analysis of the provided kernel bug report and the source code, here is the assessment of the bug:
**Bug Mechanism and Deadlock:**
The bug is a classic deadlock in the `virtio-gpu` driver involving the `dev->clientlist_mutex` lock and the virtqueue free space wait condition.
1. A process (such as the `swapper/0:1` init task during device probe, or a process executing `drm_lastclose`) acquires the `dev->clientlist_mutex` and begins queuing commands to the virtio-gpu device (e.g., for a modeset commit). If the virtqueue becomes full, the process blocks in `virtio_gpu_queue_ctrl_sgs`, waiting for `vq->num_free >= elemcnt`.
2. Concurrently, the VM host triggers a configuration change interrupt (`VIRTIO_GPU_EVENT_DISPLAY`), which causes `virtio_gpu_config_changed_work_func` to queue a `get_display_info` command.
3. When the host responds to the `get_display_info` command, the kernel worker thread (`kworker/0:0:9`) executes `virtio_gpu_dequeue_ctrl_func` to process the response.
4. The worker invokes the response callback `virtio_gpu_cmd_get_display_info_cb`, which in turn calls `drm_kms_helper_hotplug_event()` -> `drm_client_dev_hotplug()`.
5. `drm_client_dev_hotplug()` attempts to acquire the `dev->clientlist_mutex` and blocks because it is already held by the first process.
6. Because the worker thread is blocked on the mutex, it cannot finish processing the responses and free the virtqueue buffers (`vbufs`). Consequently, `vq->num_free` never increases.
7. The first process waits forever for the virtqueue to have free space, resulting in a complete deadlock.
**Security Impact:**
* **Exploitable:** No. This is a logical deadlock and does not involve memory corruption, out-of-bounds accesses, or use-after-free conditions. It cannot be exploited for privilege escalation or arbitrary code execution.
* **Denial Of Service:** Yes. The deadlock hangs the kernel tasks involved (including the system init task if triggered during boot, or the DRM worker queues), leading to a system freeze or unkillable processes (D-state).
* **VM Host Trigger in The Confidential Computing Context:** Yes. In a Confidential Computing environment (like AMD SEV or Intel TDX) where the VM Host is considered untrusted, a malicious host can intentionally inject the `VIRTIO_GPU_EVENT_DISPLAY` config change interrupt at the exact moment the guest kernel is holding the `clientlist_mutex` (e.g., during boot probe or when an unprivileged user closes the DRM device file, triggering `drm_lastclose`). This allows the untrusted host to reliably cause a Denial of Service in the guest kernel.
* **Accessible From Unprivileged Processes:** No. While an unprivileged user can trigger the `drm_lastclose` path by opening and closing `/dev/dri/card0`, they cannot trigger the required concurrent hotplug event (`VIRTIO_GPU_EVENT_DISPLAY`) on the virtio-gpu device. The deadlock strictly requires the host to inject the configuration change interrupt.
|
| 6/2 |
2026/05/31 02:09 |
llm |
expert |
0m
Model:
Tokens:
input: 10327
output: 43
thoughts: 1415
Thoughts: **Analyzing a Hung Task Report with Virtio GPU Involvement**
Okay, so I've got a report indicating three tasks are blocked for over 143 seconds. That's a serious slowdown. It looks like `swapper/0:1`, `kworker/0:0:9`, and `kworker/0:2:54` are all in the same boat, which probably means they are competing for a common resource or that something is blocked and keeping them all stuck. Let's dig into the stack traces.
The first task, `swapper/0:1`, seems to be deeply involved in the virtio GPU driver, starting with `virtio_gpu_queue_ctrl_sgs`. It then flows through the atomic commit process (`drm_atomic_helper_commit*`), fbdev handling (`drm_fb_helper_*`, `fb_*`, and finally all the way into framebuffer registration (`register_framebuffer`). It looks like it is calling `virtio_gpu_probe` so it is likely still initializing. It is calling into `virtio_gpu_queue_fenced_ctrl_buffer`.
The other tasks show `__mutex_lock` in the stack. `kworker/0:0:9` also is calling `virtio_gpu_dequeue_ctrl_func`, also related to `virtio_gpu_vq`. `kworker/0:2:54` is in `drm_fb_helper_damage_work`.
Given the `virtio_gpu` focus in the first task and the mutex contention in the others, this smells like a synchronization issue or some kind of deadlock in the virtio GPU driver.
The common denominator in the stacks appears to be the `virtio_gpu_vq.c` file and potentially some synchronization primitives (likely mutexes) involved with the virtual queue. I'm going to focus my initial investigation on `virtio_gpu_queue_ctrl_sgs` and the related functions and the mutex usage in `virtio_gpu_vq.c`. I'll need to check how these functions interact with the mutex and look for potential lock order inversions, or other synchronization issues that could lead to this kind of blocking.
|
| 7/2 |
2026/05/31 02:10 |
tool |
read-file |
0m
Args: map[File:drivers/gpu/drm/virtio/virtgpu_vq.c FirstLine:380 LineCount:50]
Results: map[Contents: 380: struct virtqueue *vq = vgdev->ctrlq.vq;
381: int ret, idx;
382:
383: if (!drm_dev_enter(vgdev->ddev, &idx)) {
384: if (fence && vbuf->objs)
385: virtio_gpu_array_unlock_resv(vbuf->objs);
386: free_vbuf(vgdev, vbuf);
387: return -ENODEV;
388: }
389:
390: if (vgdev->has_indirect)
391: elemcnt = 1;
392:
393: again:
394: spin_lock(&vgdev->ctrlq.qlock);
395:
396: if (vq->num_free < elemcnt) {
397: spin_unlock(&vgdev->ctrlq.qlock);
398: virtio_gpu_notify(vgdev);
399: wait_event(vgdev->ctrlq.ack_queue, vq->num_free >= elemcnt);
400: goto again;
401: }
402:
403: /* now that the position of the vbuf in the virtqueue is known, we can
404: * finally set the fence id
405: */
406: if (fence) {
407: virtio_gpu_fence_emit(vgdev, virtio_gpu_vbuf_ctrl_hdr(vbuf),
408: fence);
409: if (vbuf->objs) {
410: virtio_gpu_array_add_fence(vbuf->objs, &fence->f);
411: virtio_gpu_array_unlock_resv(vbuf->objs);
412: }
413: }
414:
415: ret = virtqueue_add_sgs(vq, sgs, outcnt, incnt, vbuf, GFP_ATOMIC);
416: WARN_ON(ret);
417:
418: vbuf->seqno = ++vgdev->ctrlq.seqno;
419: trace_virtio_gpu_cmd_queue(vq, virtio_gpu_vbuf_ctrl_hdr(vbuf), vbuf->seqno);
420:
421: atomic_inc(&vgdev->pending_commands);
422:
423: spin_unlock(&vgdev->ctrlq.qlock);
424:
425: drm_dev_exit(idx);
426: return 0;
427: }
428:
429: /* For drm_panic */
]
|
| 8/2 |
2026/05/31 02:10 |
llm |
expert |
0m
Model:
Tokens:
input: 13030
output: 35
thoughts: 227
Thoughts: **Debugging a Virtio-GPU Queue Stoppage**
Okay, so I'm looking at this trace, and it seems like the `swapper/0:1` task – which, wait, that's likely `init` during boot, right? It’s probing the `virtio_gpu` driver, and it's getting stuck. Specifically, it's blocking at `wait_event(vgdev->ctrlq.ack_queue, vq->num_free >= elemcnt)` within `virtio_gpu_queue_ctrl_sgs`. It's waiting for `vq->num_free` to be greater than or equal to `elemcnt`. Basically, the control queue is full, and it's trying to push another command.
So, it's waiting on `vgdev->ctrlq.ack_queue` to be signaled. The crucial question now is: what's supposed to wake this thing up? I need to find the `wake_up(&vgdev->ctrlq.ack_queue)` call (or something analogous) within the code to understand the flow here. I need to know how the driver is supposed to clear up the control queue.
|
| 9/2 |
2026/05/31 02:10 |
tool |
grepper |
0m
Args: map[Expression:wake_up.*ack_queue PathPrefix:drivers/gpu/drm/virtio]
Results: map[Output:drivers/gpu/drm/virtio/virtgpu_vq.c=225=void virtio_gpu_dequeue_ctrl_func(struct work_struct *work)
--
drivers/gpu/drm/virtio/virtgpu_vq.c-266- }
drivers/gpu/drm/virtio/virtgpu_vq.c:267: wake_up(&vgdev->ctrlq.ack_queue);
drivers/gpu/drm/virtio/virtgpu_vq.c-268-
--
drivers/gpu/drm/virtio/virtgpu_vq.c=277=void virtio_gpu_dequeue_cursor_func(struct work_struct *work)
--
drivers/gpu/drm/virtio/virtgpu_vq.c-300- }
drivers/gpu/drm/virtio/virtgpu_vq.c:301: wake_up(&vgdev->cursorq.ack_queue);
drivers/gpu/drm/virtio/virtgpu_vq.c-302-}
]
|
| 10/2 |
2026/05/31 02:10 |
llm |
expert |
0m
Model:
Tokens:
input: 13804
output: 43
thoughts: 48
Thoughts: Okay, let's break this down.
**Diving into virtio_gpu_dequeue_ctrl_func**
Alright, *finally*! `virtio_gpu_dequeue_ctrl_func` is being called, which means the control path is getting some attention. It's waking up `vgdev->ctrlq.ack_queue` – that's the acknowledge queue, which is a good sign; things are moving along. So, the kernel's getting ready to acknowledge a request. Now, the interesting question is *why*? What's going on within `virtio_gpu_dequeue_ctrl_func`? What commands are being handled? Is there a pending issue to get addressed? What specifically is being dequeued? This is where the real work begins, and I need to understand the details to know if the control path is behaving as I expect, or if there's an opportunity to optimize. Time to jump into the code and see what `virtio_gpu_dequeue_ctrl_func` is actually *doing*.
|
| 11/2 |
2026/05/31 02:10 |
tool |
read-file |
0m
Args: map[File:drivers/gpu/drm/virtio/virtgpu_vq.c FirstLine:225 LineCount:50]
Results: map[Contents: 225: void virtio_gpu_dequeue_ctrl_func(struct work_struct *work)
226: {
227: struct virtio_gpu_device *vgdev =
228: container_of(work, struct virtio_gpu_device,
229: ctrlq.dequeue_work);
230: struct list_head reclaim_list;
231: struct virtio_gpu_vbuffer *entry, *tmp;
232: struct virtio_gpu_ctrl_hdr *resp;
233: u64 fence_id;
234:
235: INIT_LIST_HEAD(&reclaim_list);
236: spin_lock(&vgdev->ctrlq.qlock);
237: do {
238: virtqueue_disable_cb(vgdev->ctrlq.vq);
239: reclaim_vbufs(vgdev->ctrlq.vq, &reclaim_list);
240:
241: } while (!virtqueue_enable_cb(vgdev->ctrlq.vq));
242: spin_unlock(&vgdev->ctrlq.qlock);
243:
244: list_for_each_entry(entry, &reclaim_list, list) {
245: resp = (struct virtio_gpu_ctrl_hdr *)entry->resp_buf;
246:
247: trace_virtio_gpu_cmd_response(vgdev->ctrlq.vq, resp, entry->seqno);
248:
249: if (resp->type != cpu_to_le32(VIRTIO_GPU_RESP_OK_NODATA)) {
250: if (le32_to_cpu(resp->type) >= VIRTIO_GPU_RESP_ERR_UNSPEC) {
251: struct virtio_gpu_ctrl_hdr *cmd;
252:
253: cmd = virtio_gpu_vbuf_ctrl_hdr(entry);
254: DRM_ERROR_RATELIMITED("response 0x%x (command 0x%x)\n",
255: le32_to_cpu(resp->type),
256: le32_to_cpu(cmd->type));
257: } else
258: DRM_DEBUG("response 0x%x\n", le32_to_cpu(resp->type));
259: }
260: if (resp->flags & cpu_to_le32(VIRTIO_GPU_FLAG_FENCE)) {
261: fence_id = le64_to_cpu(resp->fence_id);
262: virtio_gpu_fence_event_process(vgdev, fence_id);
263: }
264: if (entry->resp_cb)
265: entry->resp_cb(vgdev, entry);
266: }
267: wake_up(&vgdev->ctrlq.ack_queue);
268:
269: list_for_each_entry_safe(entry, tmp, &reclaim_list, list) {
270: if (entry->objs)
271: virtio_gpu_array_put_free_delayed(vgdev, entry->objs);
272: list_del(&entry->list);
273: free_vbuf(vgdev, entry);
274: }
]
|
| 12/2 |
2026/05/31 02:10 |
llm |
expert |
0m
Model:
Tokens:
input: 15060
output: 40
thoughts: 220
Thoughts: **Debugging a virtio_gpu Issue**
Okay, here we go again. I'm seeing `kworker/0:0:9` blocked. The call stack points directly at `virtio_gpu_dequeue_ctrl_func`, specifically at that line, line 265 in `virtgpu_vq.c`. That's where it's getting hung up, and it looks like `entry->resp_cb(vgdev, entry);` is the culprit. Hmm, time to dig deeper. I need to understand what `entry->resp_cb` actually *does*. Right, it looks like it's calling `drm_client_dev_hotplug`. Okay, now we're getting somewhere. Let's trace that function call. I'll check `drm_client_dev_hotplug` in `drm_client_event.c`. Hopefully, it'll illuminate what's causing the block.
|
| 13/2 |
2026/05/31 02:10 |
tool |
read-file |
0m
Args: map[File:drivers/gpu/drm/drm_client_event.c FirstLine:80 LineCount:50]
Results: map[Contents: 80: *
81: * This function calls the &drm_client_funcs.hotplug callback on the attached clients.
82: *
83: * drm_kms_helper_hotplug_event() calls this function, so drivers that use it
84: * don't need to call this function themselves.
85: */
86: void drm_client_dev_hotplug(struct drm_device *dev)
87: {
88: struct drm_client_dev *client;
89:
90: if (!drm_core_check_feature(dev, DRIVER_MODESET))
91: return;
92:
93: if (!dev->mode_config.num_connector) {
94: drm_dbg_kms(dev, "No connectors found, will not send hotplug events!\n");
95: return;
96: }
97:
98: mutex_lock(&dev->clientlist_mutex);
99: list_for_each_entry(client, &dev->clientlist, list)
100: drm_client_hotplug(client);
101: mutex_unlock(&dev->clientlist_mutex);
102: }
103: EXPORT_SYMBOL(drm_client_dev_hotplug);
104:
105: void drm_client_dev_restore(struct drm_device *dev, bool force)
106: {
107: struct drm_client_dev *client;
108: int ret;
109:
110: if (!drm_core_check_feature(dev, DRIVER_MODESET))
111: return;
112:
113: mutex_lock(&dev->clientlist_mutex);
114: list_for_each_entry(client, &dev->clientlist, list) {
115: if (!client->funcs || !client->funcs->restore)
116: continue;
117:
118: ret = client->funcs->restore(client, force);
119: drm_dbg_kms(dev, "%s: ret=%d\n", client->name, ret);
120: if (!ret) /* The first one to return zero gets the privilege to restore */
121: break;
122: }
123: mutex_unlock(&dev->clientlist_mutex);
124: }
125:
126: static int drm_client_suspend(struct drm_client_dev *client)
127: {
128: struct drm_device *dev = client->dev;
129: int ret = 0;
]
|
| 14/2 |
2026/05/31 02:10 |
llm |
expert |
0m
Model:
Tokens:
input: 16267
output: 32
thoughts: 941
Thoughts: **Deadlock Analysis in the DRM and Virtio-GPU Interaction**
Okay, so I'm looking at this `drm_client_dev_hotplug` function and it's trying to acquire `dev->clientlist_mutex`. I need to figure out who's holding that lock. A quick look at the lockdep output reveals that `swapper/0:1` is the culprit, holding `dev->clientlist_mutex`. That's a red flag.
Diving deeper, I see `swapper/0:1` is blocked, waiting for `vq->num_free >= elemcnt` within the `virtio_gpu_queue_ctrl_sgs` function. It makes sense; we're waiting for resources. But the crucial part is that `vq->num_free` is only incremented when `virtio_gpu_dequeue_ctrl_func` completes its processing and wakes up `vgdev->ctrlq.ack_queue`.
Now, here's where the problem is. `virtio_gpu_dequeue_ctrl_func` calls `wake_up` *after* it executes `entry->resp_cb`. And, the `entry->resp_cb` is in turn, is calling `drm_client_dev_hotplug`, which *itself* blocks on `dev->clientlist_mutex`. So, `virtio_gpu_dequeue_ctrl_func` is effectively blocked, preventing it from waking up the queue. This means `swapper/0:1` is stuck, waiting for a wake-up that will never happen, all while *holding* `dev->clientlist_mutex`.
This is a classic deadlock scenario! We have a clear circular dependency.
To confirm this, I've traced the execution path of `swapper/0:1`. It holds `dev->clientlist_mutex` in `drm_client_register`, and then proceeds through a series of function calls: `drm_fbdev_client_hotplug`, `__drm_fb_helper_initial_config_and_unlock`, and all the way down to `virtio_gpu_queue_ctrl_sgs`, where it's waiting for those resources.
Meanwhile, `kworker/0:0:9` is running `virtio_gpu_dequeue_ctrl_func`. It processes a response and calls `entry->resp_cb`, which, from what I can see, is linked to functions like `virtio_gpu_cmd_get_display_info_cb` or similar. These call functions like `drm_helper_hpd_irq_event` or, crucially, `drm_client_dev_hotplug`, which gets us back to that initial blocking call.
I need to confirm the exact function being called as the `resp_cb`, but I am quite certain the circular dependency is the core of the problem.
|
| 15/2 |
2026/05/31 02:10 |
tool |
grepper |
0m
Args: map[Expression:resp_cb = PathPrefix:drivers/gpu/drm/virtio]
Results: map[Output:drivers/gpu/drm/virtio/virtgpu_vq.c=92=virtio_gpu_panic_get_vbuf(struct virtio_gpu_device *vgdev, int size)
--
drivers/gpu/drm/virtio/virtgpu_vq.c-99- vbuf->size = size;
drivers/gpu/drm/virtio/virtgpu_vq.c:100: vbuf->resp_cb = NULL;
drivers/gpu/drm/virtio/virtgpu_vq.c-101- vbuf->resp_size = sizeof(struct virtio_gpu_ctrl_hdr);
--
drivers/gpu/drm/virtio/virtgpu_vq.c=107=virtio_gpu_get_vbuf(struct virtio_gpu_device *vgdev,
--
drivers/gpu/drm/virtio/virtgpu_vq.c-119-
drivers/gpu/drm/virtio/virtgpu_vq.c:120: vbuf->resp_cb = resp_cb;
drivers/gpu/drm/virtio/virtgpu_vq.c-121- vbuf->resp_size = resp_size;
]
|
| 16/2 |
2026/05/31 02:10 |
llm |
expert |
0m
Model:
Tokens:
input: 18155
output: 49
thoughts: 28
Thoughts: Here's my thought process, as if I were considering this code:
**Analyzing the virtio_gpu_get_vbuf Callbacks**
Alright, let's dive into this `virtio_gpu_get_vbuf` function. My main concern right now is where and how it's being *called* when a non-NULL `resp_cb` is passed. I need to understand the scenarios where a callback function is provided, since that suggests asynchronous operation or some sort of result handling that's more involved than a simple return value. I need to understand the flow and the logic surrounding these calls. Where is this function being used and why? What's the context? Is it related to DMA, interrupt handling, or something else entirely? A non-NULL `resp_cb` is my primary focus; I want to follow that thread.
|
| 17/2 |
2026/05/31 02:10 |
tool |
grepper |
0m
Error:
Args: map[Expression:virtio_gpu_get_vbuf.*, [a-zA-Z_]+_cb PathPrefix:drivers/gpu/drm/virtio]
Results:
|
| 18/2 |
2026/05/31 02:10 |
llm |
expert |
0m
Model:
Tokens:
input: 18427
output: 30
thoughts: 21
Thoughts: Okay, here's my interpretation of that thought process, tailored for an expert audience:
**Quick Driver Exploration: Hunting for Callback Functions**
Right, so I need to understand what's going on in the `drivers/gpu/drm/virtio` directory, likely related to the graphics driver for the VirtIO virtual machine environment. Instead of wading through the entire codebase, I'm going to start with a very targeted search. I'm thinking, "Let's just grep for `_cb`." That suffix is a pretty strong indicator of a callback function. It's a common naming convention for function pointers or handler routines that get invoked in response to specific events or requests within the driver. By grepping for that pattern, I'm expecting to quickly identify the key points of interaction between the VirtIO front end and the DRM backend, or maybe even identify interrupt handlers. This is a good initial strategy; quick win, hopefully. Then I can narrow it down once I have a foothold.
|
| 19/2 |
2026/05/31 02:10 |
tool |
grepper |
0m
Args: map[Expression:_cb PathPrefix:drivers/gpu/drm/virtio]
Results: map[Output:drivers/gpu/drm/virtio/virtgpu_drv.h=130=struct virtio_gpu_device;
drivers/gpu/drm/virtio/virtgpu_drv.h-131-
drivers/gpu/drm/virtio/virtgpu_drv.h:132:typedef void (*virtio_gpu_resp_cb)(struct virtio_gpu_device *vgdev,
drivers/gpu/drm/virtio/virtgpu_drv.h-133- struct virtio_gpu_vbuffer *vbuf);
--
drivers/gpu/drm/virtio/virtgpu_drv.h=158=struct virtio_gpu_vbuffer {
--
drivers/gpu/drm/virtio/virtgpu_drv.h-166- int resp_size;
drivers/gpu/drm/virtio/virtgpu_drv.h:167: virtio_gpu_resp_cb resp_cb;
drivers/gpu/drm/virtio/virtgpu_drv.h:168: void *resp_cb_data;
drivers/gpu/drm/virtio/virtgpu_drv.h-169-
--
drivers/gpu/drm/virtio/virtgpu_vq.c=92=virtio_gpu_panic_get_vbuf(struct virtio_gpu_device *vgdev, int size)
--
drivers/gpu/drm/virtio/virtgpu_vq.c-99- vbuf->size = size;
drivers/gpu/drm/virtio/virtgpu_vq.c:100: vbuf->resp_cb = NULL;
drivers/gpu/drm/virtio/virtgpu_vq.c-101- vbuf->resp_size = sizeof(struct virtio_gpu_ctrl_hdr);
--
drivers/gpu/drm/virtio/virtgpu_vq.c=107=virtio_gpu_get_vbuf(struct virtio_gpu_device *vgdev,
drivers/gpu/drm/virtio/virtgpu_vq.c-108- int size, int resp_size, void *resp_buf,
drivers/gpu/drm/virtio/virtgpu_vq.c:109: virtio_gpu_resp_cb resp_cb)
drivers/gpu/drm/virtio/virtgpu_vq.c-110-{
--
drivers/gpu/drm/virtio/virtgpu_vq.c-119-
drivers/gpu/drm/virtio/virtgpu_vq.c:120: vbuf->resp_cb = resp_cb;
drivers/gpu/drm/virtio/virtgpu_vq.c-121- vbuf->resp_size = resp_size;
--
drivers/gpu/drm/virtio/virtgpu_vq.c=169=static void *virtio_gpu_alloc_cmd_resp(struct virtio_gpu_device *vgdev,
drivers/gpu/drm/virtio/virtgpu_vq.c:170: virtio_gpu_resp_cb cb,
drivers/gpu/drm/virtio/virtgpu_vq.c-171- struct virtio_gpu_vbuffer **vbuffer_p,
--
drivers/gpu/drm/virtio/virtgpu_vq.c=183=static void *virtio_gpu_alloc_cmd(struct virtio_gpu_device *vgdev,
--
drivers/gpu/drm/virtio/virtgpu_vq.c-191-
drivers/gpu/drm/virtio/virtgpu_vq.c:192:static void *virtio_gpu_alloc_cmd_cb(struct virtio_gpu_device *vgdev,
drivers/gpu/drm/virtio/virtgpu_vq.c-193- struct virtio_gpu_vbuffer **vbuffer_p,
drivers/gpu/drm/virtio/virtgpu_vq.c-194- int size,
drivers/gpu/drm/virtio/virtgpu_vq.c:195: virtio_gpu_resp_cb cb)
drivers/gpu/drm/virtio/virtgpu_vq.c-196-{
--
drivers/gpu/drm/virtio/virtgpu_vq.c=225=void virtio_gpu_dequeue_ctrl_func(struct work_struct *work)
--
drivers/gpu/drm/virtio/virtgpu_vq.c-237- do {
drivers/gpu/drm/virtio/virtgpu_vq.c:238: virtqueue_disable_cb(vgdev->ctrlq.vq);
drivers/gpu/drm/virtio/virtgpu_vq.c-239- reclaim_vbufs(vgdev->ctrlq.vq, &reclaim_list);
drivers/gpu/drm/virtio/virtgpu_vq.c-240-
drivers/gpu/drm/virtio/virtgpu_vq.c:241: } while (!virtqueue_enable_cb(vgdev->ctrlq.vq));
drivers/gpu/drm/virtio/virtgpu_vq.c-242- spin_unlock(&vgdev->ctrlq.qlock);
--
drivers/gpu/drm/virtio/virtgpu_vq.c-263- }
drivers/gpu/drm/virtio/virtgpu_vq.c:264: if (entry->resp_cb)
drivers/gpu/drm/virtio/virtgpu_vq.c:265: entry->resp_cb(vgdev, entry);
drivers/gpu/drm/virtio/virtgpu_vq.c-266- }
--
drivers/gpu/drm/virtio/virtgpu_vq.c=277=void virtio_gpu_dequeue_cursor_func(struct work_struct *work)
--
drivers/gpu/drm/virtio/virtgpu_vq.c-287- do {
drivers/gpu/drm/virtio/virtgpu_vq.c:288: virtqueue_disable_cb(vgdev->cursorq.vq);
drivers/gpu/drm/virtio/virtgpu_vq.c-289- reclaim_vbufs(vgdev->cursorq.vq, &reclaim_list);
drivers/gpu/drm/virtio/virtgpu_vq.c:290: } while (!virtqueue_enable_cb(vgdev->cursorq.vq));
drivers/gpu/drm/virtio/virtgpu_vq.c-291- spin_unlock(&vgdev->cursorq.qlock);
--
drivers/gpu/drm/virtio/virtgpu_vq.c=594=void virtio_gpu_cmd_create_resource(struct virtio_gpu_device *vgdev,
--
drivers/gpu/drm/virtio/virtgpu_vq.c-616-
drivers/gpu/drm/virtio/virtgpu_vq.c:617:static void virtio_gpu_cmd_unref_cb(struct virtio_gpu_device *vgdev,
drivers/gpu/drm/virtio/virtgpu_vq.c-618- struct virtio_gpu_vbuffer *vbuf)
--
drivers/gpu/drm/virtio/virtgpu_vq.c-621-
drivers/gpu/drm/virtio/virtgpu_vq.c:622: bo = vbuf->resp_cb_data;
drivers/gpu/drm/virtio/virtgpu_vq.c:623: vbuf->resp_cb_data = NULL;
drivers/gpu/drm/virtio/virtgpu_vq.c-624-
--
drivers/gpu/drm/virtio/virtgpu_vq.c=628=void virtio_gpu_cmd_unref_resource(struct virtio_gpu_device *vgdev,
--
drivers/gpu/drm/virtio/virtgpu_vq.c-634-
drivers/gpu/drm/virtio/virtgpu_vq.c:635: cmd_p = virtio_gpu_alloc_cmd_cb(vgdev, &vbuf, sizeof(*cmd_p),
drivers/gpu/drm/virtio/virtgpu_vq.c:636: virtio_gpu_cmd_unref_cb);
drivers/gpu/drm/virtio/virtgpu_vq.c-637- memset(cmd_p, 0, sizeof(*cmd_p));
--
drivers/gpu/drm/virtio/virtgpu_vq.c-641-
drivers/gpu/drm/virtio/virtgpu_vq.c:642: vbuf->resp_cb_data = bo;
drivers/gpu/drm/virtio/virtgpu_vq.c-643- ret = virtio_gpu_queue_ctrl_buffer(vgdev, vbuf);
--
drivers/gpu/drm/virtio/virtgpu_vq.c=803=virtio_gpu_cmd_resource_detach_backing(struct virtio_gpu_device *vgdev,
--
drivers/gpu/drm/virtio/virtgpu_vq.c-818-
drivers/gpu/drm/virtio/virtgpu_vq.c:819:static void virtio_gpu_cmd_get_display_info_cb(struct virtio_gpu_device *vgdev,
drivers/gpu/drm/virtio/virtgpu_vq.c-820- struct virtio_gpu_vbuffer *vbuf)
--
drivers/gpu/drm/virtio/virtgpu_vq.c-847-
drivers/gpu/drm/virtio/virtgpu_vq.c:848:static void virtio_gpu_cmd_get_capset_info_cb(struct virtio_gpu_device *vgdev,
drivers/gpu/drm/virtio/virtgpu_vq.c-849- struct virtio_gpu_vbuffer *vbuf)
--
drivers/gpu/drm/virtio/virtgpu_vq.c-868-
drivers/gpu/drm/virtio/virtgpu_vq.c:869:static void virtio_gpu_cmd_capset_cb(struct virtio_gpu_device *vgdev,
drivers/gpu/drm/virtio/virtgpu_vq.c-870- struct virtio_gpu_vbuffer *vbuf)
--
drivers/gpu/drm/virtio/virtgpu_vq.c=894=static int virtio_get_edid_block(void *data, u8 *buf,
--
drivers/gpu/drm/virtio/virtgpu_vq.c-905-
drivers/gpu/drm/virtio/virtgpu_vq.c:906:static void virtio_gpu_cmd_get_edid_cb(struct virtio_gpu_device *vgdev,
drivers/gpu/drm/virtio/virtgpu_vq.c-907- struct virtio_gpu_vbuffer *vbuf)
--
drivers/gpu/drm/virtio/virtgpu_vq.c=933=int virtio_gpu_cmd_get_display_info(struct virtio_gpu_device *vgdev)
--
drivers/gpu/drm/virtio/virtgpu_vq.c-943- cmd_p = virtio_gpu_alloc_cmd_resp
drivers/gpu/drm/virtio/virtgpu_vq.c:944: (vgdev, &virtio_gpu_cmd_get_display_info_cb, &vbuf,
drivers/gpu/drm/virtio/virtgpu_vq.c-945- sizeof(*cmd_p), sizeof(struct virtio_gpu_resp_display_info),
--
drivers/gpu/drm/virtio/virtgpu_vq.c=955=int virtio_gpu_cmd_get_capset_info(struct virtio_gpu_device *vgdev, int idx)
--
drivers/gpu/drm/virtio/virtgpu_vq.c-965- cmd_p = virtio_gpu_alloc_cmd_resp
drivers/gpu/drm/virtio/virtgpu_vq.c:966: (vgdev, &virtio_gpu_cmd_get_capset_info_cb, &vbuf,
drivers/gpu/drm/virtio/virtgpu_vq.c-967- sizeof(*cmd_p), sizeof(struct virtio_gpu_resp_capset_info),
--
drivers/gpu/drm/virtio/virtgpu_vq.c=977=int virtio_gpu_cmd_get_capset(struct virtio_gpu_device *vgdev,
--
drivers/gpu/drm/virtio/virtgpu_vq.c-1040- cmd_p = virtio_gpu_alloc_cmd_resp
drivers/gpu/drm/virtio/virtgpu_vq.c:1041: (vgdev, &virtio_gpu_cmd_capset_cb, &vbuf, sizeof(*cmd_p),
drivers/gpu/drm/virtio/virtgpu_vq.c-1042- sizeof(struct virtio_gpu_resp_capset) + max_size,
--
drivers/gpu/drm/virtio/virtgpu_vq.c=1053=int virtio_gpu_cmd_get_edids(struct virtio_gpu_device *vgdev)
--
drivers/gpu/drm/virtio/virtgpu_vq.c-1068- cmd_p = virtio_gpu_alloc_cmd_resp
drivers/gpu/drm/virtio/virtgpu_vq.c:1069: (vgdev, &virtio_gpu_cmd_get_edid_cb, &vbuf,
drivers/gpu/drm/virtio/virtgpu_vq.c-1070- sizeof(*cmd_p), sizeof(struct virtio_gpu_resp_edid),
--
drivers/gpu/drm/virtio/virtgpu_vq.c=1296=void virtio_gpu_cursor_ping(struct virtio_gpu_device *vgdev,
--
drivers/gpu/drm/virtio/virtgpu_vq.c-1307-
drivers/gpu/drm/virtio/virtgpu_vq.c:1308:static void virtio_gpu_cmd_resource_uuid_cb(struct virtio_gpu_device *vgdev,
drivers/gpu/drm/virtio/virtgpu_vq.c-1309- struct virtio_gpu_vbuffer *vbuf)
--
drivers/gpu/drm/virtio/virtgpu_vq.c=1333=virtio_gpu_cmd_resource_assign_uuid(struct virtio_gpu_device *vgdev,
--
drivers/gpu/drm/virtio/virtgpu_vq.c-1350- cmd_p = virtio_gpu_alloc_cmd_resp
drivers/gpu/drm/virtio/virtgpu_vq.c:1351: (vgdev, virtio_gpu_cmd_resource_uuid_cb, &vbuf, sizeof(*cmd_p),
drivers/gpu/drm/virtio/virtgpu_vq.c-1352- sizeof(struct virtio_gpu_resp_resource_uuid), resp_buf);
--
drivers/gpu/drm/virtio/virtgpu_vq.c-1362-
drivers/gpu/drm/virtio/virtgpu_vq.c:1363:static void virtio_gpu_cmd_resource_map_cb(struct virtio_gpu_device *vgdev,
drivers/gpu/drm/virtio/virtgpu_vq.c-1364- struct virtio_gpu_vbuffer *vbuf)
--
drivers/gpu/drm/virtio/virtgpu_vq.c=1386=int virtio_gpu_cmd_map(struct virtio_gpu_device *vgdev,
--
drivers/gpu/drm/virtio/virtgpu_vq.c-1398- cmd_p = virtio_gpu_alloc_cmd_resp
drivers/gpu/drm/virtio/virtgpu_vq.c:1399: (vgdev, virtio_gpu_cmd_resource_map_cb, &vbuf, sizeof(*cmd_p),
drivers/gpu/drm/virtio/virtgpu_vq.c-1400- sizeof(struct virtio_gpu_resp_map_info), resp_buf);
]
|
| 20/2 |
2026/05/31 02:10 |
llm |
expert |
0m
Model:
Tokens:
input: 22662
output: 43
thoughts: 20
Thoughts: Okay, let's dive into this. Here's my thought process on what we're looking at, summarized from an expert perspective:
**Analyzing the `virtio_gpu_cmd_get_display_info_cb` Callback**
Alright, so the focus is on the `virtio_gpu_cmd_get_display_info_cb` callback. My immediate thought is, this is a crucial function within the virtio-gpu driver. It's almost certainly the routine responsible for handling the command from the guest OS that asks for information about the display configuration. Thinking about it, this is a pretty fundamental part of the interaction. The guest needs to know about available display outputs, their resolutions, refresh rates, etc., before it can actually start drawing anything. This callback is the bridge between the guest's request and the host's understanding of the underlying hardware or emulated display setup. I'll need to remember to check how it deals with multiple displays and any potential complexities there. I'll want to verify that the information is accurate, up-to-date, and consistently reported to the guest. I need to know the details of what it reports; what does the "get" aspect encompass? Is it a lookup? A calculation? A combination?
|
| 21/2 |
2026/05/31 02:10 |
tool |
read-file |
0m
Args: map[File:drivers/gpu/drm/virtio/virtgpu_vq.c FirstLine:819 LineCount:25]
Results: map[Contents: 819: static void virtio_gpu_cmd_get_display_info_cb(struct virtio_gpu_device *vgdev,
820: struct virtio_gpu_vbuffer *vbuf)
821: {
822: struct virtio_gpu_resp_display_info *resp =
823: (struct virtio_gpu_resp_display_info *)vbuf->resp_buf;
824: int i;
825:
826: spin_lock(&vgdev->display_info_lock);
827: for (i = 0; i < vgdev->num_scanouts; i++) {
828: vgdev->outputs[i].info = resp->pmodes[i];
829: if (resp->pmodes[i].enabled) {
830: DRM_DEBUG("output %d: %dx%d+%d+%d", i,
831: le32_to_cpu(resp->pmodes[i].r.width),
832: le32_to_cpu(resp->pmodes[i].r.height),
833: le32_to_cpu(resp->pmodes[i].r.x),
834: le32_to_cpu(resp->pmodes[i].r.y));
835: } else {
836: DRM_DEBUG("output %d: disabled", i);
837: }
838: }
839:
840: vgdev->display_info_pending = false;
841: spin_unlock(&vgdev->display_info_lock);
842: wake_up(&vgdev->resp_wq);
843:
]
|
| 22/2 |
2026/05/31 02:10 |
llm |
expert |
0m
Model:
Tokens:
input: 23472
output: 43
thoughts: 52
Thoughts: Here's my thought process, summarized as if I were considering the code:
**Digging into the VirtIO-GPU Driver**
Okay, hold on a second. I was under the impression that `virtio_gpu_cmd_get_display_info_cb` was the function that triggered a `drm_client_dev_hotplug` call, but it doesn't seem to be. That's unexpected, and I need to figure out how display info is getting updated. It's time to trace the hotplug flow.
Let me take a quick look at `virtio_gpu_cmd_get_edid_cb` now, and see if the EDID retrieval is involved in the hotplug handling logic. Perhaps this function holds the key. The display information has to be refreshed somehow.
|
| 23/2 |
2026/05/31 02:10 |
tool |
read-file |
0m
Args: map[File:drivers/gpu/drm/virtio/virtgpu_vq.c FirstLine:906 LineCount:25]
Results: map[Contents: 906: static void virtio_gpu_cmd_get_edid_cb(struct virtio_gpu_device *vgdev,
907: struct virtio_gpu_vbuffer *vbuf)
908: {
909: struct virtio_gpu_cmd_get_edid *cmd =
910: (struct virtio_gpu_cmd_get_edid *)vbuf->buf;
911: struct virtio_gpu_resp_edid *resp =
912: (struct virtio_gpu_resp_edid *)vbuf->resp_buf;
913: uint32_t scanout = le32_to_cpu(cmd->scanout);
914: struct virtio_gpu_output *output;
915: const struct drm_edid *new_edid, *old_edid;
916:
917: if (scanout >= vgdev->num_scanouts)
918: return;
919: output = vgdev->outputs + scanout;
920:
921: new_edid = drm_edid_read_custom(&output->conn, virtio_get_edid_block, resp);
922: drm_edid_connector_update(&output->conn, new_edid);
923:
924: spin_lock(&vgdev->display_info_lock);
925: old_edid = output->drm_edid;
926: output->drm_edid = new_edid;
927: spin_unlock(&vgdev->display_info_lock);
928:
929: drm_edid_free(old_edid);
930: wake_up(&vgdev->resp_wq);
]
|
| 24/2 |
2026/05/31 02:10 |
llm |
expert |
0m
Model:
Tokens:
input: 24229
output: 43
thoughts: 335
Thoughts: **Tracing the Virtio GPU EDID Retrieval**
Okay, hold on a second. I thought `virtio_gpu_cmd_get_edid_cb` was directly calling `drm_edid_connector_update`, but something feels off. Let me retrace this. I need to understand the connection, and that involves figuring out how `drm_client_dev_hotplug` is triggered. Right, let's see where that function is called from.
The stack trace gives me a starting point. It's:
```
drm_client_dev_hotplug+0xdc/0x4f0 drivers/gpu/drm/drm_client_event.c:98
virtio_gpu_dequeue_ctrl_func+0x506/0x8c0 drivers/gpu/drm/virtio/virtgpu_vq.c:265
```
Ah, right. Now I remember. `virtio_gpu_dequeue_ctrl_func` calls `entry->resp_cb(vgdev, entry);` at line 265. So, is `entry->resp_cb` equivalent to `drm_client_dev_hotplug`? No, wait a minute, `drm_client_dev_hotplug` takes a `struct drm_device *dev` argument.
Looking at the stack trace again:
```
drm_client_dev_hotplug+0xdc/0x4f0 drivers/gpu/drm/drm_client_event.c:98
virtio_gpu_dequeue_ctrl_func+0x506/0x8c0 drivers/gpu/drm/virtio/virtgpu_vq.c:265
```
It looks like there's no intermediate function in this call chain. I'm going to have to carefully re-examine `virtio_gpu_dequeue_ctrl_func`. I need to make sure I haven't missed a critical detail in the flow of data or function calls.
|
| 25/2 |
2026/05/31 02:10 |
tool |
read-file |
0m
Args: map[File:drivers/gpu/drm/virtio/virtgpu_vq.c FirstLine:260 LineCount:15]
Results: map[Contents: 260: if (resp->flags & cpu_to_le32(VIRTIO_GPU_FLAG_FENCE)) {
261: fence_id = le64_to_cpu(resp->fence_id);
262: virtio_gpu_fence_event_process(vgdev, fence_id);
263: }
264: if (entry->resp_cb)
265: entry->resp_cb(vgdev, entry);
266: }
267: wake_up(&vgdev->ctrlq.ack_queue);
268:
269: list_for_each_entry_safe(entry, tmp, &reclaim_list, list) {
270: if (entry->objs)
271: virtio_gpu_array_put_free_delayed(vgdev, entry->objs);
272: list_del(&entry->list);
273: free_vbuf(vgdev, entry);
274: }
]
|
| 26/2 |
2026/05/31 02:10 |
llm |
expert |
1m
Model:
Tokens:
input: 25327
output: 43
thoughts: 199
Thoughts: **Digging into the `virtio_gpu` Fence Event Processing**
Okay, so I'm trying to wrap my head around this `virtio_gpu_fence_event_process` function. My initial thought was that it might somehow be tied into `drm_client_dev_hotplug`, but that doesn't quite fit – it's a fence event after all. I need to be sure I understand the call chain.
Now, I'm wondering about `entry->resp_cb`. Is this a simple inline function? Need to clarify how it's being handled. Let's start by inspecting `virtio_gpu_cmd_get_display_info_cb` and some of the other callbacks. Got to make sure there aren't any other instances of `resp_cb` floating around in the code.
Okay, back to `virtio_gpu_cmd_get_display_info_cb`. Aha! I see it calls `wake_up(&vgdev->resp_wq);`. This is starting to make more sense. Now I'm starting to think about a specific call path. What if `virtio_gpu_dequeue_ctrl_func` calls `virtio_gpu_cmd_get_display_info_cb` and that calls `drm_helper_hpd_irq_event`? Need to track that down to confirm the full path.
Okay, let me go back to `virtio_gpu_cmd_get_display_info_cb` again and trace that logic more carefully.
|
| 27/2 |
2026/05/31 02:11 |
tool |
read-file |
0m
Args: map[File:drivers/gpu/drm/virtio/virtgpu_vq.c FirstLine:819 LineCount:35]
Results: map[Contents: 819: static void virtio_gpu_cmd_get_display_info_cb(struct virtio_gpu_device *vgdev,
820: struct virtio_gpu_vbuffer *vbuf)
821: {
822: struct virtio_gpu_resp_display_info *resp =
823: (struct virtio_gpu_resp_display_info *)vbuf->resp_buf;
824: int i;
825:
826: spin_lock(&vgdev->display_info_lock);
827: for (i = 0; i < vgdev->num_scanouts; i++) {
828: vgdev->outputs[i].info = resp->pmodes[i];
829: if (resp->pmodes[i].enabled) {
830: DRM_DEBUG("output %d: %dx%d+%d+%d", i,
831: le32_to_cpu(resp->pmodes[i].r.width),
832: le32_to_cpu(resp->pmodes[i].r.height),
833: le32_to_cpu(resp->pmodes[i].r.x),
834: le32_to_cpu(resp->pmodes[i].r.y));
835: } else {
836: DRM_DEBUG("output %d: disabled", i);
837: }
838: }
839:
840: vgdev->display_info_pending = false;
841: spin_unlock(&vgdev->display_info_lock);
842: wake_up(&vgdev->resp_wq);
843:
844: if (!drm_helper_hpd_irq_event(vgdev->ddev))
845: drm_kms_helper_hotplug_event(vgdev->ddev);
846: }
847:
848: static void virtio_gpu_cmd_get_capset_info_cb(struct virtio_gpu_device *vgdev,
849: struct virtio_gpu_vbuffer *vbuf)
850: {
851: struct virtio_gpu_get_capset_info *cmd =
852: (struct virtio_gpu_get_capset_info *)vbuf->buf;
853: struct virtio_gpu_resp_capset_info *resp =
]
|
| 28/2 |
2026/05/31 02:11 |
llm |
expert |
0m
Model:
Tokens:
input: 26579
output: 41
thoughts: 96
Thoughts: **Tracing the Hotplug Event**
Okay, so I'm digging into this `virtio_gpu_cmd_get_display_info_cb` function and immediately, my brain zeroes in on that call to `drm_kms_helper_hotplug_event(vgdev->ddev)`. Hmm, that looks promising. This seems to be where the magic happens, or at least where the event gets triggered. And, of course, that call branches into `drm_client_dev_hotplug`. Now, I want to confirm my understanding of the flow, so I'll quickly check the definition of `drm_kms_helper_hotplug_event`. I'll head over to `drivers/gpu/drm/drm_probe_helper.c` to refresh my memory on the details of that function. I need to understand exactly how this hotplug event mechanism works within the DRM subsystem.
|
| 29/2 |
2026/05/31 02:11 |
tool |
read-file |
0m
Args: map[File:drivers/gpu/drm/drm_probe_helper.c FirstLine:850 LineCount:20]
Results: map[Contents: 850: if (repoll)
851: schedule_delayed_work(delayed_work, DRM_OUTPUT_POLL_PERIOD);
852: }
853:
854: /**
855: * drm_kms_helper_is_poll_worker - is %current task an output poll worker?
856: *
857: * Determine if %current task is an output poll worker. This can be used
858: * to select distinct code paths for output polling versus other contexts.
859: *
860: * One use case is to avoid a deadlock between the output poll worker and
861: * the autosuspend worker wherein the latter waits for polling to finish
862: * upon calling drm_kms_helper_poll_disable(), while the former waits for
863: * runtime suspend to finish upon calling pm_runtime_get_sync() in a
864: * connector ->detect hook.
865: */
866: bool drm_kms_helper_is_poll_worker(void)
867: {
868: struct work_struct *work = current_work();
869:
]
|
| 30/2 |
2026/05/31 02:11 |
llm |
expert |
0m
Model:
Tokens:
input: 27237
output: 35
thoughts: 16
Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience and written in the first person:
**Chasing the Hotplug**
Alright, let's get down to brass tacks. I need to understand the kernel's hotplug handling within the DRM/KMS framework. Specifically, I'm after the core event handling function. My initial hunch is that it's going to be somewhere within the `drm_kms_helper` area, given its role in simplifying KMS driver interaction. So, my mental search immediately focuses on finding `drm_kms_helper_hotplug_event`. The name itself is fairly explicit, which should speed things up. I'm expecting this function to be the central point where the kernel signals and coordinates events related to display devices being connected or disconnected, which is obviously critical for the system's display functionality. Knowing the naming conventions, I have a pretty good idea of what I will find: a signal, maybe some interrupt handling, perhaps interactions with the modesetting code. Let's see if this hunch holds water. Time to delve into the code!
|
| 31/2 |
2026/05/31 02:11 |
tool |
grepper |
0m
Args: map[Expression:drm_kms_helper_hotplug_event PathPrefix:drivers/gpu/drm]
Results: map[Output:drivers/gpu/drm/amd/amdgpu/amdgpu_device.c=5305=int amdgpu_device_resume(struct drm_device *dev, bool notify_clients)
--
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c-5391- else
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c:5392: drm_kms_helper_hotplug_event(dev);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c-5393-#ifdef CONFIG_PM
--
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c=3469=static int dm_resume(struct amdgpu_ip_block *ip_block)
--
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c-3685-
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c:3686: drm_kms_helper_hotplug_event(ddev);
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c-3687-
--
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c=3996=static void hdmi_hpd_debounce_work(struct work_struct *work)
--
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c-4039- if (!fake_reconnect && aconnector->base.force == DRM_FORCE_UNSPECIFIED)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c:4040: drm_kms_helper_hotplug_event(dev);
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c-4041- }
--
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c=5808=static ssize_t s3_debug_store(struct device *device,
--
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c-5827- dm_resume(ip_block);
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c:5828: drm_kms_helper_hotplug_event(adev_to_drm(adev));
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c-5829- } else
--
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c=7693=static ssize_t panel_power_savings_store(struct device *device,
--
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c-7720-
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c:7721: drm_kms_helper_hotplug_event(dev);
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c-7722-
--
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c=391=static ssize_t dp_mst_link_setting(struct file *f, const char __user *buf,
--
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c-480- mutex_unlock(&aconnector->base.dev->mode_config.mutex);
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c:481: drm_kms_helper_hotplug_event(aconnector->base.dev);
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c-482-
--
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c-487- mutex_unlock(&aconnector->base.dev->mode_config.mutex);
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c:488: drm_kms_helper_hotplug_event(aconnector->base.dev);
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c-489-
--
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c=4011=static int trigger_hpd_mst_set(void *data, u64 val)
--
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c-4058- }
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c:4059: drm_kms_helper_hotplug_event(dev);
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c-4060-
--
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c=711=static void cdns_mhdp_fw_cb(const struct firmware *fw, void *context)
--
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c-732- * XXX how to make sure the bridge is still attached when
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c:733: * calling drm_kms_helper_hotplug_event() after releasing
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c-734- * the lock? We should not hold the spin lock when
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c:735: * calling drm_kms_helper_hotplug_event() since it may
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c-736- * cause a dead lock. FB-dev console calls detect from the
--
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c-743- if (mhdp->connector.dev)
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c:744: drm_kms_helper_hotplug_event(mhdp->bridge.dev);
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c-745- else
--
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c=2292=static void cdns_mhdp_modeset_retry_fn(struct work_struct *work)
--
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c-2311- /* Send Hotplug uevent so userspace can reprobe */
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c:2312: drm_kms_helper_hotplug_event(mhdp->bridge.dev);
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c-2313-}
--
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c=2315=static irqreturn_t cdns_mhdp_irq_handler(int irq, void *data)
--
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c-2327- /*
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c:2328: * Calling drm_kms_helper_hotplug_event() when not attached
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c-2329- * to drm device causes an oops because the drm_bridge->dev
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c-2330- * is NULL. See cdns_mhdp_fw_cb() comments for details about the
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c:2331: * problems related drm_kms_helper_hotplug_event() call.
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c-2332- */
--
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c=2368=static void cdns_mhdp_hpd_work(struct work_struct *work)
--
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c-2379- else
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c:2380: drm_kms_helper_hotplug_event(mhdp->bridge.dev);
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c-2381- } else {
--
drivers/gpu/drm/bridge/lontium-lt9611.c=372=static irqreturn_t lt9611_irq_thread_handler(int irq, void *dev_id)
--
drivers/gpu/drm/bridge/lontium-lt9611.c-397- if (irq_flag3 & 0xc0 && lt9611->bridge.dev)
drivers/gpu/drm/bridge/lontium-lt9611.c:398: drm_kms_helper_hotplug_event(lt9611->bridge.dev);
drivers/gpu/drm/bridge/lontium-lt9611.c-399-
--
drivers/gpu/drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c=178=static irqreturn_t ge_b850v3_lvds_irq_handler(int irq, void *dev_id)
--
drivers/gpu/drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c-187- if (ge_b850v3_lvds_ptr->bridge.dev)
drivers/gpu/drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c:188: drm_kms_helper_hotplug_event(ge_b850v3_lvds_ptr->bridge.dev);
drivers/gpu/drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c-189-
--
drivers/gpu/drm/bridge/tc358767.c=2227=static irqreturn_t tc_irq_handler(int irq, void *arg)
--
drivers/gpu/drm/bridge/tc358767.c-2260- h ? "H" : "", lc ? "LC" : "");
drivers/gpu/drm/bridge/tc358767.c:2261: drm_kms_helper_hotplug_event(tc->bridge.dev);
drivers/gpu/drm/bridge/tc358767.c-2262- }
--
drivers/gpu/drm/bridge/tda998x_drv.c=778=static void tda998x_detect_work(struct work_struct *work)
--
drivers/gpu/drm/bridge/tda998x_drv.c-784- if (dev)
drivers/gpu/drm/bridge/tda998x_drv.c:785: drm_kms_helper_hotplug_event(dev);
drivers/gpu/drm/bridge/tda998x_drv.c-786-}
--
drivers/gpu/drm/bridge/ti-sn65dsi86.c=1378=static irqreturn_t ti_sn_bridge_interrupt(int irq, void *private)
--
drivers/gpu/drm/bridge/ti-sn65dsi86.c-1406- if (pdata->hpd_enabled && hpd_event)
drivers/gpu/drm/bridge/ti-sn65dsi86.c:1407: drm_kms_helper_hotplug_event(dev);
drivers/gpu/drm/bridge/ti-sn65dsi86.c-1408- mutex_unlock(&pdata->hpd_mutex);
--
drivers/gpu/drm/display/drm_dp_mst_topology.c=2654=static void drm_dp_mst_link_probe_work(struct work_struct *work)
--
drivers/gpu/drm/display/drm_dp_mst_topology.c-2698- if (ret > 0)
drivers/gpu/drm/display/drm_dp_mst_topology.c:2699: drm_kms_helper_hotplug_event(dev);
drivers/gpu/drm/display/drm_dp_mst_topology.c-2700-}
--
drivers/gpu/drm/display/drm_dp_mst_topology.c=4096=static void drm_dp_mst_up_req_work(struct work_struct *work)
--
drivers/gpu/drm/display/drm_dp_mst_topology.c-4122- if (send_hotplug)
drivers/gpu/drm/display/drm_dp_mst_topology.c:4123: drm_kms_helper_hotplug_event(mgr->dev);
drivers/gpu/drm/display/drm_dp_mst_topology.c-4124-}
--
drivers/gpu/drm/display/drm_dp_mst_topology.c=5065=static void drm_dp_delayed_destroy_work(struct work_struct *work)
--
drivers/gpu/drm/display/drm_dp_mst_topology.c-5118- if (send_hotplug)
drivers/gpu/drm/display/drm_dp_mst_topology.c:5119: drm_kms_helper_hotplug_event(mgr->dev);
drivers/gpu/drm/display/drm_dp_mst_topology.c-5120-}
--
drivers/gpu/drm/drm_client_event.c=54=static void drm_client_hotplug(struct drm_client_dev *client)
--
drivers/gpu/drm/drm_client_event.c-82- *
drivers/gpu/drm/drm_client_event.c:83: * drm_kms_helper_hotplug_event() calls this function, so drivers that use it
drivers/gpu/drm/drm_client_event.c-84- * don't need to call this function themselves.
--
drivers/gpu/drm/drm_probe_helper.c=712=EXPORT_SYMBOL(drm_helper_probe_single_connector_modes);
--
drivers/gpu/drm/drm_probe_helper.c-714-/**
drivers/gpu/drm/drm_probe_helper.c:715: * drm_kms_helper_hotplug_event - fire off KMS hotplug events
drivers/gpu/drm/drm_probe_helper.c-716- * @dev: drm_device whose connector state changed
--
drivers/gpu/drm/drm_probe_helper.c-732- */
drivers/gpu/drm/drm_probe_helper.c:733:void drm_kms_helper_hotplug_event(struct drm_device *dev)
drivers/gpu/drm/drm_probe_helper.c-734-{
--
drivers/gpu/drm/drm_probe_helper.c-737-}
drivers/gpu/drm/drm_probe_helper.c:738:EXPORT_SYMBOL(drm_kms_helper_hotplug_event);
drivers/gpu/drm/drm_probe_helper.c-739-
--
drivers/gpu/drm/drm_probe_helper.c-743- *
drivers/gpu/drm/drm_probe_helper.c:744: * This is the same as drm_kms_helper_hotplug_event(), except it fires a more
drivers/gpu/drm/drm_probe_helper.c-745- * fine-grained uevent for a single connector.
--
drivers/gpu/drm/drm_probe_helper.c=756=static void output_poll_execute(struct work_struct *work)
--
drivers/gpu/drm/drm_probe_helper.c-847- if (changed)
drivers/gpu/drm/drm_probe_helper.c:848: drm_kms_helper_hotplug_event(dev);
drivers/gpu/drm/drm_probe_helper.c-849-
--
drivers/gpu/drm/drm_probe_helper.c=1053=EXPORT_SYMBOL(drm_connector_helper_hpd_irq_event);
--
drivers/gpu/drm/drm_probe_helper.c-1069- * drm_connector_helper_hpd_irq_event(). Alternatively, they should bypass this
drivers/gpu/drm/drm_probe_helper.c:1070: * code and directly call drm_kms_helper_hotplug_event() in case the connector
drivers/gpu/drm/drm_probe_helper.c-1071- * state changed.
--
drivers/gpu/drm/drm_probe_helper.c=1082=bool drm_helper_hpd_irq_event(struct drm_device *dev)
--
drivers/gpu/drm/drm_probe_helper.c-1112- else if (changed > 0)
drivers/gpu/drm/drm_probe_helper.c:1113: drm_kms_helper_hotplug_event(dev);
drivers/gpu/drm/drm_probe_helper.c-1114-
--
drivers/gpu/drm/exynos/exynos_drm_dsi.c=36=static int exynos_dsi_host_attach(struct samsung_dsim *dsim,
--
drivers/gpu/drm/exynos/exynos_drm_dsi.c-58- if (drm->mode_config.poll_enabled)
drivers/gpu/drm/exynos/exynos_drm_dsi.c:59: drm_kms_helper_hotplug_event(drm);
drivers/gpu/drm/exynos/exynos_drm_dsi.c-60-
--
drivers/gpu/drm/exynos/exynos_drm_dsi.c=64=static void exynos_dsi_host_detach(struct samsung_dsim *dsim,
--
drivers/gpu/drm/exynos/exynos_drm_dsi.c-70- if (drm->mode_config.poll_enabled)
drivers/gpu/drm/exynos/exynos_drm_dsi.c:71: drm_kms_helper_hotplug_event(drm);
drivers/gpu/drm/exynos/exynos_drm_dsi.c-72-}
--
drivers/gpu/drm/i915/display/intel_dp_test.c=523=bool intel_dp_test_short_pulse(struct intel_dp *intel_dp)
--
drivers/gpu/drm/i915/display/intel_dp_test.c-532- /* Send a Hotplug Uevent to userspace to start modeset */
drivers/gpu/drm/i915/display/intel_dp_test.c:533: drm_kms_helper_hotplug_event(display->drm);
drivers/gpu/drm/i915/display/intel_dp_test.c-534- break;
--
drivers/gpu/drm/i915/display/intel_hotplug.c-67- * detect hooks, and, if connector status changes, triggers sending of hotplug
drivers/gpu/drm/i915/display/intel_hotplug.c:68: * uevent to userspace via drm_kms_helper_hotplug_event().
drivers/gpu/drm/i915/display/intel_hotplug.c-69- *
--
drivers/gpu/drm/i915/display/intel_hotplug.c=468=static void i915_hotplug_work_func(struct work_struct *work)
--
drivers/gpu/drm/i915/display/intel_hotplug.c-551- else if (changed_connectors > 0)
drivers/gpu/drm/i915/display/intel_hotplug.c:552: drm_kms_helper_hotplug_event(display->drm);
drivers/gpu/drm/i915/display/intel_hotplug.c-553-
--
drivers/gpu/drm/i915/display/intel_hotplug.c=739=static void i915_hpd_poll_detect_connectors(struct intel_display *display)
--
drivers/gpu/drm/i915/display/intel_hotplug.c-776- else
drivers/gpu/drm/i915/display/intel_hotplug.c:777: drm_kms_helper_hotplug_event(display->drm);
drivers/gpu/drm/i915/display/intel_hotplug.c-778-
--
drivers/gpu/drm/nouveau/dispnv50/disp.c=1481=nv50_mstm_init(struct nouveau_encoder *outp, bool runtime)
--
drivers/gpu/drm/nouveau/dispnv50/disp.c-1499- if (ret == -1)
drivers/gpu/drm/nouveau/dispnv50/disp.c:1500: drm_kms_helper_hotplug_event(mstm->mgr.dev);
drivers/gpu/drm/nouveau/dispnv50/disp.c-1501-}
--
drivers/gpu/drm/nouveau/nouveau_display.c=422=nouveau_display_hpd_work(struct work_struct *work)
--
drivers/gpu/drm/nouveau/nouveau_display.c-492- else if (changed > 0)
drivers/gpu/drm/nouveau/nouveau_display.c:493: drm_kms_helper_hotplug_event(dev);
drivers/gpu/drm/nouveau/nouveau_display.c-494-
--
drivers/gpu/drm/qxl/qxl_display.c=169=void qxl_display_read_client_monitors_config(struct qxl_device *qdev)
--
drivers/gpu/drm/qxl/qxl_display.c-199- adjust at the arbitrary resolution */
drivers/gpu/drm/qxl/qxl_display.c:200: drm_kms_helper_hotplug_event(dev);
drivers/gpu/drm/qxl/qxl_display.c-201- }
--
drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c=962=static int sun6i_dsi_attach(struct mipi_dsi_host *host,
--
drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c-975-
drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c:976: drm_kms_helper_hotplug_event(dsi->drm);
drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c-977-
--
drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c=983=static int sun6i_dsi_detach(struct mipi_dsi_host *host,
--
drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c-990-
drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c:991: drm_kms_helper_hotplug_event(dsi->drm);
drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c-992-
--
drivers/gpu/drm/vboxvideo/vbox_irq.c=164=static void vbox_hotplug_worker(struct work_struct *work)
--
drivers/gpu/drm/vboxvideo/vbox_irq.c-169- vbox_update_mode_hints(vbox);
drivers/gpu/drm/vboxvideo/vbox_irq.c:170: drm_kms_helper_hotplug_event(&vbox->ddev);
drivers/gpu/drm/vboxvideo/vbox_irq.c-171-}
--
drivers/gpu/drm/virtio/virtgpu_vq.c=819=static void virtio_gpu_cmd_get_display_info_cb(struct virtio_gpu_device *vgdev,
--
drivers/gpu/drm/virtio/virtgpu_vq.c-844- if (!drm_helper_hpd_irq_event(vgdev->ddev))
drivers/gpu/drm/virtio/virtgpu_vq.c:845: drm_kms_helper_hotplug_event(vgdev->ddev);
drivers/gpu/drm/virtio/virtgpu_vq.c-846-}
--
drivers/gpu/drm/vkms/vkms_connector.c=91=void vkms_trigger_connector_hotplug(struct vkms_device *vkmsdev)
--
drivers/gpu/drm/vkms/vkms_connector.c-94-
drivers/gpu/drm/vkms/vkms_connector.c:95: drm_kms_helper_hotplug_event(dev);
drivers/gpu/drm/vkms/vkms_connector.c-96-}
]
|
| 32/2 |
2026/05/31 02:11 |
llm |
expert |
0m
Model:
Tokens:
input: 34109
output: 39
thoughts: 157
Thoughts: **Analyzing a Potential Race Condition**
Okay, so I'm digging into this code and trying to pinpoint a possible race condition. I see that `virtio_gpu_cmd_get_display_info_cb` calls `drm_kms_helper_hotplug_event`, which, in turn, calls `drm_client_dev_hotplug`. My alarm bells are starting to go off because `drm_client_dev_hotplug` is acquiring `dev->clientlist_mutex`. That's where it gets interesting...
Now, I seem to remember that `swapper/0:1` is *already* holding `dev->clientlist_mutex` in `drm_client_register`. Hold on a minute... did I miss something? Is `drm_client_register` responsible for calling `client->funcs->hotplug` while already holding the mutex? No, scratch that; it calls `drm_client_dev_hotplug`. Okay, I really need to double-check `drm_client_register` to be absolutely certain I've got this right. I need to be precise, or I could miss the root cause of this possible problem!
|
| 33/2 |
2026/05/31 02:12 |
tool |
read-file |
0m
Args: map[File:drivers/gpu/drm/drm_client.c FirstLine:110 LineCount:50]
Results: map[Contents: 110: /**
111: * drm_client_register - Register client
112: * @client: DRM client
113: *
114: * Add the client to the &drm_device client list to activate its callbacks.
115: * @client must be initialized by a call to drm_client_init(). After
116: * drm_client_register() it is no longer permissible to call drm_client_release()
117: * directly (outside the unregister callback), instead cleanup will happen
118: * automatically on driver unload.
119: *
120: * Registering a client generates a hotplug event that allows the client
121: * to set up its display from pre-existing outputs. The client must have
122: * initialized its state to able to handle the hotplug event successfully.
123: */
124: void drm_client_register(struct drm_client_dev *client)
125: {
126: struct drm_device *dev = client->dev;
127: int ret;
128:
129: mutex_lock(&dev->clientlist_mutex);
130: list_add(&client->list, &dev->clientlist);
131:
132: if (client->funcs && client->funcs->hotplug) {
133: /*
134: * Perform an initial hotplug event to pick up the
135: * display configuration for the client. This step
136: * has to be performed *after* registering the client
137: * in the list of clients, or a concurrent hotplug
138: * event might be lost; leaving the display off.
139: *
140: * Hold the clientlist_mutex as for a regular hotplug
141: * event.
142: */
143: ret = client->funcs->hotplug(client);
144: if (ret)
145: drm_dbg_kms(dev, "client hotplug ret=%d\n", ret);
146: }
147: mutex_unlock(&dev->clientlist_mutex);
148: }
149: EXPORT_SYMBOL(drm_client_register);
150:
151: /**
152: * drm_client_release - Release DRM client resources
153: * @client: DRM client
154: *
155: * Releases resources by closing the &drm_file that was opened by drm_client_init().
156: * It is called automatically if the &drm_client_funcs.unregister callback is _not_ set.
157: *
158: * This function should only be called from the unregister callback. An exception
159: * is fbdev which cannot free the buffer if userspace has open file descriptors.
]
|
| 34/2 |
2026/05/31 02:12 |
llm |
expert |
0m
Model:
Tokens:
input: 35346
output: 40
thoughts: 752
Thoughts: **Deadlock Deep Dive: Virtio-GPU and DRM Client Hotplug**
Okay, here's what's happening. I've got a classic deadlock scenario brewing in the virtio-gpu driver, specifically involving the `drm_client_register` function and hotplug events. It seems to hinge on contention for the `dev->clientlist_mutex`.
Essentially, `drm_client_register` is holding the `dev->clientlist_mutex` lock, and then it calls `client->funcs->hotplug(client)`. This `hotplug` function, in our case, is `drm_fbdev_client_hotplug`. This function then triggers a full modeset commit, which queues a control command to the virtio-gpu device. Now, here's the kicker: this queue, the virtqueue, can become full. When it's full, the code waits for the virtqueue to have enough free slots (`vq->num_free >= elemcnt`).
The problem? The virtqueue *is* full because there are pending commands in the system. These pending commands are being handled by `virtio_gpu_dequeue_ctrl_func` running in a kworker thread. However, that function is blocked on `dev->clientlist_mutex`. This is because it is processing a response for `virtio_gpu_cmd_get_display_info_cb`, which, crucially, calls `drm_kms_helper_hotplug_event`, which in turn calls `drm_client_dev_hotplug`. And `drm_client_dev_hotplug` *also* tries to grab that same `dev->clientlist_mutex`!
So, we're stuck in a classic deadlock:
1. We have `swapper/0:1` in init calling `drm_client_register`, acquiring `dev->clientlist_mutex`.
2. `swapper/0:1` then calls `client->funcs->hotplug` which eventually calls `virtio_gpu_queue_ctrl_sgs`.
3. `virtio_gpu_queue_ctrl_sgs` sees a full virtqueue and waits.
4. `kworker/0:0:9` executes `virtio_gpu_dequeue_ctrl_func` to handle completed commands.
5. `kworker/0:0:9` processes `virtio_gpu_cmd_get_display_info_cb`, which leads to a call to `drm_client_dev_hotplug`.
6. `drm_client_dev_hotplug` tries to acquire `dev->clientlist_mutex` and blocks.
7. `kworker/0:0:9` is blocked, so it cannot free up the virtqueue and wake up `swapper/0:1`.
8. Deadlock!
The question now is *why* the virtqueue is full in the first place. The virtqueue has a limited size, and if a bunch of commands are queued up, it's going to fill. It looks like during initialization (the `virtio_gpu_probe` process), or potentially from the modeset commit, lots of commands are queued at once, filling up the virtqueue.
The next question is exploitability. Can this be triggered by a user? This is a deadlock that occurs during either initialization (probe) or a hotplug event. The code flow, specifically `drm_client_register`, is called during device probe, automatically when the virtio-gpu device is probed. `virtio_gpu_probe` calls `drm_client_setup`, which then calls `drm_fbdev_client_setup` which finally calls `drm_client_register`. An unprivileged user can't directly trigger `drm_client_register` because it’s part of the driver initialization. However, can an unprivileged user trigger `virtio_gpu_cmd_get_display_info` via some DRM ioctl? That is the next step.
|
| 35/2 |
2026/05/31 02:12 |
tool |
grepper |
0m
Args: map[Expression:virtio_gpu_cmd_get_display_info PathPrefix:drivers/gpu/drm/virtio]
Results: map[Output:drivers/gpu/drm/virtio/virtgpu_drv.h=371=void virtio_gpu_cursor_ping(struct virtio_gpu_device *vgdev,
drivers/gpu/drm/virtio/virtgpu_drv.h-372- struct virtio_gpu_output *output);
drivers/gpu/drm/virtio/virtgpu_drv.h:373:int virtio_gpu_cmd_get_display_info(struct virtio_gpu_device *vgdev);
drivers/gpu/drm/virtio/virtgpu_drv.h-374-int virtio_gpu_cmd_get_capset_info(struct virtio_gpu_device *vgdev, int idx);
--
drivers/gpu/drm/virtio/virtgpu_kms.c=36=static void virtio_gpu_config_changed_work_func(struct work_struct *work)
--
drivers/gpu/drm/virtio/virtgpu_kms.c-49- virtio_gpu_cmd_get_edids(vgdev);
drivers/gpu/drm/virtio/virtgpu_kms.c:50: virtio_gpu_cmd_get_display_info(vgdev);
drivers/gpu/drm/virtio/virtgpu_kms.c-51- virtio_gpu_notify(vgdev);
--
drivers/gpu/drm/virtio/virtgpu_kms.c=118=int virtio_gpu_init(struct virtio_device *vdev, struct drm_device *dev)
--
drivers/gpu/drm/virtio/virtgpu_kms.c-254- virtio_gpu_cmd_get_edids(vgdev);
drivers/gpu/drm/virtio/virtgpu_kms.c:255: virtio_gpu_cmd_get_display_info(vgdev);
drivers/gpu/drm/virtio/virtgpu_kms.c-256- virtio_gpu_notify(vgdev);
--
drivers/gpu/drm/virtio/virtgpu_vq.c=803=virtio_gpu_cmd_resource_detach_backing(struct virtio_gpu_device *vgdev,
--
drivers/gpu/drm/virtio/virtgpu_vq.c-818-
drivers/gpu/drm/virtio/virtgpu_vq.c:819:static void virtio_gpu_cmd_get_display_info_cb(struct virtio_gpu_device *vgdev,
drivers/gpu/drm/virtio/virtgpu_vq.c-820- struct virtio_gpu_vbuffer *vbuf)
--
drivers/gpu/drm/virtio/virtgpu_vq.c=906=static void virtio_gpu_cmd_get_edid_cb(struct virtio_gpu_device *vgdev,
--
drivers/gpu/drm/virtio/virtgpu_vq.c-932-
drivers/gpu/drm/virtio/virtgpu_vq.c:933:int virtio_gpu_cmd_get_display_info(struct virtio_gpu_device *vgdev)
drivers/gpu/drm/virtio/virtgpu_vq.c-934-{
--
drivers/gpu/drm/virtio/virtgpu_vq.c-943- cmd_p = virtio_gpu_alloc_cmd_resp
drivers/gpu/drm/virtio/virtgpu_vq.c:944: (vgdev, &virtio_gpu_cmd_get_display_info_cb, &vbuf,
drivers/gpu/drm/virtio/virtgpu_vq.c-945- sizeof(*cmd_p), sizeof(struct virtio_gpu_resp_display_info),
]
|
| 36/2 |
2026/05/31 02:12 |
llm |
expert |
0m
Model:
Tokens:
input: 37903
output: 42
thoughts: 359
Thoughts: **Analyzing the Virtio GPU Initialization Deadlock**
Okay, so I'm looking at this `virtio_gpu` initialization flow, and I'm seeing a potential race condition or deadlock. The key function here seems to be `virtio_gpu_cmd_get_display_info`, which gets called in both `virtio_gpu_init` and `virtio_gpu_config_changed_work_func`. I know `virtio_gpu_config_changed_work_func` is a workqueue function – that's triggered by a virtio configuration change interrupt, meaning it's the host, the VMM, telling us something's changed. The question immediately pops into my head: can a guest user somehow trigger this? Probably not directly, unless they can cause a config change, which would be very bad.
But then I remember the deadlock is happening during *boot*, specifically with `swapper/0:1`, the init task. It's probing the device, and that's where `virtio_gpu_init` comes in. `virtio_gpu_init` calls `virtio_gpu_cmd_get_display_info`, then waits for the response. Ah, right, that's it: `virtio_gpu_init` calls `virtio_gpu_cmd_get_display_info(vgdev)` and then `virtio_gpu_notify(vgdev)`. Then, crucially, it calls `wait_event_timeout(vgdev->resp_wq, !vgdev->display_info_pending, 5 * HZ)`. Okay, so it *blocks* waiting for the display info. That's the key.
But hang on… the stack trace of `swapper/0:1` shows it's in `virtio_gpu_probe` -> `drm_client_setup` -> `drm_fbdev_client_setup` -> `drm_client_register`. This means `virtio_gpu_init` *has already finished*! Because `drm_client_setup` is called at the end of `virtio_gpu_probe`. So it’s *after* the initial device setup. That's a huge clue. The deadlock isn't happening in `virtio_gpu_init` itself, or we would be seeing it at the wait. It's *after* that. I need to re-examine the `virtio_gpu_probe` flow, and understand what the system is doing *after* the initial probe. This is likely the crucial next step.
|
| 37/2 |
2026/05/31 02:12 |
tool |
read-file |
0m
Args: map[File:drivers/gpu/drm/virtio/virtgpu_drv.c FirstLine:80 LineCount:50]
Results: map[Contents: 80: return -EINVAL;
81:
82: if (virtio_gpu_modeset == 0)
83: return -EINVAL;
84:
85: /*
86: * The virtio-gpu device is a virtual device that doesn't have DMA
87: * ops assigned to it, nor DMA mask set and etc. Its parent device
88: * is actual GPU device we want to use it for the DRM's device in
89: * order to benefit from using generic DRM APIs.
90: */
91: dev = drm_dev_alloc(&driver, vdev->dev.parent);
92: if (IS_ERR(dev))
93: return PTR_ERR(dev);
94: vdev->priv = dev;
95:
96: if (dev_is_pci(vdev->dev.parent)) {
97: ret = virtio_gpu_pci_quirk(dev);
98: if (ret)
99: goto err_free;
100: }
101:
102: dma_set_max_seg_size(dev->dev, dma_max_mapping_size(dev->dev) ?: UINT_MAX);
103: ret = virtio_gpu_init(vdev, dev);
104: if (ret)
105: goto err_free;
106:
107: ret = drm_dev_register(dev, 0);
108: if (ret)
109: goto err_deinit;
110:
111: drm_client_setup(vdev->priv, NULL);
112:
113: return 0;
114:
115: err_deinit:
116: virtio_gpu_deinit(dev);
117: err_free:
118: drm_dev_put(dev);
119: return ret;
120: }
121:
122: static void virtio_gpu_remove(struct virtio_device *vdev)
123: {
124: struct drm_device *dev = vdev->priv;
125:
126: drm_dev_unplug(dev);
127: drm_atomic_helper_shutdown(dev);
128: virtio_gpu_deinit(dev);
129: drm_dev_put(dev);
]
|
| 38/2 |
2026/05/31 02:12 |
llm |
expert |
0m
Model:
Tokens:
input: 39557
output: 42
thoughts: 122
Thoughts: **Debugging the Virtio-GPU Initialization**
Okay, so I've confirmed the initial sequence: `virtio_gpu_init` ran, then `drm_dev_register`, and finally, `drm_client_setup`. That confirms the initial setup of the Virtio-GPU is complete. However, I'm a little puzzled. Why is `virtio_gpu_cmd_get_display_info_cb` being handled by `kworker/0:0:9`? That worker thread usually signifies an interrupt-driven context.
Aha! It's likely that a configuration change interrupt triggered `virtio_gpu_config_changed_work_func`. That function could be the intermediary to handle display information after a change. Therefore, I need to dig into `virtio_gpu_config_changed_work_func` to understand exactly how the `get_display_info` command is being dispatched and to identify the root cause. I'll focus my investigation there.
|
| 39/2 |
2026/05/31 02:12 |
tool |
read-file |
0m
Args: map[File:drivers/gpu/drm/virtio/virtgpu_kms.c FirstLine:36 LineCount:25]
Results: map[Contents: 36: static void virtio_gpu_config_changed_work_func(struct work_struct *work)
37: {
38: struct virtio_gpu_device *vgdev =
39: container_of(work, struct virtio_gpu_device,
40: config_changed_work);
41: u32 events_read, events_clear = 0;
42:
43: /* read the config space */
44: virtio_cread_le(vgdev->vdev, struct virtio_gpu_config,
45: events_read, &events_read);
46: if (events_read & VIRTIO_GPU_EVENT_DISPLAY) {
47: if (vgdev->num_scanouts) {
48: if (vgdev->has_edid)
49: virtio_gpu_cmd_get_edids(vgdev);
50: virtio_gpu_cmd_get_display_info(vgdev);
51: virtio_gpu_notify(vgdev);
52: drm_helper_hpd_irq_event(vgdev->ddev);
53: }
54: events_clear |= VIRTIO_GPU_EVENT_DISPLAY;
55: }
56: virtio_cwrite_le(vgdev->vdev, struct virtio_gpu_config,
57: events_clear, &events_clear);
58: }
59:
60: static void virtio_gpu_init_vq(struct virtio_gpu_queue *vgvq,
]
|
| 40/2 |
2026/05/31 02:12 |
llm |
expert |
0m
Model:
Tokens:
input: 40367
output: 37
thoughts: 604
Thoughts: **Deadlock in virtio_gpu Driver: A Confidential Computing Vulnerability**
Okay, let me break this down. It seems like the core issue revolves around a potential deadlock within the virtio_gpu driver. It starts with a display configuration change, which, in turn, queues a command: `virtio_gpu_cmd_get_display_info`. This is where `kworker/0:0:9` steps in to process the response in `virtio_gpu_dequeue_ctrl_func`. This then leads to `drm_kms_helper_hotplug_event`, followed by `drm_client_dev_hotplug`. However, here is the problem - this requires `dev->clientlist_mutex`.
The problem is that `swapper/0:1`, right from the get-go, is holding this `dev->clientlist_mutex` because it's involved in `drm_client_register`, specifically from the `virtio_gpu_probe` stage. Now, `swapper/0:1` is trying to queue another command - it could be something like `virtio_gpu_cmd_resource_flush`, but the virtqueue is full.
The virtqueue is full, I realized, because the host hasn't processed the commands or, crucially, because `virtio_gpu_dequeue_ctrl_func` isn't freeing the vbufs. Yes, exactly! Because `virtio_gpu_dequeue_ctrl_func` is *blocked* waiting on `dev->clientlist_mutex`, it's unable to finish processing the responses and free those vbufs. This is critical because `vq->num_free` will remain low. This is where the deadlock kicks in, as `swapper/0:1` is waiting for `vq->num_free >= elemcnt`, which will never happen since the worker that is supposed to be freeing them is blocked.
So, this is a deadlock, plain and simple. And here's the kicker: this deadlock can be triggered by a VM host. Now, in a typical VM environment, the host is trusted, but what about confidential computing scenarios like AMD SEV or Intel TDX? In these cases, the host is *untrusted*! The host can inject a configuration change interrupt at any time. If that interrupt hits precisely during `virtio_gpu_probe`, boom – deadlock. This would lead to a denial of service, effectively hanging the guest kernel. So, this is a Denial of Service vulnerability, specifically in a Confidential Computing context, triggered by a VM Host.
We need to make sure this is the only way to trigger it. Can a local unprivileged user trigger this?
To trigger this, `drm_client_register` needs to be called, or something else that holds `dev->clientlist_mutex` and queues a virtio-gpu command.
Let me see what else holds `dev->clientlist_mutex`.
|
| 41/2 |
2026/05/31 02:12 |
tool |
grepper |
0m
Args: map[Expression:mutex_lock\(&dev->clientlist_mutex\) PathPrefix:drivers/gpu/drm]
Results: map[Output:drivers/gpu/drm/drm_client.c=124=void drm_client_register(struct drm_client_dev *client)
--
drivers/gpu/drm/drm_client.c-128-
drivers/gpu/drm/drm_client.c:129: mutex_lock(&dev->clientlist_mutex);
drivers/gpu/drm/drm_client.c-130- list_add(&client->list, &dev->clientlist);
--
drivers/gpu/drm/drm_client_event.c=32=void drm_client_dev_unregister(struct drm_device *dev)
--
drivers/gpu/drm/drm_client_event.c-38-
drivers/gpu/drm/drm_client_event.c:39: mutex_lock(&dev->clientlist_mutex);
drivers/gpu/drm/drm_client_event.c-40- list_for_each_entry_safe(client, tmp, &dev->clientlist, list) {
--
drivers/gpu/drm/drm_client_event.c=86=void drm_client_dev_hotplug(struct drm_device *dev)
--
drivers/gpu/drm/drm_client_event.c-97-
drivers/gpu/drm/drm_client_event.c:98: mutex_lock(&dev->clientlist_mutex);
drivers/gpu/drm/drm_client_event.c-99- list_for_each_entry(client, &dev->clientlist, list)
--
drivers/gpu/drm/drm_client_event.c=105=void drm_client_dev_restore(struct drm_device *dev, bool force)
--
drivers/gpu/drm/drm_client_event.c-112-
drivers/gpu/drm/drm_client_event.c:113: mutex_lock(&dev->clientlist_mutex);
drivers/gpu/drm/drm_client_event.c-114- list_for_each_entry(client, &dev->clientlist, list) {
--
drivers/gpu/drm/drm_client_event.c=143=void drm_client_dev_suspend(struct drm_device *dev)
--
drivers/gpu/drm/drm_client_event.c-146-
drivers/gpu/drm/drm_client_event.c:147: mutex_lock(&dev->clientlist_mutex);
drivers/gpu/drm/drm_client_event.c-148- list_for_each_entry(client, &dev->clientlist, list) {
--
drivers/gpu/drm/drm_client_event.c=176=void drm_client_dev_resume(struct drm_device *dev)
--
drivers/gpu/drm/drm_client_event.c-179-
drivers/gpu/drm/drm_client_event.c:180: mutex_lock(&dev->clientlist_mutex);
drivers/gpu/drm/drm_client_event.c-181- list_for_each_entry(client, &dev->clientlist, list) {
--
drivers/gpu/drm/drm_client_event.c=190=static int drm_client_debugfs_internal_clients(struct seq_file *m, void *data)
--
drivers/gpu/drm/drm_client_event.c-196-
drivers/gpu/drm/drm_client_event.c:197: mutex_lock(&dev->clientlist_mutex);
drivers/gpu/drm/drm_client_event.c-198- list_for_each_entry(client, &dev->clientlist, list)
]
|
| 42/2 |
2026/05/31 02:12 |
llm |
expert |
1m
Model:
Tokens:
input: 42527
output: 32
thoughts: 43
Thoughts: Okay, here's my interpretation of those thoughts, summarized from my perspective as someone familiar with kernel driver development:
**Debugging the DRM Client Restore Process**
Right, so I'm trying to figure out the exact trigger for `drm_client_dev_restore`. Is it being called exclusively by `drm_lastclose` or does `drm_release` also contribute? It's a key distinction to understand how client state is managed during a device's lifecycle within the Direct Rendering Manager (DRM) subsystem. Time to dig into the call sites. I need to make sure I know *exactly* where that function is invoked from, and under which circumstances. Gotta trace the path to understand the restore mechanism fully. Let's see what the code tells us.
|
| 43/2 |
2026/05/31 02:13 |
tool |
grepper |
0m
Args: map[Expression:drm_client_dev_restore PathPrefix:drivers/gpu/drm]
Results: map[Output:drivers/gpu/drm/drm_client_event.c=103=EXPORT_SYMBOL(drm_client_dev_hotplug);
drivers/gpu/drm/drm_client_event.c-104-
drivers/gpu/drm/drm_client_event.c:105:void drm_client_dev_restore(struct drm_device *dev, bool force)
drivers/gpu/drm/drm_client_event.c-106-{
--
drivers/gpu/drm/drm_client_sysrq.c=16=static void drm_client_sysrq_restore_work_fn(struct work_struct *ignored)
--
drivers/gpu/drm/drm_client_sysrq.c-25-
drivers/gpu/drm/drm_client_sysrq.c:26: drm_client_dev_restore(dev, true);
drivers/gpu/drm/drm_client_sysrq.c-27- }
--
drivers/gpu/drm/drm_file.c=406=static void drm_lastclose(struct drm_device *dev)
drivers/gpu/drm/drm_file.c-407-{
drivers/gpu/drm/drm_file.c:408: drm_client_dev_restore(dev, false);
drivers/gpu/drm/drm_file.c-409-
]
|
| 44/2 |
2026/05/31 02:13 |
llm |
expert |
0m
Model:
Tokens:
input: 43096
output: 43
thoughts: 139
Thoughts: **My Analysis of the DRM Last Close Function**
Okay, so I'm looking at how the DRM system handles the closing of a device file, specifically focusing on what happens when the *last* user closes `/dev/dri/card0`. The key function here is `drm_lastclose`. This is crucial because an unprivileged user can open and close this device file. When that happens, `drm_lastclose` gets triggered, and that's where things get interesting.
`drm_lastclose` calls `drm_client_dev_restore`. My immediate thought is, what's *restoring* here? What's being preserved or reverted? `drm_client_dev_restore` then grabs the `dev->clientlist_mutex`. This suggests a potential lock contention point, something I'll need to keep in mind for potential concurrency issues. It's also prepping for a client-specific operation.
The heart of the matter lies in the call to `client->funcs->restore(client, force)`. This seems to be where the real "restoration" logic lives. I've got to follow that function pointer. For fbdev (framebuffer device) clients, `client->funcs->restore` is specifically set to `drm_fbdev_client_restore`. So, my next step is clear – I've got to dissect `drm_fbdev_client_restore` to understand what state it's preserving or returning to when a client relinquishes access. I need to understand what state is potentially vulnerable, or what assumptions are being made about the previous state.
|
| 45/2 |
2026/05/31 02:13 |
tool |
read-file |
0m
Args: map[File:drivers/gpu/drm/clients/drm_fbdev_client.c FirstLine:80 LineCount:20]
Results: map[Contents: 80: {
81: struct drm_fb_helper *fb_helper = drm_fb_helper_from_client(client);
82:
83: drm_fb_helper_set_suspend_unlocked(fb_helper, true);
84:
85: return 0;
86: }
87:
88: static int drm_fbdev_client_resume(struct drm_client_dev *client)
89: {
90: struct drm_fb_helper *fb_helper = drm_fb_helper_from_client(client);
91:
92: drm_fb_helper_set_suspend_unlocked(fb_helper, false);
93:
94: return 0;
95: }
96:
97: static const struct drm_client_funcs drm_fbdev_client_funcs = {
98: .owner = THIS_MODULE,
99: .free = drm_fbdev_client_free,
]
|
| 46/2 |
2026/05/31 02:13 |
llm |
expert |
0m
Model:
Tokens:
input: 43903
output: 43
thoughts: 14
Thoughts: Okay, here's my interpretation of that thought process, assuming I'm an expert in this area and thinking this through:
**Deconstructing `drm_fbdev_client_restore`**
Alright, let's break this down. *drm_fbdev_client_restore*. Immediately, my mind jumps to the specifics. I know this function – it's crucial for restoring the framebuffer-based display client within the Direct Rendering Manager (DRM) framework, specifically in the context of frame buffer device (fbdev) drivers. But let me think, what exactly *is* it, in detail? It's the mechanism the DRM uses when coming back up, after a suspension, or maybe even after a modeset operation. It's purpose is to make sure the userspace applications, that expect a framebuffer, still find their framebuffer. We’re talking about ensuring the graphics context is properly re-established for those framebuffers that rely on the legacy fbdev interface, when returning from sleep/hibernation or a graphics mode change. I need to refresh what it does in each instance, as details are sometimes crucial. It’s about ensuring data consistency, right? Re-initializing the framebuffers, mapping the memory, and properly configuring the client's access to the hardware. Right, the function's responsibility should include restoring the framebuffer's state, possibly re-mapping the framebuffer memory, and potentially resetting any associated hardware registers. I need to make sure I remember how that interacts with the more modern DRM KMS functions. Let's see if there is anything that is overlooked by this function. I need to go back and check.
|
| 47/2 |
2026/05/31 02:13 |
tool |
read-file |
0m
Args: map[File:drivers/gpu/drm/clients/drm_fbdev_client.c FirstLine:60 LineCount:20]
Results: map[Contents: 60: if (ret)
61: goto err_drm_err;
62:
63: if (!drm_drv_uses_atomic_modeset(dev))
64: drm_helper_disable_unused_functions(dev);
65:
66: ret = drm_fb_helper_initial_config(fb_helper);
67: if (ret)
68: goto err_drm_fb_helper_fini;
69:
70: return 0;
71:
72: err_drm_fb_helper_fini:
73: drm_fb_helper_fini(fb_helper);
74: err_drm_err:
75: drm_err(dev, "fbdev: Failed to setup emulation (ret=%d)\n", ret);
76: return ret;
77: }
78:
79: static int drm_fbdev_client_suspend(struct drm_client_dev *client)
]
|
| 48/2 |
2026/05/31 02:13 |
llm |
expert |
0m
Model:
Tokens:
input: 44582
output: 35
thoughts: 14
Thoughts: Here's my thought process, summarized as you requested:
**Navigating the Codebase: The Search for `drm_fbdev_client_restore`**
Okay, so I need to find the function `drm_fbdev_client_restore`. Right off the bat, I'm thinking, "Where would this likely reside?" Given the name, it's almost certainly related to the Direct Rendering Manager (DRM) framebuffer device driver, which makes sense for display handling. My initial instinct is to look within the core DRM driver directory, or perhaps within specific subsystem directories related to framebuffer management within the kernel's source tree. I could use `grep` or a similar tool to pinpoint the file containing this function. I'd start with a basic `grep "drm_fbdev_client_restore"` search across the relevant source directories. Then, I will have to start tracing the various calls and inter-dependencies that the function has, which is where things can get more nuanced. I'll need to understand the data structures it manipulates, and the contexts in which it's called. This is a common pattern for me; a function name usually gives me a solid starting point for a deeper dive into how this specific aspect of the system works.
|
| 49/2 |
2026/05/31 02:13 |
tool |
grepper |
0m
Args: map[Expression:drm_fbdev_client_restore PathPrefix:drivers/gpu/drm/clients]
Results: map[Output:drivers/gpu/drm/clients/drm_fbdev_client.c=24=static void drm_fbdev_client_unregister(struct drm_client_dev *client)
--
drivers/gpu/drm/clients/drm_fbdev_client.c-40-
drivers/gpu/drm/clients/drm_fbdev_client.c:41:static int drm_fbdev_client_restore(struct drm_client_dev *client, bool force)
drivers/gpu/drm/clients/drm_fbdev_client.c-42-{
--
drivers/gpu/drm/clients/drm_fbdev_client.c=97=static const struct drm_client_funcs drm_fbdev_client_funcs = {
--
drivers/gpu/drm/clients/drm_fbdev_client.c-100- .unregister = drm_fbdev_client_unregister,
drivers/gpu/drm/clients/drm_fbdev_client.c:101: .restore = drm_fbdev_client_restore,
drivers/gpu/drm/clients/drm_fbdev_client.c-102- .hotplug = drm_fbdev_client_hotplug,
]
|
| 50/2 |
2026/05/31 02:13 |
llm |
expert |
0m
Model:
Tokens:
input: 45186
output: 43
thoughts: 14
Thoughts: Here's a summary of my thought process, as requested:
**Diving into `drm_fbdev_client_restore`**
Alright, let's get down to brass tacks. I need to take a look at `drm_fbdev_client_restore`. I know this function is critical within the DRM framework, specifically for framebuffer device handling. It's likely involved in restoring the framebuffer state, probably after a suspend/resume cycle, a mode switch, or maybe even after a client disconnect. My immediate questions are: What specific aspects of the framebuffer state are we talking about here? Are we restoring the video memory itself? The cursor position? The display mode? Is this operation specific to a particular DRM driver or does it have a more generic implementation? Understanding the details of what `drm_fbdev_client_restore` does will be crucial for any analysis I need to perform. I'm especially interested in how it interacts with other DRM components. Let's see how it handles the interaction between the client, the driver, and the framebuffer memory. Time to dig in!
|
| 51/2 |
2026/05/31 02:13 |
tool |
read-file |
0m
Args: map[File:drivers/gpu/drm/clients/drm_fbdev_client.c FirstLine:40 LineCount:20]
Results: map[Contents: 40:
41: static int drm_fbdev_client_restore(struct drm_client_dev *client, bool force)
42: {
43: struct drm_fb_helper *fb_helper = drm_fb_helper_from_client(client);
44:
45: drm_fb_helper_restore_fbdev_mode_unlocked(fb_helper, force);
46:
47: return 0;
48: }
49:
50: static int drm_fbdev_client_hotplug(struct drm_client_dev *client)
51: {
52: struct drm_fb_helper *fb_helper = drm_fb_helper_from_client(client);
53: struct drm_device *dev = client->dev;
54: int ret;
55:
56: if (dev->fb_helper)
57: return drm_fb_helper_hotplug_event(dev->fb_helper);
58:
59: ret = drm_fb_helper_init(dev, fb_helper);
]
|
| 52/2 |
2026/05/31 02:13 |
llm |
expert |
1m
Model:
Tokens:
input: 45778
output: 35
thoughts: 548
Thoughts: **Deadlock Detection: A Virtio-GPU Kernel Vulnerability**
Okay, here's what's running through my head. I've got a potential kernel deadlock scenario involving the virtio-gpu driver. It seems to hinge on a race condition between a user-space process and a hotplug event. Let's break it down:
`drm_fb_helper_restore_fbdev_mode_unlocked` calls `drm_client_modeset_commit_locked`, which itself queues a virtio-gpu command. Now, the fun begins if an unprivileged user opens and closes `/dev/dri/card0` because `drm_lastclose` is triggered. This function acquires `dev->clientlist_mutex`, and then queues *another* virtio-gpu command. The critical piece is that if the virtqueue is full, `drm_lastclose` will *wait*... right there, for space to become available.
Now, if a hotplug event pops up at the *same* time (say, a host config change interrupt), `virtio_gpu_config_changed_work_func` kicks in and queues a `get_display_info` command. A worker thread (kworker/0:0:9) picks up this work, processes the response, and calls `drm_kms_helper_hotplug_event`. `drm_kms_helper_hotplug_event`, in turn, calls `drm_client_dev_hotplug`, and this function *also* tries to grab `dev->clientlist_mutex`.
Here's the problem: The worker thread is trying to acquire the mutex held by `drm_lastclose`. The deadlock is now in place. `drm_lastclose` is blocked waiting for the virtqueue to free up space. And the worker thread is blocked trying to acquire the mutex.
So, can an *unprivileged* user trigger this? Yes, opening and closing `/dev/dri/card0` starts the process. The hotplug event is the kicker. Can they trigger *that*? I need to dig deeper. How can a hotplug event be triggered in this context? I need to track `drm_kms_helper_hotplug_event` and `drm_client_dev_hotplug`.
`drm_client_dev_hotplug` is called from `drm_kms_helper_hotplug_event`. So, can an unprivileged user make a call to `drm_kms_helper_hotplug_event`?
I need to trace the callers of `drm_kms_helper_hotplug_event`. Let's see... `output_poll_execute` calls it if `changed` is true. `output_poll_execute` is part of delayed work that polls connectors. Connector status changes trigger `drm_kms_helper_hotplug_event`. But, for virtio-gpu, interrupts are used for events (`VIRTIO_GPU_EVENT_DISPLAY`). So, polling is not used. Let's see... is there any ioctl call to `drm_kms_helper_hotplug_event`? Let's check `drm_mode_getconnector`.
|
| 53/2 |
2026/05/31 02:15 |
tool |
grepper |
0m
Args: map[Expression:drm_kms_helper_hotplug_event PathPrefix:drivers/gpu/drm]
Results: map[Output:drivers/gpu/drm/amd/amdgpu/amdgpu_device.c=5305=int amdgpu_device_resume(struct drm_device *dev, bool notify_clients)
--
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c-5391- else
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c:5392: drm_kms_helper_hotplug_event(dev);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c-5393-#ifdef CONFIG_PM
--
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c=3469=static int dm_resume(struct amdgpu_ip_block *ip_block)
--
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c-3685-
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c:3686: drm_kms_helper_hotplug_event(ddev);
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c-3687-
--
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c=3996=static void hdmi_hpd_debounce_work(struct work_struct *work)
--
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c-4039- if (!fake_reconnect && aconnector->base.force == DRM_FORCE_UNSPECIFIED)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c:4040: drm_kms_helper_hotplug_event(dev);
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c-4041- }
--
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c=5808=static ssize_t s3_debug_store(struct device *device,
--
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c-5827- dm_resume(ip_block);
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c:5828: drm_kms_helper_hotplug_event(adev_to_drm(adev));
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c-5829- } else
--
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c=7693=static ssize_t panel_power_savings_store(struct device *device,
--
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c-7720-
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c:7721: drm_kms_helper_hotplug_event(dev);
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c-7722-
--
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c=391=static ssize_t dp_mst_link_setting(struct file *f, const char __user *buf,
--
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c-480- mutex_unlock(&aconnector->base.dev->mode_config.mutex);
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c:481: drm_kms_helper_hotplug_event(aconnector->base.dev);
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c-482-
--
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c-487- mutex_unlock(&aconnector->base.dev->mode_config.mutex);
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c:488: drm_kms_helper_hotplug_event(aconnector->base.dev);
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c-489-
--
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c=4011=static int trigger_hpd_mst_set(void *data, u64 val)
--
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c-4058- }
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c:4059: drm_kms_helper_hotplug_event(dev);
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c-4060-
--
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c=711=static void cdns_mhdp_fw_cb(const struct firmware *fw, void *context)
--
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c-732- * XXX how to make sure the bridge is still attached when
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c:733: * calling drm_kms_helper_hotplug_event() after releasing
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c-734- * the lock? We should not hold the spin lock when
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c:735: * calling drm_kms_helper_hotplug_event() since it may
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c-736- * cause a dead lock. FB-dev console calls detect from the
--
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c-743- if (mhdp->connector.dev)
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c:744: drm_kms_helper_hotplug_event(mhdp->bridge.dev);
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c-745- else
--
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c=2292=static void cdns_mhdp_modeset_retry_fn(struct work_struct *work)
--
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c-2311- /* Send Hotplug uevent so userspace can reprobe */
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c:2312: drm_kms_helper_hotplug_event(mhdp->bridge.dev);
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c-2313-}
--
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c=2315=static irqreturn_t cdns_mhdp_irq_handler(int irq, void *data)
--
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c-2327- /*
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c:2328: * Calling drm_kms_helper_hotplug_event() when not attached
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c-2329- * to drm device causes an oops because the drm_bridge->dev
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c-2330- * is NULL. See cdns_mhdp_fw_cb() comments for details about the
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c:2331: * problems related drm_kms_helper_hotplug_event() call.
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c-2332- */
--
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c=2368=static void cdns_mhdp_hpd_work(struct work_struct *work)
--
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c-2379- else
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c:2380: drm_kms_helper_hotplug_event(mhdp->bridge.dev);
drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c-2381- } else {
--
drivers/gpu/drm/bridge/lontium-lt9611.c=372=static irqreturn_t lt9611_irq_thread_handler(int irq, void *dev_id)
--
drivers/gpu/drm/bridge/lontium-lt9611.c-397- if (irq_flag3 & 0xc0 && lt9611->bridge.dev)
drivers/gpu/drm/bridge/lontium-lt9611.c:398: drm_kms_helper_hotplug_event(lt9611->bridge.dev);
drivers/gpu/drm/bridge/lontium-lt9611.c-399-
--
drivers/gpu/drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c=178=static irqreturn_t ge_b850v3_lvds_irq_handler(int irq, void *dev_id)
--
drivers/gpu/drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c-187- if (ge_b850v3_lvds_ptr->bridge.dev)
drivers/gpu/drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c:188: drm_kms_helper_hotplug_event(ge_b850v3_lvds_ptr->bridge.dev);
drivers/gpu/drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c-189-
--
drivers/gpu/drm/bridge/tc358767.c=2227=static irqreturn_t tc_irq_handler(int irq, void *arg)
--
drivers/gpu/drm/bridge/tc358767.c-2260- h ? "H" : "", lc ? "LC" : "");
drivers/gpu/drm/bridge/tc358767.c:2261: drm_kms_helper_hotplug_event(tc->bridge.dev);
drivers/gpu/drm/bridge/tc358767.c-2262- }
--
drivers/gpu/drm/bridge/tda998x_drv.c=778=static void tda998x_detect_work(struct work_struct *work)
--
drivers/gpu/drm/bridge/tda998x_drv.c-784- if (dev)
drivers/gpu/drm/bridge/tda998x_drv.c:785: drm_kms_helper_hotplug_event(dev);
drivers/gpu/drm/bridge/tda998x_drv.c-786-}
--
drivers/gpu/drm/bridge/ti-sn65dsi86.c=1378=static irqreturn_t ti_sn_bridge_interrupt(int irq, void *private)
--
drivers/gpu/drm/bridge/ti-sn65dsi86.c-1406- if (pdata->hpd_enabled && hpd_event)
drivers/gpu/drm/bridge/ti-sn65dsi86.c:1407: drm_kms_helper_hotplug_event(dev);
drivers/gpu/drm/bridge/ti-sn65dsi86.c-1408- mutex_unlock(&pdata->hpd_mutex);
--
drivers/gpu/drm/display/drm_dp_mst_topology.c=2654=static void drm_dp_mst_link_probe_work(struct work_struct *work)
--
drivers/gpu/drm/display/drm_dp_mst_topology.c-2698- if (ret > 0)
drivers/gpu/drm/display/drm_dp_mst_topology.c:2699: drm_kms_helper_hotplug_event(dev);
drivers/gpu/drm/display/drm_dp_mst_topology.c-2700-}
--
drivers/gpu/drm/display/drm_dp_mst_topology.c=4096=static void drm_dp_mst_up_req_work(struct work_struct *work)
--
drivers/gpu/drm/display/drm_dp_mst_topology.c-4122- if (send_hotplug)
drivers/gpu/drm/display/drm_dp_mst_topology.c:4123: drm_kms_helper_hotplug_event(mgr->dev);
drivers/gpu/drm/display/drm_dp_mst_topology.c-4124-}
--
drivers/gpu/drm/display/drm_dp_mst_topology.c=5065=static void drm_dp_delayed_destroy_work(struct work_struct *work)
--
drivers/gpu/drm/display/drm_dp_mst_topology.c-5118- if (send_hotplug)
drivers/gpu/drm/display/drm_dp_mst_topology.c:5119: drm_kms_helper_hotplug_event(mgr->dev);
drivers/gpu/drm/display/drm_dp_mst_topology.c-5120-}
--
drivers/gpu/drm/drm_client_event.c=54=static void drm_client_hotplug(struct drm_client_dev *client)
--
drivers/gpu/drm/drm_client_event.c-82- *
drivers/gpu/drm/drm_client_event.c:83: * drm_kms_helper_hotplug_event() calls this function, so drivers that use it
drivers/gpu/drm/drm_client_event.c-84- * don't need to call this function themselves.
--
drivers/gpu/drm/drm_probe_helper.c=712=EXPORT_SYMBOL(drm_helper_probe_single_connector_modes);
--
drivers/gpu/drm/drm_probe_helper.c-714-/**
drivers/gpu/drm/drm_probe_helper.c:715: * drm_kms_helper_hotplug_event - fire off KMS hotplug events
drivers/gpu/drm/drm_probe_helper.c-716- * @dev: drm_device whose connector state changed
--
drivers/gpu/drm/drm_probe_helper.c-732- */
drivers/gpu/drm/drm_probe_helper.c:733:void drm_kms_helper_hotplug_event(struct drm_device *dev)
drivers/gpu/drm/drm_probe_helper.c-734-{
--
drivers/gpu/drm/drm_probe_helper.c-737-}
drivers/gpu/drm/drm_probe_helper.c:738:EXPORT_SYMBOL(drm_kms_helper_hotplug_event);
drivers/gpu/drm/drm_probe_helper.c-739-
--
drivers/gpu/drm/drm_probe_helper.c-743- *
drivers/gpu/drm/drm_probe_helper.c:744: * This is the same as drm_kms_helper_hotplug_event(), except it fires a more
drivers/gpu/drm/drm_probe_helper.c-745- * fine-grained uevent for a single connector.
--
drivers/gpu/drm/drm_probe_helper.c=756=static void output_poll_execute(struct work_struct *work)
--
drivers/gpu/drm/drm_probe_helper.c-847- if (changed)
drivers/gpu/drm/drm_probe_helper.c:848: drm_kms_helper_hotplug_event(dev);
drivers/gpu/drm/drm_probe_helper.c-849-
--
drivers/gpu/drm/drm_probe_helper.c=1053=EXPORT_SYMBOL(drm_connector_helper_hpd_irq_event);
--
drivers/gpu/drm/drm_probe_helper.c-1069- * drm_connector_helper_hpd_irq_event(). Alternatively, they should bypass this
drivers/gpu/drm/drm_probe_helper.c:1070: * code and directly call drm_kms_helper_hotplug_event() in case the connector
drivers/gpu/drm/drm_probe_helper.c-1071- * state changed.
--
drivers/gpu/drm/drm_probe_helper.c=1082=bool drm_helper_hpd_irq_event(struct drm_device *dev)
--
drivers/gpu/drm/drm_probe_helper.c-1112- else if (changed > 0)
drivers/gpu/drm/drm_probe_helper.c:1113: drm_kms_helper_hotplug_event(dev);
drivers/gpu/drm/drm_probe_helper.c-1114-
--
drivers/gpu/drm/exynos/exynos_drm_dsi.c=36=static int exynos_dsi_host_attach(struct samsung_dsim *dsim,
--
drivers/gpu/drm/exynos/exynos_drm_dsi.c-58- if (drm->mode_config.poll_enabled)
drivers/gpu/drm/exynos/exynos_drm_dsi.c:59: drm_kms_helper_hotplug_event(drm);
drivers/gpu/drm/exynos/exynos_drm_dsi.c-60-
--
drivers/gpu/drm/exynos/exynos_drm_dsi.c=64=static void exynos_dsi_host_detach(struct samsung_dsim *dsim,
--
drivers/gpu/drm/exynos/exynos_drm_dsi.c-70- if (drm->mode_config.poll_enabled)
drivers/gpu/drm/exynos/exynos_drm_dsi.c:71: drm_kms_helper_hotplug_event(drm);
drivers/gpu/drm/exynos/exynos_drm_dsi.c-72-}
--
drivers/gpu/drm/i915/display/intel_dp_test.c=523=bool intel_dp_test_short_pulse(struct intel_dp *intel_dp)
--
drivers/gpu/drm/i915/display/intel_dp_test.c-532- /* Send a Hotplug Uevent to userspace to start modeset */
drivers/gpu/drm/i915/display/intel_dp_test.c:533: drm_kms_helper_hotplug_event(display->drm);
drivers/gpu/drm/i915/display/intel_dp_test.c-534- break;
--
drivers/gpu/drm/i915/display/intel_hotplug.c-67- * detect hooks, and, if connector status changes, triggers sending of hotplug
drivers/gpu/drm/i915/display/intel_hotplug.c:68: * uevent to userspace via drm_kms_helper_hotplug_event().
drivers/gpu/drm/i915/display/intel_hotplug.c-69- *
--
drivers/gpu/drm/i915/display/intel_hotplug.c=468=static void i915_hotplug_work_func(struct work_struct *work)
--
drivers/gpu/drm/i915/display/intel_hotplug.c-551- else if (changed_connectors > 0)
drivers/gpu/drm/i915/display/intel_hotplug.c:552: drm_kms_helper_hotplug_event(display->drm);
drivers/gpu/drm/i915/display/intel_hotplug.c-553-
--
drivers/gpu/drm/i915/display/intel_hotplug.c=739=static void i915_hpd_poll_detect_connectors(struct intel_display *display)
--
drivers/gpu/drm/i915/display/intel_hotplug.c-776- else
drivers/gpu/drm/i915/display/intel_hotplug.c:777: drm_kms_helper_hotplug_event(display->drm);
drivers/gpu/drm/i915/display/intel_hotplug.c-778-
--
drivers/gpu/drm/nouveau/dispnv50/disp.c=1481=nv50_mstm_init(struct nouveau_encoder *outp, bool runtime)
--
drivers/gpu/drm/nouveau/dispnv50/disp.c-1499- if (ret == -1)
drivers/gpu/drm/nouveau/dispnv50/disp.c:1500: drm_kms_helper_hotplug_event(mstm->mgr.dev);
drivers/gpu/drm/nouveau/dispnv50/disp.c-1501-}
--
drivers/gpu/drm/nouveau/nouveau_display.c=422=nouveau_display_hpd_work(struct work_struct *work)
--
drivers/gpu/drm/nouveau/nouveau_display.c-492- else if (changed > 0)
drivers/gpu/drm/nouveau/nouveau_display.c:493: drm_kms_helper_hotplug_event(dev);
drivers/gpu/drm/nouveau/nouveau_display.c-494-
--
drivers/gpu/drm/qxl/qxl_display.c=169=void qxl_display_read_client_monitors_config(struct qxl_device *qdev)
--
drivers/gpu/drm/qxl/qxl_display.c-199- adjust at the arbitrary resolution */
drivers/gpu/drm/qxl/qxl_display.c:200: drm_kms_helper_hotplug_event(dev);
drivers/gpu/drm/qxl/qxl_display.c-201- }
--
drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c=962=static int sun6i_dsi_attach(struct mipi_dsi_host *host,
--
drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c-975-
drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c:976: drm_kms_helper_hotplug_event(dsi->drm);
drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c-977-
--
drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c=983=static int sun6i_dsi_detach(struct mipi_dsi_host *host,
--
drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c-990-
drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c:991: drm_kms_helper_hotplug_event(dsi->drm);
drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c-992-
--
drivers/gpu/drm/vboxvideo/vbox_irq.c=164=static void vbox_hotplug_worker(struct work_struct *work)
--
drivers/gpu/drm/vboxvideo/vbox_irq.c-169- vbox_update_mode_hints(vbox);
drivers/gpu/drm/vboxvideo/vbox_irq.c:170: drm_kms_helper_hotplug_event(&vbox->ddev);
drivers/gpu/drm/vboxvideo/vbox_irq.c-171-}
--
drivers/gpu/drm/virtio/virtgpu_vq.c=819=static void virtio_gpu_cmd_get_display_info_cb(struct virtio_gpu_device *vgdev,
--
drivers/gpu/drm/virtio/virtgpu_vq.c-844- if (!drm_helper_hpd_irq_event(vgdev->ddev))
drivers/gpu/drm/virtio/virtgpu_vq.c:845: drm_kms_helper_hotplug_event(vgdev->ddev);
drivers/gpu/drm/virtio/virtgpu_vq.c-846-}
--
drivers/gpu/drm/vkms/vkms_connector.c=91=void vkms_trigger_connector_hotplug(struct vkms_device *vkmsdev)
--
drivers/gpu/drm/vkms/vkms_connector.c-94-
drivers/gpu/drm/vkms/vkms_connector.c:95: drm_kms_helper_hotplug_event(dev);
drivers/gpu/drm/vkms/vkms_connector.c-96-}
]
|
| 54/2 |
2026/05/31 02:15 |
llm |
expert |
0m
Model:
Tokens:
input: 53626
output: 42
thoughts: 121
Thoughts: **Dissecting the Hotplug Event Flow**
Okay, so I'm tracing this hotplug event handling, and it's starting to make a bit more sense. My initial thought was that there was a more indirect connection, but let's see. Right, *`drm_helper_hpd_irq_event`* is definitely the key function here. Now, I remember that `drm_helper_hpd_irq_event` is directly calling `drm_kms_helper_hotplug_event`. So far, so good, this is the expected behavior for a hotplug event.
Wait a second… *`virtio_gpu_config_changed_work_func`* calls `drm_helper_hpd_irq_event`! That's how it's triggered. It's becoming clearer now. Okay, let me confirm. Yes, *`virtio_gpu_config_changed_work_func`* directly calls *`drm_helper_hpd_irq_event(vgdev->ddev)`*. Okay, so `virtio_gpu_config_changed_work_func` is the direct trigger for hotplug event notifications. I need to make sure I understand the logic *inside* that function, and how it leads to that call. Let me check the code one more time, and re-examine *`virtio_gpu_config_changed_work_func`*, so I don't miss any of the surrounding logic.
|
| 55/2 |
2026/05/31 02:15 |
tool |
read-file |
0m
Args: map[File:drivers/gpu/drm/virtio/virtgpu_kms.c FirstLine:36 LineCount:25]
Results: map[Contents: 36: static void virtio_gpu_config_changed_work_func(struct work_struct *work)
37: {
38: struct virtio_gpu_device *vgdev =
39: container_of(work, struct virtio_gpu_device,
40: config_changed_work);
41: u32 events_read, events_clear = 0;
42:
43: /* read the config space */
44: virtio_cread_le(vgdev->vdev, struct virtio_gpu_config,
45: events_read, &events_read);
46: if (events_read & VIRTIO_GPU_EVENT_DISPLAY) {
47: if (vgdev->num_scanouts) {
48: if (vgdev->has_edid)
49: virtio_gpu_cmd_get_edids(vgdev);
50: virtio_gpu_cmd_get_display_info(vgdev);
51: virtio_gpu_notify(vgdev);
52: drm_helper_hpd_irq_event(vgdev->ddev);
53: }
54: events_clear |= VIRTIO_GPU_EVENT_DISPLAY;
55: }
56: virtio_cwrite_le(vgdev->vdev, struct virtio_gpu_config,
57: events_clear, &events_clear);
58: }
59:
60: static void virtio_gpu_init_vq(struct virtio_gpu_queue *vgvq,
]
|
| 56/2 |
2026/05/31 02:15 |
llm |
expert |
0m
Model:
Tokens:
input: 54544
output: 45
thoughts: 594
Thoughts: **Deadlock Investigation: Virtio-GPU and DRM Client List**
Okay, let's break this down. My initial thought was about `virtio_gpu_config_changed_work_func` and its interaction with the DRM hotplug events, specifically the call chain: `drm_helper_hpd_irq_event` -> `drm_kms_helper_hotplug_event` -> `drm_client_dev_hotplug`. That chain is interesting because it ultimately acquires `dev->clientlist_mutex`. The key realization is that `virtio_gpu_config_changed_work_func` *itself* can block on this mutex. It's executed in a workqueue, so that seems straightforward enough.
But then, it hits me. `virtio_gpu_cmd_get_display_info_cb` also makes this crucial call to `drm_helper_hpd_irq_event` or `drm_kms_helper_hotplug_event`. So this code path, which also gets called by `virtio_gpu_dequeue_ctrl_func` which itself lives in a workqueue (`kworker/0:0:9`), could also be blocking on `dev->clientlist_mutex`.
The situation becomes clear. We have `swapper/0:1` holding `dev->clientlist_mutex` and waiting for `vq->num_free >= elemcnt`, which is a condition on the virtqueue. Crucially, `swapper/0:1` is waiting for `kworker/0:0:9` to free up vbufs, which is exactly the point of the deadlock. So, `swapper/0:1` is waiting for `kworker/0:0:9` and `kworker/0:0:9` is waiting for the mutex which `swapper/0:1` holds, which means, boom, we've got a deadlock!
Now, the real question is whether this is exploitable. Can an *unprivileged* user trigger this? My thought is yes. They can open and close `/dev/dri/card0`. When a user closes it, `drm_lastclose` is called. That code is important because it takes the `dev->clientlist_mutex` and queues a virtio-gpu command. And, if the virtqueue is full, it will also wait for `vq->num_free >= elemcnt`. But the question is: What causes the virtqueue to be full? 64 or 256 entries in the virtqueue seems like a large number, so what makes it full?
The crucial insight here is whether or not an unprivileged user can *queue* commands to the virtio-gpu device. And the answer is yes, they can do this using DRM ioctls! Specifically, `DRM_IOCTL_VIRTGPU_EXECBUFFER` seems like a likely candidate. We need to check if unprivileged users have access to this ioctl. If so, they could potentially fill the virtqueue and trigger the deadlock when combined with a device close.
|
| 57/2 |
2026/05/31 02:15 |
tool |
grepper |
0m
Args: map[Expression:DRM_IOCTL_DEF_DRV\(VIRTGPU_EXECBUFFER PathPrefix:drivers/gpu/drm/virtio]
Results: map[Output:drivers/gpu/drm/virtio/virtgpu_ioctl.c=696=struct drm_ioctl_desc virtio_gpu_ioctls[DRM_VIRTIO_NUM_IOCTLS] = {
--
drivers/gpu/drm/virtio/virtgpu_ioctl.c-699-
drivers/gpu/drm/virtio/virtgpu_ioctl.c:700: DRM_IOCTL_DEF_DRV(VIRTGPU_EXECBUFFER, virtio_gpu_execbuffer_ioctl,
drivers/gpu/drm/virtio/virtgpu_ioctl.c-701- DRM_RENDER_ALLOW),
]
|
| 58/2 |
2026/05/31 02:15 |
llm |
expert |
0m
Model:
Tokens:
input: 56007
output: 43
thoughts: 106
Thoughts: **Analyzing the `DRM_RENDER_ALLOW` Security Implication**
Okay, so `DRM_RENDER_ALLOW` *definitely* implies unprivileged users can interact with the render node, `/dev/dri/renderD128`. That's the key. This also means an unprivileged user has the potential to exploit the `VIRTGPU_EXECBUFFER` calls. My immediate concern is that a malicious user could flood the virtqueue using `VIRTGPU_EXECBUFFER`, which submits commands to it. The important question now is: What happens if the virtqueue fills up? Does the system block, potentially leading to a denial-of-service? I need to check the behavior of `virtio_gpu_execbuffer_ioctl`. That will tell me how the kernel handles a full virtqueue in this specific context. This is the critical piece of the puzzle.
|
| 59/2 |
2026/05/31 02:15 |
tool |
read-file |
0m
Args: map[File:drivers/gpu/drm/virtio/virtgpu_ioctl.c FirstLine:120 LineCount:50]
Results: map[Contents: 120: default:
121: return -EINVAL;
122: }
123: if (copy_to_user(u64_to_user_ptr(param->value), &value, sizeof(int)))
124: return -EFAULT;
125:
126: return 0;
127: }
128:
129: static int virtio_gpu_resource_create_ioctl(struct drm_device *dev, void *data,
130: struct drm_file *file)
131: {
132: struct virtio_gpu_device *vgdev = dev->dev_private;
133: struct drm_virtgpu_resource_create *rc = data;
134: struct virtio_gpu_fence *fence;
135: int ret;
136: struct virtio_gpu_object *qobj;
137: struct drm_gem_object *obj;
138: uint32_t handle = 0;
139: struct virtio_gpu_object_params params = { 0 };
140:
141: if (vgdev->has_virgl_3d) {
142: virtio_gpu_create_context(dev, file);
143: params.virgl = true;
144: params.target = rc->target;
145: params.bind = rc->bind;
146: params.depth = rc->depth;
147: params.array_size = rc->array_size;
148: params.last_level = rc->last_level;
149: params.nr_samples = rc->nr_samples;
150: params.flags = rc->flags;
151: } else {
152: if (rc->depth > 1)
153: return -EINVAL;
154: if (rc->nr_samples > 1)
155: return -EINVAL;
156: if (rc->last_level > 1)
157: return -EINVAL;
158: if (rc->target != 2)
159: return -EINVAL;
160: if (rc->array_size > 1)
161: return -EINVAL;
162: }
163:
164: params.format = rc->format;
165: params.width = rc->width;
166: params.height = rc->height;
167: params.size = rc->size;
168: /* allocate a single page size object */
169: if (params.size == 0)
]
|
| 60/2 |
2026/05/31 02:15 |
llm |
expert |
0m
Model:
Tokens:
input: 57104
output: 37
thoughts: 15
Thoughts: Here's my thought process, summarized as you requested:
**Finding the `virtio_gpu_execbuffer_ioctl` Function**
Okay, let's track down `virtio_gpu_execbuffer_ioctl`. This is a crucial piece, likely a core entry point for buffer execution within the virtio-gpu driver. Given my experience, I'm expecting this to be a key function involved in rendering commands. I'll need to understand how it's called, what data it expects, and how it interacts with the GPU's memory model. Knowing its place in the execution flow will be critical. I'll be looking for where it is declared, where it is defined, and also, where it is called and how its related structs are defined. I expect I'll be diving deep into the code and probably the associated documentation and standards. The goal is to fully understand its function and how it fits into the overall architecture.
|
| 61/2 |
2026/05/31 02:15 |
tool |
grepper |
0m
Args: map[Expression:virtio_gpu_execbuffer_ioctl PathPrefix:drivers/gpu/drm/virtio]
Results: map[Output:drivers/gpu/drm/virtio/virtgpu_drv.h=507=void virtio_gpu_vram_unmap_dma_buf(struct device *dev,
--
drivers/gpu/drm/virtio/virtgpu_drv.h-511-/* virtgpu_submit.c */
drivers/gpu/drm/virtio/virtgpu_drv.h:512:int virtio_gpu_execbuffer_ioctl(struct drm_device *dev, void *data,
drivers/gpu/drm/virtio/virtgpu_drv.h-513- struct drm_file *file);
--
drivers/gpu/drm/virtio/virtgpu_ioctl.c=696=struct drm_ioctl_desc virtio_gpu_ioctls[DRM_VIRTIO_NUM_IOCTLS] = {
--
drivers/gpu/drm/virtio/virtgpu_ioctl.c-699-
drivers/gpu/drm/virtio/virtgpu_ioctl.c:700: DRM_IOCTL_DEF_DRV(VIRTGPU_EXECBUFFER, virtio_gpu_execbuffer_ioctl,
drivers/gpu/drm/virtio/virtgpu_ioctl.c-701- DRM_RENDER_ALLOW),
--
drivers/gpu/drm/virtio/virtgpu_submit.c=465=static int virtio_gpu_lock_buflist(struct virtio_gpu_submit *submit)
--
drivers/gpu/drm/virtio/virtgpu_submit.c-472-
drivers/gpu/drm/virtio/virtgpu_submit.c:473:int virtio_gpu_execbuffer_ioctl(struct drm_device *dev, void *data,
drivers/gpu/drm/virtio/virtgpu_submit.c-474- struct drm_file *file)
]
|
| 62/2 |
2026/05/31 02:15 |
llm |
expert |
0m
Model:
Tokens:
input: 57808
output: 43
thoughts: 33
Thoughts: Okay, let's dive into this. Here's how I'd approach that kernel code:
**Diving into virtio_gpu_execbuffer_ioctl**
Alright, I need to get a handle on what's going on with the `virtio_gpu_execbuffer_ioctl` function. It looks like I need to head over to `drivers/gpu/drm/virtio/virtgpu_submit.c` to find the implementation. That function name immediately makes me think this is the core of buffer execution for the Virtio GPU driver – the place where commands submitted from userspace are actually marshaled and sent to the hardware, or a virtual representation of hardware. I’m expecting to see things like:
* **Command Parsing:** How the submitted buffer is decoded. Is it a custom format, or does it adhere to some standard?
* **Resource Handling:** How the function manages buffers, textures, and other GPU resources referenced by the submitted commands. Are there checks for validity, permissions, and so on?
* **Submission Strategy:** The mechanism by which the commands get dispatched. Is it immediate execution, or is there a queue involved? If there's a queue, how is it managed?
* **Error Handling:** The most likely place to look for potential vulnerabilities, like unvalidated input. What happens if something goes wrong during command execution or resource access?
* **Context Management:** What does it mean for context? Is this being run per-process, or a global context for the user?
* **Synchronization:** How does it deal with multi-threaded submission from the user? Is there a mutex, semaphore, or something else?
This is where the rubber meets the road. Time to start digging and see how it works under the hood. I know the Virtio GPU driver is a critical piece, and it's imperative that it's robust and secure.
|
| 63/2 |
2026/05/31 02:15 |
tool |
read-file |
0m
Args: map[File:drivers/gpu/drm/virtio/virtgpu_submit.c FirstLine:473 LineCount:50]
Results: map[Contents: 473: int virtio_gpu_execbuffer_ioctl(struct drm_device *dev, void *data,
474: struct drm_file *file)
475: {
476: struct virtio_gpu_device *vgdev = dev->dev_private;
477: struct virtio_gpu_fpriv *vfpriv = file->driver_priv;
478: u64 fence_ctx = vgdev->fence_drv.context;
479: struct drm_virtgpu_execbuffer *exbuf = data;
480: struct virtio_gpu_submit submit;
481: u32 ring_idx = 0;
482: int ret = -EINVAL;
483:
484: if (!vgdev->has_virgl_3d)
485: return -ENOSYS;
486:
487: if (exbuf->flags & ~VIRTGPU_EXECBUF_FLAGS)
488: return ret;
489:
490: if (exbuf->flags & VIRTGPU_EXECBUF_RING_IDX) {
491: if (exbuf->ring_idx >= vfpriv->num_rings)
492: return ret;
493:
494: if (!vfpriv->base_fence_ctx)
495: return ret;
496:
497: fence_ctx = vfpriv->base_fence_ctx;
498: ring_idx = exbuf->ring_idx;
499: }
500:
501: virtio_gpu_create_context(dev, file);
502:
503: ret = virtio_gpu_init_submit(&submit, exbuf, dev, file,
504: fence_ctx, ring_idx);
505: if (ret)
506: goto cleanup;
507:
508: ret = virtio_gpu_parse_post_deps(&submit);
509: if (ret)
510: goto cleanup;
511:
512: ret = virtio_gpu_parse_deps(&submit);
513: if (ret)
514: goto cleanup;
515:
516: /*
517: * Await in-fences in the end of the job submission path to
518: * optimize the path by proceeding directly to the submission
519: * to virtio after the waits.
520: */
521: ret = virtio_gpu_wait_in_fence(&submit);
522: if (ret)
]
|
| 64/2 |
2026/05/31 02:15 |
llm |
expert |
0m
Model:
Tokens:
input: 59039
output: 43
thoughts: 865
Thoughts: **Analyzing a Potential Deadlock in the virtio-gpu Driver**
Okay, so I'm looking at this `virtio_gpu_execbuffer_ioctl` function. It seems to queue commands, which immediately flags a potential issue – a flood of `VIRTGPU_EXECBUFFER` calls from an unprivileged user could fill the virtqueue. But, hold on, the deadlock requires `drm_lastclose` to be called.
So, if an unprivileged user opens `/dev/dri/card0`, spams `VIRTGPU_EXECBUFFER`, then closes the file descriptor, that calls `drm_lastclose`. `drm_lastclose` acquires `dev->clientlist_mutex` and then tries to queue a command, like restoring the framebuffer. The problem is the virtqueue is full, so it's waiting for resources: `vq->num_free >= elemcnt`. Meanwhile, there's a worker thread `kworker/0:0:9` processing responses. If a hotplug event happens simultaneously, the worker blocks on `dev->clientlist_mutex`. This means the `drm_lastclose` process is stuck forever, a deadlock.
Now, can an unprivileged user actually trigger this hotplug event? Normally, those are hardware-triggered (plugging in a monitor, etc.). Let's see if there are any ioctls that can trigger one... I know `drm_kms_helper_hotplug_event` can, and it's called by several functions like `drm_dp_mst_link_probe_work`, `drm_dp_mst_up_req_work`, and others. For virtio-gpu specifically, it's called by `virtio_gpu_cmd_get_display_info_cb`. That's triggered when the `get_display_info` command completes.
But who queues `get_display_info`? During probe, `virtio_gpu_init` does, and during config change interrupts, `virtio_gpu_config_changed_work_func` does. So, an unprivileged user can't directly queue `get_display_info` through an ioctl. Can they trigger a config change interrupt? No, that's host-controlled. So, by itself, an unprivileged user can't trigger the hotplug event on virtio-gpu. That deadlock scenario needs the host to trigger a config change interrupt at *exactly* the wrong time, either when `drm_lastclose` is running or when `drm_client_register` is running during probe.
Hold on, what if the user doesn't even need to trigger a hotplug event? Are there any *other* response callbacks that end up calling `drm_client_dev_hotplug` or that lock `dev->clientlist_mutex`? Let's check *all* the response callback functions. I'll go back through the `drivers/gpu/drm/virtio` code. Looking for `_cb` functions, there's:
* `virtio_gpu_cmd_unref_cb`
* `virtio_gpu_cmd_get_display_info_cb`
* `virtio_gpu_cmd_get_capset_info_cb`
* `virtio_gpu_cmd_capset_cb`
* `virtio_gpu_cmd_get_edid_cb`
* `virtio_gpu_cmd_resource_uuid_cb`
* `virtio_gpu_cmd_resource_map_cb`
Next, I need to investigate `virtio_gpu_cmd_unref_cb`...
|
| 65/2 |
2026/05/31 02:15 |
tool |
read-file |
0m
Args: map[File:drivers/gpu/drm/virtio/virtgpu_vq.c FirstLine:617 LineCount:15]
Results: map[Contents: 617: static void virtio_gpu_cmd_unref_cb(struct virtio_gpu_device *vgdev,
618: struct virtio_gpu_vbuffer *vbuf)
619: {
620: struct virtio_gpu_object *bo;
621:
622: bo = vbuf->resp_cb_data;
623: vbuf->resp_cb_data = NULL;
624:
625: virtio_gpu_cleanup_object(bo);
626: }
627:
628: void virtio_gpu_cmd_unref_resource(struct virtio_gpu_device *vgdev,
629: struct virtio_gpu_object *bo)
630: {
631: struct virtio_gpu_resource_unref *cmd_p;
]
|
| 66/2 |
2026/05/31 02:15 |
llm |
expert |
1m
Model:
Tokens:
input: 60986
output: 43
thoughts: 21
Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience and written in the first person:
**Diving into virtio_gpu_cmd_get_capset_info_cb**
Okay, time to dissect `virtio_gpu_cmd_get_capset_info_cb`. This is where the rubber meets the road, so to speak, when it comes to the capability set information exchange in our virtio-gpu implementation. I need to refresh my memory on the data flow and potential gotchas here. My first thought is to ensure the command is correctly handled from the guest side. Are we validating all the input parameters thoroughly? Remember that race condition we saw last quarter? I need to double-check that it is fixed. I need to make sure that we're properly extracting the requested capability set index, checking if it's supported, and then populating the appropriate response structure. Let's see how much of a performance penalty we're incurring with the lookups. Is it hitting the cache? I am thinking, I also need to verify that we are handling errors gracefully, returning the correct error codes according to the virtio specification, and not leaking any sensitive information. Finally, I'll need to confirm that any associated memory allocations are properly managed to avoid any memory leaks or fragmentation issues. This is a critical piece of the puzzle for understanding what the guest can do with the GPU, so it needs to be bulletproof.
|
| 67/2 |
2026/05/31 02:16 |
tool |
read-file |
0m
Args: map[File:drivers/gpu/drm/virtio/virtgpu_vq.c FirstLine:848 LineCount:20]
Results: map[Contents: 848: static void virtio_gpu_cmd_get_capset_info_cb(struct virtio_gpu_device *vgdev,
849: struct virtio_gpu_vbuffer *vbuf)
850: {
851: struct virtio_gpu_get_capset_info *cmd =
852: (struct virtio_gpu_get_capset_info *)vbuf->buf;
853: struct virtio_gpu_resp_capset_info *resp =
854: (struct virtio_gpu_resp_capset_info *)vbuf->resp_buf;
855: int i = le32_to_cpu(cmd->capset_index);
856:
857: spin_lock(&vgdev->display_info_lock);
858: if (vgdev->capsets) {
859: vgdev->capsets[i].id = le32_to_cpu(resp->capset_id);
860: vgdev->capsets[i].max_version = le32_to_cpu(resp->capset_max_version);
861: vgdev->capsets[i].max_size = le32_to_cpu(resp->capset_max_size);
862: } else {
863: DRM_ERROR("invalid capset memory.");
864: }
865: spin_unlock(&vgdev->display_info_lock);
866: wake_up(&vgdev->resp_wq);
867: }
]
|
| 68/2 |
2026/05/31 02:16 |
llm |
expert |
0m
Model:
Tokens:
input: 61782
output: 43
thoughts: 17
Thoughts: Here's my thought process, as if I were considering this function:
**Diving into `virtio_gpu_cmd_capset_cb`**
Okay, time to take a look at `virtio_gpu_cmd_capset_cb`. I need to understand exactly what this callback is doing within the virtio-gpu driver. Given the name, it's likely involved in handling capability sets, which are crucial for feature negotiation and device configuration in this architecture. My immediate questions are: What triggers this callback? What specific capability sets is it dealing with? Are these graphics-specific? How does it interact with the guest's requests? What data structures are involved and how are they validated? I expect it's going to involve parsing commands, checking permissions, and perhaps even modifying the device's internal state based on these capability set requests. I'll need to trace the data flow through this function, examining the arguments and the return values to fully grasp its role in enabling and disabling graphics features or determining their characteristics. It could be a critical point of potential vulnerability or performance bottleneck, depending on its implementation. I'll focus on how it handles errors, too, because robustness is key when interacting with untrusted guest code.
|
| 69/2 |
2026/05/31 02:16 |
tool |
read-file |
0m
Args: map[File:drivers/gpu/drm/virtio/virtgpu_vq.c FirstLine:869 LineCount:20]
Results: map[Contents: 869: static void virtio_gpu_cmd_capset_cb(struct virtio_gpu_device *vgdev,
870: struct virtio_gpu_vbuffer *vbuf)
871: {
872: struct virtio_gpu_get_capset *cmd =
873: (struct virtio_gpu_get_capset *)vbuf->buf;
874: struct virtio_gpu_resp_capset *resp =
875: (struct virtio_gpu_resp_capset *)vbuf->resp_buf;
876: struct virtio_gpu_drv_cap_cache *cache_ent;
877:
878: spin_lock(&vgdev->display_info_lock);
879: list_for_each_entry(cache_ent, &vgdev->cap_cache, head) {
880: if (cache_ent->version == le32_to_cpu(cmd->capset_version) &&
881: cache_ent->id == le32_to_cpu(cmd->capset_id)) {
882: memcpy(cache_ent->caps_cache, resp->capset_data,
883: cache_ent->size);
884: /* Copy must occur before is_valid is signalled. */
885: smp_wmb();
886: atomic_set(&cache_ent->is_valid, 1);
887: break;
888: }
]
|
| 70/2 |
2026/05/31 02:16 |
llm |
expert |
0m
Model:
Tokens:
input: 62513
output: 43
thoughts: 19
Thoughts: Okay, let's dive into this. Here's my thought process on this:
**Analyzing `virtio_gpu_cmd_get_edid_cb`**
Alright, I'm starting with `virtio_gpu_cmd_get_edid_cb`. That immediately tells me this function is involved in fetching the Extended Display Identification Data (EDID) from the virtual GPU, likely within a virtio-based graphics driver. This is a critical piece of information for the guest OS, allowing it to correctly identify the connected display and configure the appropriate resolution, color depth, refresh rate, and other display parameters. I need to understand exactly how this call functions. What's the control flow? What data structures are involved in handling the request and returning the EDID? I bet it probably talks to the actual host side device. I wonder what the security considerations are around retrieving EDID. What are the potential vulnerabilities if this process isn't handled securely? I'm curious what kind of error checking is done. Does it handle partial EDIDs or other corner cases gracefully? How does it interact with the host-side EDID data? Let's check the code and see.
|
| 71/2 |
2026/05/31 02:16 |
tool |
read-file |
0m
Args: map[File:drivers/gpu/drm/virtio/virtgpu_vq.c FirstLine:906 LineCount:25]
Results: map[Contents: 906: static void virtio_gpu_cmd_get_edid_cb(struct virtio_gpu_device *vgdev,
907: struct virtio_gpu_vbuffer *vbuf)
908: {
909: struct virtio_gpu_cmd_get_edid *cmd =
910: (struct virtio_gpu_cmd_get_edid *)vbuf->buf;
911: struct virtio_gpu_resp_edid *resp =
912: (struct virtio_gpu_resp_edid *)vbuf->resp_buf;
913: uint32_t scanout = le32_to_cpu(cmd->scanout);
914: struct virtio_gpu_output *output;
915: const struct drm_edid *new_edid, *old_edid;
916:
917: if (scanout >= vgdev->num_scanouts)
918: return;
919: output = vgdev->outputs + scanout;
920:
921: new_edid = drm_edid_read_custom(&output->conn, virtio_get_edid_block, resp);
922: drm_edid_connector_update(&output->conn, new_edid);
923:
924: spin_lock(&vgdev->display_info_lock);
925: old_edid = output->drm_edid;
926: output->drm_edid = new_edid;
927: spin_unlock(&vgdev->display_info_lock);
928:
929: drm_edid_free(old_edid);
930: wake_up(&vgdev->resp_wq);
]
|
| 72/2 |
2026/05/31 02:16 |
llm |
expert |
0m
Model:
Tokens:
input: 63313
output: 42
thoughts: 52
Thoughts: Okay, here's my interpretation of that thought process, tailored for an expert audience:
**Investigating the EDID Retrieval Path in Virtio-GPU**
Alright, so I'm digging into the `virtio_gpu_cmd_get_edid_cb` function. The key here is it calls `drm_edid_connector_update`. Now, I need to understand the complete execution path. Specifically, I'm trying to determine if `drm_edid_connector_update` somehow triggers a hotplug event via a call to `drm_kms_helper_hotplug_event`.
I'm thinking this is related to hotplug detection in the virtio-gpu driver. It is an interesting question, particularly in a virtualized context. I'm trying to figure out if retrieving EDID information has any side effect on the system's ability to respond to display changes, or if this is completely isolated, as it should be. The interaction or lack thereof will guide some performance expectations, and possible event handling design decisions in the broader KMS architecture of this driver.
|
| 73/2 |
2026/05/31 02:16 |
tool |
grepper |
0m
Error:
Args: map[Expression:drm_kms_helper_hotplug_event PathPrefix:drivers/gpu/drm/drm_edid.c]
Results:
|
| 74/2 |
2026/05/31 02:16 |
llm |
expert |
0m
Model:
Tokens:
input: 63649
output: 40
thoughts: 2921
Thoughts: **Analyzing the Virtio-GPU Deadlock: A Deep Dive**
Okay, so I've been dissecting this virtio-gpu deadlock, and here's what I've got. It seems the core issue lies in the interaction between a configuration change interrupt from the host and how we handle display information. The critical function is `virtio_gpu_cmd_get_display_info_cb`, because it calls `drm_kms_helper_hotplug_event`, which leads to `drm_client_dev_hotplug` and subsequent lock contention.
I've traced the call path. `virtio_gpu_cmd_get_display_info_cb` is only queued in `virtio_gpu_init` during device probe or when the host sends a configuration change interrupt via `virtio_gpu_config_changed_work_func`. The deadlock materializes when: the host sends the configuration change *concurrently* with another process holding `dev->clientlist_mutex` while waiting for the virtqueue to have free space.
Initially, I thought about `dev->clientlist_mutex` being held during virtqueue waits, and I remembered `drm_client_register` in `drm_client_setup`. Specifically, `drm_fbdev_client_hotplug` does a modeset commit that queues a command and waits if the queue is full. This means that if the host sends the interrupt during device probe or during a close sequence, we have a problem.
The device probe itself, where `virtio_gpu_init` already queued `get_display_info` and waited for it to complete. However, during probe, `drm_client_setup` hasn't been called yet. This part of the code works fine. We start to see a deadlock occur when the host *triggers* that configuration change *after* the `virtio_gpu_init`.
This means that a host config change interrupt after probe can cause a new `get_display_info` request via `virtio_gpu_config_changed_work_func`. But this is a *second* such event, which is the key. The first one is handled during probe, but the second one will hit the deadlock.
When a configuration change occurs, the host sends the interrupt, and it leads to `virtio_gpu_config_changed_work_func` being invoked. The function queues a new `get_display_info` command and, when the host processes it, `virtio_gpu_cmd_get_display_info_cb` gets called, which in turn tries to call `drm_client_dev_hotplug`. This is where the contention starts because `swapper/0:1` *already* holds the `dev->clientlist_mutex`.
And what happens at this point? Well, `swapper/0:1` is blocked waiting for space on the virtqueue. Meanwhile, `kworker/0:0:9` is trying to run `virtio_gpu_dequeue_ctrl_func` to handle the response from the host. Because `kworker` has to call `drm_client_dev_hotplug` which then has to acquire the mutex (held by `swapper`), the workers can't finish processing responses. So the virtqueue fills up because the workers are blocked. Boom, deadlock.
So the *exact* sequence is: we need `drm_client_register`, from the end of `virtio_gpu_probe`, to be running *concurrently* with `virtio_gpu_cmd_get_display_info_cb`.
This seems to be a race condition triggered by the host. Can unprivileged users trigger this? No, it requires a host-triggered interrupt. Can a VM guest cause this? No, it's a victim. But can a *VM host* trigger this intentionally? Yes! That's the problem in a Confidential Computing context. The host can send that interrupt at just the right time and cause a DoS by hanging the init task.
Furthermore, it’s not only during probe but also during a device close sequence, when `drm_lastclose` gets called. `drm_lastclose` calls `drm_fbdev_client_restore`, which also queues commands to the virtqueue, and also acquires the needed lock. So again, when a config change interrupt comes, and we process `get_display_info` within the interrupt handler, the system deadlocks.
I've checked other response callbacks, and only `virtio_gpu_cmd_get_display_info_cb` calls that hotplug event function, which is the culprit, so an unprivileged user cannot trigger this deadlock. Only the VM host has the capability.
|
| 75/2 |
2026/05/31 02:17 |
tool |
grepper |
0m
Args: map[Expression:virtio_gpu_cmd_get_display_info PathPrefix:drivers/gpu/drm/virtio]
Results: map[Output:drivers/gpu/drm/virtio/virtgpu_drv.h=371=void virtio_gpu_cursor_ping(struct virtio_gpu_device *vgdev,
drivers/gpu/drm/virtio/virtgpu_drv.h-372- struct virtio_gpu_output *output);
drivers/gpu/drm/virtio/virtgpu_drv.h:373:int virtio_gpu_cmd_get_display_info(struct virtio_gpu_device *vgdev);
drivers/gpu/drm/virtio/virtgpu_drv.h-374-int virtio_gpu_cmd_get_capset_info(struct virtio_gpu_device *vgdev, int idx);
--
drivers/gpu/drm/virtio/virtgpu_kms.c=36=static void virtio_gpu_config_changed_work_func(struct work_struct *work)
--
drivers/gpu/drm/virtio/virtgpu_kms.c-49- virtio_gpu_cmd_get_edids(vgdev);
drivers/gpu/drm/virtio/virtgpu_kms.c:50: virtio_gpu_cmd_get_display_info(vgdev);
drivers/gpu/drm/virtio/virtgpu_kms.c-51- virtio_gpu_notify(vgdev);
--
drivers/gpu/drm/virtio/virtgpu_kms.c=118=int virtio_gpu_init(struct virtio_device *vdev, struct drm_device *dev)
--
drivers/gpu/drm/virtio/virtgpu_kms.c-254- virtio_gpu_cmd_get_edids(vgdev);
drivers/gpu/drm/virtio/virtgpu_kms.c:255: virtio_gpu_cmd_get_display_info(vgdev);
drivers/gpu/drm/virtio/virtgpu_kms.c-256- virtio_gpu_notify(vgdev);
--
drivers/gpu/drm/virtio/virtgpu_vq.c=803=virtio_gpu_cmd_resource_detach_backing(struct virtio_gpu_device *vgdev,
--
drivers/gpu/drm/virtio/virtgpu_vq.c-818-
drivers/gpu/drm/virtio/virtgpu_vq.c:819:static void virtio_gpu_cmd_get_display_info_cb(struct virtio_gpu_device *vgdev,
drivers/gpu/drm/virtio/virtgpu_vq.c-820- struct virtio_gpu_vbuffer *vbuf)
--
drivers/gpu/drm/virtio/virtgpu_vq.c=906=static void virtio_gpu_cmd_get_edid_cb(struct virtio_gpu_device *vgdev,
--
drivers/gpu/drm/virtio/virtgpu_vq.c-932-
drivers/gpu/drm/virtio/virtgpu_vq.c:933:int virtio_gpu_cmd_get_display_info(struct virtio_gpu_device *vgdev)
drivers/gpu/drm/virtio/virtgpu_vq.c-934-{
--
drivers/gpu/drm/virtio/virtgpu_vq.c-943- cmd_p = virtio_gpu_alloc_cmd_resp
drivers/gpu/drm/virtio/virtgpu_vq.c:944: (vgdev, &virtio_gpu_cmd_get_display_info_cb, &vbuf,
drivers/gpu/drm/virtio/virtgpu_vq.c-945- sizeof(*cmd_p), sizeof(struct virtio_gpu_resp_display_info),
]
|
| 76/2 |
2026/05/31 02:17 |
llm |
expert |
0m
Model:
Tokens:
input: 68521
output: 33
thoughts: 398
Thoughts: **My Assessment of the Virtio-GPU Deadlock Vulnerability**
Okay, so I've narrowed it down. The vulnerability resides exclusively within `virtio_gpu_init` and `virtio_gpu_config_changed_work_func`. Good, that narrows the scope considerably. The critical aspect is that an unprivileged user cannot directly trigger this. We're dealing with a Denial of Service (DoS) vulnerability – a deadlock – and not a memory corruption, which is a significant distinction.
Now, let's break down the attack dimensions. Exploitation: Nope, it’s a deadlock, not memory corruption, but it is a denial of service. Denial of Service: Yes, a definite "yes." The deadlock freezes kernel tasks, which is the definition of a DoS. Accessible from unprivileged processes? No. Host interaction is required. User namespaces? No, again, it's not. VM guest trigger? Negative. The guest is the victim here.
The key is that the VM host can trigger this. The host can induce the config change interrupt, and that's the vector. The confidential computing aspect plays a role here. Ethernet network, other remote triggers, peripherals, and malicious filesystems? All no.
But wait. Is there *any* other pathway to `drm_kms_helper_hotplug_event`? An unprivileged user triggering a hotplug event on *another* DRM device? If the system has multiple DRM devices, where one *is* virtio-gpu… If the user triggers a hotplug on *that* other DRM device, it calls `drm_kms_helper_hotplug_event(other_dev)`. And that acquires `other_dev->clientlist_mutex`, which is fine, because it won't impact `virtio_gpu_dev->clientlist_mutex`. So it doesn’t deadlock virtio-gpu. Okay, that's not it.
Okay, so what if an unprivileged user could trigger a hotplug event on virtio-gpu *directly* through some other means? I need to look into this. Any sysfs attribute perhaps? Does DRM expose anything in sysfs to force a hotplug event? Let me check…
|
| 77/2 |
2026/05/31 02:17 |
tool |
grepper |
0m
Args: map[Expression:drm_sysfs_.*hotplug PathPrefix:drivers/gpu/drm]
Results: map[Output:drivers/gpu/drm/drm_connector.c=758=void drm_connector_cleanup(struct drm_connector *connector)
--
drivers/gpu/drm/drm_connector.c-814- if (dev->registered)
drivers/gpu/drm/drm_connector.c:815: drm_sysfs_hotplug_event(dev);
drivers/gpu/drm/drm_connector.c-816-}
--
drivers/gpu/drm/drm_connector.c=837=int drm_connector_register(struct drm_connector *connector)
--
drivers/gpu/drm/drm_connector.c-868- /* Let userspace know we have a new connector */
drivers/gpu/drm/drm_connector.c:869: drm_sysfs_connector_hotplug_event(connector);
drivers/gpu/drm/drm_connector.c-870-
--
drivers/gpu/drm/drm_probe_helper.c=733=void drm_kms_helper_hotplug_event(struct drm_device *dev)
drivers/gpu/drm/drm_probe_helper.c-734-{
drivers/gpu/drm/drm_probe_helper.c:735: drm_sysfs_hotplug_event(dev);
drivers/gpu/drm/drm_probe_helper.c-736- drm_client_dev_hotplug(dev);
--
drivers/gpu/drm/drm_probe_helper.c=747=void drm_kms_helper_connector_hotplug_event(struct drm_connector *connector)
--
drivers/gpu/drm/drm_probe_helper.c-750-
drivers/gpu/drm/drm_probe_helper.c:751: drm_sysfs_connector_hotplug_event(connector);
drivers/gpu/drm/drm_probe_helper.c-752- drm_client_dev_hotplug(dev);
--
drivers/gpu/drm/drm_sysfs.c=423=void drm_sysfs_lease_event(struct drm_device *dev)
--
drivers/gpu/drm/drm_sysfs.c-433-/**
drivers/gpu/drm/drm_sysfs.c:434: * drm_sysfs_hotplug_event - generate a DRM uevent
drivers/gpu/drm/drm_sysfs.c-435- * @dev: DRM device
--
drivers/gpu/drm/drm_sysfs.c-443- */
drivers/gpu/drm/drm_sysfs.c:444:void drm_sysfs_hotplug_event(struct drm_device *dev)
drivers/gpu/drm/drm_sysfs.c-445-{
--
drivers/gpu/drm/drm_sysfs.c-452-}
drivers/gpu/drm/drm_sysfs.c:453:EXPORT_SYMBOL(drm_sysfs_hotplug_event);
drivers/gpu/drm/drm_sysfs.c-454-
drivers/gpu/drm/drm_sysfs.c-455-/**
drivers/gpu/drm/drm_sysfs.c:456: * drm_sysfs_connector_hotplug_event - generate a DRM uevent for any connector
drivers/gpu/drm/drm_sysfs.c-457- * change
--
drivers/gpu/drm/drm_sysfs.c-462- */
drivers/gpu/drm/drm_sysfs.c:463:void drm_sysfs_connector_hotplug_event(struct drm_connector *connector)
drivers/gpu/drm/drm_sysfs.c-464-{
--
drivers/gpu/drm/drm_sysfs.c-477-}
drivers/gpu/drm/drm_sysfs.c:478:EXPORT_SYMBOL(drm_sysfs_connector_hotplug_event);
drivers/gpu/drm/drm_sysfs.c-479-
--
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c=1286=static void vmw_master_set(struct drm_device *dev,
--
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c-1294- if (!from_open)
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c:1295: drm_sysfs_hotplug_event(dev);
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c-1296-}
--
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c=1248=static int vmw_du_update_layout(struct vmw_private *dev_priv,
--
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c-1316-
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c:1317: drm_sysfs_hotplug_event(dev);
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c-1318-
]
|
| 78/2 |
2026/05/31 02:17 |
llm |
expert |
0m
Model:
Tokens:
input: 70655
output: 40
thoughts: 49
Thoughts: Okay, here's my interpretation of that thought process, assuming I'm an expert in this area:
**Investigating Connector Status Control**
Alright, so I'm thinking about the way we manage connector status, specifically focusing on the `status` sysfs attribute. I know it's there – it's a common entry point. The interesting bit, of course, is that writing to this attribute can force a status change. Now, I'm trying to mentally map out the implications of that and how it actually works under the hood. To get the specifics, I'm heading straight for the source code, and I'm homing in on the `status_store` function within `drivers/gpu/drm/drm_sysfs.c`. I need to understand the exact implementation details of how that write operation is handled, any checks or side effects, the potential for race conditions. It's time to dig into the guts of the DRM core and see how this status control is implemented. This is where the real nuance lies, and understanding this `status_store` function is the key to understanding how we're changing status.
|
| 79/2 |
2026/05/31 02:17 |
tool |
read-file |
0m
Args: map[File:drivers/gpu/drm/drm_sysfs.c FirstLine:180 LineCount:50]
Results: map[Contents: 180: static void drm_sysfs_release(struct device *dev)
181: {
182: kfree(dev);
183: }
184:
185: /*
186: * Connector properties
187: */
188: static ssize_t status_store(struct device *device,
189: struct device_attribute *attr,
190: const char *buf, size_t count)
191: {
192: struct drm_connector *connector = to_drm_connector(device);
193: struct drm_device *dev = connector->dev;
194: enum drm_connector_force old_force;
195: int ret;
196:
197: ret = mutex_lock_interruptible(&dev->mode_config.mutex);
198: if (ret)
199: return ret;
200:
201: old_force = connector->force;
202:
203: if (sysfs_streq(buf, "detect"))
204: connector->force = 0;
205: else if (sysfs_streq(buf, "on"))
206: connector->force = DRM_FORCE_ON;
207: else if (sysfs_streq(buf, "on-digital"))
208: connector->force = DRM_FORCE_ON_DIGITAL;
209: else if (sysfs_streq(buf, "off"))
210: connector->force = DRM_FORCE_OFF;
211: else
212: ret = -EINVAL;
213:
214: if (old_force != connector->force || !connector->force) {
215: drm_dbg_kms(dev, "[CONNECTOR:%d:%s] force updated from %d to %d or reprobing\n",
216: connector->base.id, connector->name,
217: old_force, connector->force);
218:
219: connector->funcs->fill_modes(connector,
220: dev->mode_config.max_width,
221: dev->mode_config.max_height);
222: }
223:
224: mutex_unlock(&dev->mode_config.mutex);
225:
226: return ret ? ret : count;
227: }
228:
229: static ssize_t status_show(struct device *device,
]
|
| 80/2 |
2026/05/31 02:17 |
llm |
expert |
0m
Model:
Tokens:
input: 71712
output: 66
thoughts: 598
Thoughts: **My Analysis of the Virtio-GPU Deadlock**
Okay, let's break this down. My thought process here is centered around a deadlock scenario I've identified in the virtio-gpu driver. It seems to be triggered by a specific set of circumstances and, importantly, isn't something a standard, unprivileged user can exploit.
My initial investigation focused on how the `status_store` function interacts with mode filling. I was curious if the mode filling process, specifically through `drm_helper_probe_single_connector_modes`, might inadvertently trigger a hotplug event via `drm_kms_helper_hotplug_event`. However, that's not the case. `status_store` simply updates the force status and fills modes directly. It's not the cause.
Then I considered the role of `drm_sysfs_connector_hotplug_event`, which is, as I recall, triggered during `drm_connector_register`. This confirmed my initial intuition: an unprivileged user can't exploit this via sysfs, as they cannot trigger a hotplug event directly. This is good to know, and narrows down the attack surface.
This leads me to conclude that the deadlock is solely triggered by the VM Host. Here's the core of the problem:
The deadlock occurs when a process is already holding `dev->clientlist_mutex` – for example, during device probe (`drm_client_register`), or when `drm_lastclose` is in operation – and is waiting for the virtqueue to have free space (`vq->num_free >= elemcnt`). Then, the host triggers a config change interrupt, specifically `VIRTIO_GPU_EVENT_DISPLAY`. This interrupt queues a `get_display_info` command.
When the host responds, `virtio_gpu_dequeue_ctrl_func` processes the response. `virtio_gpu_cmd_get_display_info_cb` is then called, and that calls `drm_kms_helper_hotplug_event`, which in turn calls `drm_client_dev_hotplug`.
Here's the critical point: `drm_client_dev_hotplug` attempts to acquire `dev->clientlist_mutex`, and this blocks. Because the worker function is blocked, the worker cannot free the vbufs in the virtqueue. Thus, because the virtqueue does not free space, the process waiting for free space waits forever, resulting in a deadlock. It's a classic AB-BA deadlock, or more accurately, a wait-for-condition vs mutex deadlock. The end result is a Denial of Service.
In the context of Confidential Computing environments (like AMD SEV or Intel TDX), this can be triggered by a malicious VM Host injecting a config change interrupt at the right moment. The key point is that an unprivileged user can't trigger this because they can't control the config change interrupt, nor can they trigger a hotplug event that would cause the worker to block on `dev->clientlist_mutex`. This is important for determining the severity and the likely mitigations needed.
Finally, I can fill in the findings confidently:
* Exploitable: False
* DenialOfService: True
* Unprivileged: False
* UserNamespace: False
* VMGuestTrigger: False
* VMHostTrigger: True
* NetworkTrigger: False
* RemoteTrigger: False
* PeripheralTrigger: False
* FilesystemTrigger: False
|
| 81/2 |
2026/05/31 02:17 |
tool |
set-results |
0m
Args: map[DenialOfService:true Exploitable:false FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:false RemoteTrigger:false Unprivileged:false UserNamespace:false VMGuestTrigger:false VMHostTrigger:true]
Results: map[DenialOfService:true Exploitable:false FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:false RemoteTrigger:false Unprivileged:false UserNamespace:false VMGuestTrigger:false VMHostTrigger:true]
|
| 82/2 |
2026/05/31 02:17 |
llm |
expert |
0m
Model:
Tokens:
input: 73183
output: 727
thoughts: 402
Thoughts: **My Analysis & Response: A Virtio-GPU Deadlock**
Alright, the analysis is done, and it's time to put together the final response. My findings point to a nasty deadlock in the virtio-gpu driver. It all boils down to a conflict involving `dev->clientlist_mutex` and the virtqueue free space condition. Here’s what’s happening:
First, a process, could be something like `swapper/0:1` during boot or even something executing `drm_lastclose`, grabs that crucial `dev->clientlist_mutex` lock. It's then queuing up commands for the virtio-gpu device. If the virtqueue is packed to the gills, it waits, expecting `vq->num_free` to grow enough to be able to handle this.
Then, things get spicy. The host side decides to trigger a config change interrupt, specifically `VIRTIO_GPU_EVENT_DISPLAY`. This interrupt queues up a `get_display_info` command.
Now, when the host finally gets around to responding to that `get_display_info` request, a worker thread, like `kworker/0:0:9`, steps in to process the response using `virtio_gpu_dequeue_ctrl_func`.
That worker, in turn, calls `virtio_gpu_cmd_get_display_info_cb`, which, in turn, calls `drm_kms_helper_hotplug_event`, which finally triggers `drm_client_dev_hotplug`.
Here's where the wheels come off. `drm_client_dev_hotplug` comes along and tries to *also* grab `dev->clientlist_mutex`. This is where it blocks. Remember that `dev->clientlist_mutex` is currently held by the original process.
Since the worker thread is blocked on this lock, it can’t make progress. It can't free the vbufs it’s already processed, which means `vq->num_free` *never* increases.
The process that's waiting for `vq->num_free >= elemcnt` is left hanging, forever. That's a classic deadlock.
The end result? A Denial of Service – the kernel hangs.
This is something that can be triggered by a malicious VM Host, especially in a Confidential Computing environment, by injecting that config change interrupt at the perfect moment. However, an unprivileged user can't trigger this because they can't make that interrupt happen, and they can't cause that hotplug event that would block the worker.
|
| 83/1 |
2026/05/31 02:17 |
action |
format-explanation |
0m
Results: map[Explanation:Based on the analysis of the provided kernel bug report and the source code,
here is the assessment of the bug:
**Bug Mechanism and Deadlock:**
The bug is a classic deadlock in the `virtio-gpu` driver involving the
`dev->clientlist_mutex` lock and the virtqueue free space wait condition.
1. A process (such as the `swapper/0:1` init task during device probe, or a
process executing `drm_lastclose`) acquires the `dev->clientlist_mutex` and
begins queuing commands to the virtio-gpu device (e.g., for a modeset commit).
If the virtqueue becomes full, the process blocks in
`virtio_gpu_queue_ctrl_sgs`, waiting for `vq->num_free >= elemcnt`.
2. Concurrently, the VM host triggers a configuration change interrupt
(`VIRTIO_GPU_EVENT_DISPLAY`), which causes `virtio_gpu_config_changed_work_func`
to queue a `get_display_info` command.
3. When the host responds to the `get_display_info` command, the kernel worker
thread (`kworker/0:0:9`) executes `virtio_gpu_dequeue_ctrl_func` to process the
response.
4. The worker invokes the response callback
`virtio_gpu_cmd_get_display_info_cb`, which in turn calls
`drm_kms_helper_hotplug_event()` -> `drm_client_dev_hotplug()`.
5. `drm_client_dev_hotplug()` attempts to acquire the `dev->clientlist_mutex`
and blocks because it is already held by the first process.
6. Because the worker thread is blocked on the mutex, it cannot finish
processing the responses and free the virtqueue buffers (`vbufs`). Consequently,
`vq->num_free` never increases.
7. The first process waits forever for the virtqueue to have free space,
resulting in a complete deadlock.
**Security Impact:**
* **Exploitable:** No. This is a logical deadlock and does not involve memory
corruption, out-of-bounds accesses, or use-after-free conditions. It cannot be
exploited for privilege escalation or arbitrary code execution.
* **Denial Of Service:** Yes. The deadlock hangs the kernel tasks involved
(including the system init task if triggered during boot, or the DRM worker
queues), leading to a system freeze or unkillable processes (D-state).
* **VM Host Trigger in The Confidential Computing Context:** Yes. In a
Confidential Computing environment (like AMD SEV or Intel TDX) where the VM Host
is considered untrusted, a malicious host can intentionally inject the
`VIRTIO_GPU_EVENT_DISPLAY` config change interrupt at the exact moment the guest
kernel is holding the `clientlist_mutex` (e.g., during boot probe or when an
unprivileged user closes the DRM device file, triggering `drm_lastclose`). This
allows the untrusted host to reliably cause a Denial of Service in the guest
kernel.
* **Accessible From Unprivileged Processes:** No. While an unprivileged user can
trigger the `drm_lastclose` path by opening and closing `/dev/dri/card0`, they
cannot trigger the required concurrent hotplug event
(`VIRTIO_GPU_EVENT_DISPLAY`) on the virtio-gpu device. The deadlock strictly
requires the host to inject the configuration change interrupt.]
|