* [PATCH] drm/i915/display: hold frontbuffer ref across dirtyfb fence callback
@ 2026-11-26 6:08 Bin Luo (University of Electronic Science and Technology of China)
2026-11-26 6:20 ` sashiko-bot
2026-11-30 15:50 ` ✗ LGCI.VerificationFailed: failure for drm/i915/display: hold frontbuffer ref across dirtyfb fence callback (rev2) Patchwork
0 siblings, 2 replies; 3+ messages in thread
From: Bin Luo (University of Electronic Science and Technology of China) @ 2026-11-26 6:08 UTC (permalink / raw)
To: jani.nikula, rodrigo.vivi; +Cc: intel-gfx, intel-xe, dri-devel, linux-kernel
intel_user_framebuffer_dirty() stores the raw intel_frontbuffer pointer
in frontbuffer_fence_cb without taking a frontbuffer reference. If the
framebuffer is destroyed and its owner frontbuffer reference is dropped
before the reservation dma_fence signals,
intel_user_framebuffer_fence_wake() passes a freed intel_frontbuffer
pointer to intel_frontbuffer_queue_flush(), causing a use-after-free.
Take a frontbuffer reference via intel_parent_frontbuffer_ref() before
registering the fence callback, and release it via
intel_parent_frontbuffer_put() in intel_user_framebuffer_fence_wake()
after queuing the flush.
Fixes: 1bb2af547a4b ("drm/i915: Handle dma fences in dirtyfb callback")
Signed-off-by: Bin Luo (University of Electronic Science and Technology of China) <luob87709@gmail.com>
---
Found by code inspection. Compile-tested on x86_64 with W=1 and KASAN
for both i915 (drivers/gpu/drm/i915/display/intel_fb.o) and xe
(drivers/gpu/drm/xe/i915-display/intel_fb.o); not runtime-tested on
Intel display hardware.
drivers/gpu/drm/i915/display/intel_fb.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/i915/display/intel_fb.c b/drivers/gpu/drm/i915/display/intel_fb.c
index 9d71f59..3bbbedc 100644
--- a/drivers/gpu/drm/i915/display/intel_fb.c
+++ b/drivers/gpu/drm/i915/display/intel_fb.c
@@ -2148,8 +2148,10 @@ static void intel_user_framebuffer_fence_wake(struct dma_fence *dma,
struct dma_fence_cb *data)
{
struct frontbuffer_fence_cb *cb = container_of(data, typeof(*cb), base);
+ struct intel_frontbuffer *front = cb->front;
- intel_frontbuffer_queue_flush(cb->front);
+ intel_frontbuffer_queue_flush(front);
+ intel_parent_frontbuffer_put(front->display, front);
kfree(cb);
dma_fence_put(dma);
}
@@ -2160,6 +2162,7 @@ static int intel_user_framebuffer_dirty(struct drm_framebuffer *fb,
struct drm_clip_rect *clips,
unsigned int num_clips)
{
+ struct intel_display *display = to_intel_display(fb->dev);
struct drm_gem_object *obj = intel_fb_bo(fb);
struct intel_frontbuffer *front = to_intel_frontbuffer(fb);
struct dma_fence *fence;
@@ -2185,6 +2188,7 @@ static int intel_user_framebuffer_dirty(struct drm_framebuffer *fb,
}
cb->front = front;
+ intel_parent_frontbuffer_ref(display, front);
intel_frontbuffer_invalidate(front, ORIGIN_DIRTYFB);
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] drm/i915/display: hold frontbuffer ref across dirtyfb fence callback
2026-11-26 6:08 [PATCH] drm/i915/display: hold frontbuffer ref across dirtyfb fence callback Bin Luo (University of Electronic Science and Technology of China)
@ 2026-11-26 6:20 ` sashiko-bot
2026-11-30 15:50 ` ✗ LGCI.VerificationFailed: failure for drm/i915/display: hold frontbuffer ref across dirtyfb fence callback (rev2) Patchwork
1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-11-26 6:20 UTC (permalink / raw)
To: Bin Luo (University of Electronic Science and Technology of China)
Cc: intel-gfx, intel-xe, dri-devel
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] drm/i915: atomic frontbuffer put in
intel_user_framebuffer_fence_wake()
--
commit 6668699993fc94a934753276eb08e4a83ae0ca89
Author: luob87709@gmail.com <luob87709@gmail.com>
drm/i915/display: hold frontbuffer ref across dirtyfb fence callback
This commit takes a frontbuffer reference before registering the dirtyfb
dma_fence callback and drops it in intel_user_framebuffer_fence_wake()
after queuing the flush.
> diff --git a/drivers/gpu/drm/i915/display/intel_fb.c b/drivers/gpu/drm/i915/display/intel_fb.c
> index 2c63aeefaea88..a0af4166c1d33 100644
> --- a/drivers/gpu/drm/i915/display/intel_fb.c
> +++ b/drivers/gpu/drm/i915/display/intel_fb.c
> @@ -2184,8 +2184,10 @@ static void intel_user_framebuffer_fence_wake(struct dma_fence *dma,
> struct dma_fence_cb *data)
> {
> struct frontbuffer_fence_cb *cb = container_of(data, typeof(*cb), base);
> + struct intel_frontbuffer *front = cb->front;
>
> - intel_frontbuffer_queue_flush(cb->front);
> + intel_frontbuffer_queue_flush(front);
> + intel_parent_frontbuffer_put(front->display, front);
> kfree(cb);
> dma_fence_put(dma);
> }
[Severity: High]
Can intel_parent_frontbuffer_put() here drop the final reference to front
from atomic dma_fence signaling context?
intel_user_framebuffer_fence_wake() runs under fence->lock with interrupts
disabled. If the framebuffer was destroyed before the fence signaled and
front->flush_work finishes on another CPU first,
intel_parent_frontbuffer_put() drops the last reference:
CPU0 (<hardirq>) CPU1 (kworker)
intel_user_framebuffer_fence_wake()
intel_frontbuffer_queue_flush()
intel_parent_frontbuffer_ref()
schedule_work(&front->flush_work)
intel_frontbuffer_flush_work()
...
intel_parent_frontbuffer_put()
intel_parent_frontbuffer_put()
frontbuffer_release() <-- final put in atomic context
On Xe, frontbuffer_release() calls drm_gem_object_put(front->obj) ->
xe_gem_object_free() -> ttm_bo_fini() -> ttm_bo_release() ->
xe_ttm_bo_destroy(), which acquires sleeping mutexes such as
xe->mem_access.vram_userfault.lock in atomic context. On i915,
i915_gem_object_frontbuffer_put() and frontbuffer_release() ->
i915_ggtt_clear_scanout() acquire i915->frontbuffer_lock and obj->vma.lock
with plain spin_lock(), which can deadlock if the fence signals from an
interrupt that preempted a holder of either lock on the same CPU.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261126060818.1654-1-luob87709@gmail.com?part=1
^ permalink raw reply [flat|nested] 3+ messages in thread* ✗ LGCI.VerificationFailed: failure for drm/i915/display: hold frontbuffer ref across dirtyfb fence callback (rev2)
2026-11-26 6:08 [PATCH] drm/i915/display: hold frontbuffer ref across dirtyfb fence callback Bin Luo (University of Electronic Science and Technology of China)
2026-11-26 6:20 ` sashiko-bot
@ 2026-11-30 15:50 ` Patchwork
1 sibling, 0 replies; 3+ messages in thread
From: Patchwork @ 2026-11-30 15:50 UTC (permalink / raw)
To: Bin Luo (University of Electronic Science and Technology of China)
Cc: intel-xe
== Series Details ==
Series: drm/i915/display: hold frontbuffer ref across dirtyfb fence callback (rev2)
URL : https://patchwork.freedesktop.org/series/180026/
State : failure
== Summary ==
Series author address 'luob87709@gmail.com' is not on the allowlist, which prevents CI from being automatically triggered.
If you want CI to run for this series, ask Patchwork project owners to click 'retest' on the series in Patchwork.
Exception occurred during validation, bailing out!
Build URL: http://intel-gfx-ci-public.igk.intel.com:8080/job/xe_pw_trigger/1355977/ (on master)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-30 15:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-26 6:08 [PATCH] drm/i915/display: hold frontbuffer ref across dirtyfb fence callback Bin Luo (University of Electronic Science and Technology of China)
2026-11-26 6:20 ` sashiko-bot
2026-11-30 15:50 ` ✗ LGCI.VerificationFailed: failure for drm/i915/display: hold frontbuffer ref across dirtyfb fence callback (rev2) Patchwork
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox