From: Changyul Lee <lcy8047@gmail.com>
To: Zack Rusin <zack.rusin@broadcom.com>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>
Cc: Broadcom internal kernel review list
<bcm-kernel-feedback-list@broadcom.com>,
Maaz Mombasawala <maaz.mombasawala@broadcom.com>,
Martin Krastev <martin.krastev@broadcom.com>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
Changyul Lee <lcy8047@gmail.com>
Subject: [PATCH] drm/vmwgfx: Reserve the buffer during surface lookup
Date: Thu, 19 Nov 2026 22:11:52 -0500 [thread overview]
Message-ID: <20261120031152.1696587-1-lcy8047@gmail.com> (raw)
A GEM reference keeps the buffer alive, but it does not keep its
surfaces alive. vmw_bo_surface() walks the buffer's resource tree
without holding the buffer reservation. A concurrent surface release
can remove and free a surface while the lookup is still using its
tree node. The caller enters its RCU read-side critical section only
after the walk.
Reserve the buffer before calling vmw_bo_surface() and keep it
reserved until the lookup has tried to take a surface reference.
The reservation prevents the surface from being detached during
the lookup, and kref_get_unless_zero() rejects a surface whose
reference count has already reached zero. Assert that the caller
holds the reservation in vmw_bo_surface().
Fixes: d6667f0ddf46 ("drm/vmwgfx: Fix handling of dumb buffers")
Signed-off-by: Changyul Lee <lcy8047@gmail.com>
---
drivers/gpu/drm/vmwgfx/vmwgfx_bo.c | 2 ++
drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 2 ++
2 files changed, 4 insertions(+)
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c
index a6d7156e4281..625c4b33daa2 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c
@@ -864,6 +864,8 @@ struct vmw_surface *vmw_bo_surface(struct vmw_bo *vbo)
struct vmw_surface *surf = NULL;
struct rb_node *rb_itr = vbo->res_tree.rb_node;
+ dma_resv_assert_held(vbo->tbo.base.resv);
+
if (vbo->is_dumb && vbo->dumb_surface) {
res = &vbo->dumb_surface->res;
goto out;
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
index 3064a2a960e1..13548fdfa84c 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
@@ -877,6 +877,7 @@ vmw_lookup_user_surface_for_buffer(struct vmw_private *vmw, struct vmw_bo *bo,
struct vmw_surface *surf;
struct ttm_base_object *base;
+ ttm_bo_reserve(&bo->tbo, false, false, NULL);
surf = vmw_bo_surface(bo);
if (surf) {
rcu_read_lock();
@@ -891,6 +892,7 @@ vmw_lookup_user_surface_for_buffer(struct vmw_private *vmw, struct vmw_bo *bo,
}
rcu_read_unlock();
}
+ ttm_bo_unreserve(&bo->tbo);
return user_srf;
}
base-commit: af1cf92e8617a7f7aa24b415596cbf64b76a12e7
--
2.43.0
reply other threads:[~2026-11-20 3:11 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261120031152.1696587-1-lcy8047@gmail.com \
--to=lcy8047@gmail.com \
--cc=airlied@gmail.com \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=maaz.mombasawala@broadcom.com \
--cc=martin.krastev@broadcom.com \
--cc=mripard@kernel.org \
--cc=simona@ffwll.ch \
--cc=tzimmermann@suse.de \
--cc=zack.rusin@broadcom.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®