From: Zack Rusin <zack.rusin@broadcom.com>
To: Maaz Mombasawala <maaz.mombasawala@broadcom.com>
Cc: dri-devel@lists.freedesktop.org,
bcm-kernel-feedback-list@broadcom.com, ian.forbes@broadcom.com
Subject: Re: [PATCH v3 4/5] drm/vmwgfx: Change ttm refs for dumb buffers.
Date: Fri, 15 May 2026 01:49:20 -0400 [thread overview]
Message-ID: <CABQX2QN4yojsoZ9pkzw1y5a_PEaxa_nfur0V2qaKyiezTgYZHg@mail.gmail.com> (raw)
In-Reply-To: <20260514224819.3631763-5-maaz.mombasawala@broadcom.com>
[-- Attachment #1: Type: text/plain, Size: 2999 bytes --]
On Thu, May 14, 2026 at 6:46 PM Maaz Mombasawala
<maaz.mombasawala@broadcom.com> wrote:
>
> Preserve a ttm reference during dumb buffer creation. This keeps the dumb
> buffer valid for framebuffer usage and fixes all igt tests that use dumb
> buffers.
> Also fix ttm_prime_fd_to_handle(), which in the error case was leaking a
> dma_buf reference. During vmw_prime_fd_to_handle() this function
> is expected to fail for dumb buffers since the fd is for a gem object,
> the dma_buf would in turn hold a reference to the dumb buffer gem object
> and cause a memory leak.
>
> Signed-off-by: Maaz Mombasawala <maaz.mombasawala@broadcom.com>
> ---
> drivers/gpu/drm/vmwgfx/ttm_object.c | 7 +++++--
> drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 5 +++--
> 2 files changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/vmwgfx/ttm_object.c b/drivers/gpu/drm/vmwgfx/ttm_object.c
> index 2421b0dd057c..f9042bafdc93 100644
> --- a/drivers/gpu/drm/vmwgfx/ttm_object.c
> +++ b/drivers/gpu/drm/vmwgfx/ttm_object.c
> @@ -547,14 +547,17 @@ int ttm_prime_fd_to_handle(struct ttm_object_file *tfile,
> if (IS_ERR(dma_buf))
> return PTR_ERR(dma_buf);
>
> - if (dma_buf->ops != &tdev->ops)
> - return -ENOSYS;
> + if (dma_buf->ops != &tdev->ops) {
> + ret = -ENOSYS;
> + goto out;
> + }
>
> prime = (struct ttm_prime_object *) dma_buf->priv;
> base = &prime->base;
> *handle = base->handle;
> ret = ttm_ref_object_add(tfile, base, NULL, false);
>
> +out:
> dma_buf_put(dma_buf);
>
> return ret;
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
> index b2d3927b5567..256e7b89daea 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
> @@ -2328,11 +2328,12 @@ int vmw_dumb_create(struct drm_file *file_priv,
> struct vmw_user_surface *usurf = container_of(vbo->dumb_surface,
> struct vmw_user_surface, srf);
> usurf->prime.base.refcount_release = NULL;
> +
> err:
> if (res)
> vmw_resource_unreference(&res);
> -
> - ttm_ref_object_base_unref(tfile, arg.rep.handle);
> + if (ret)
> + ttm_ref_object_base_unref(tfile, arg.rep.handle);
That still doesn't look correct. dumb buffers own the resource and
should drop it themselves. What you did is made arg.rep.handle stay in
tdev->idr and now both the tfile and dumb_buffer own the surface.
Whichever one is destroyed first will make the other UAF on that
surface.
For all the commits in that series that are fixes please find a proper
Fixes commit. And if you want to land this through drm-misc-fixes then
you'll need to remove the last one from the series because I don't
think we should land general cleanups through fixes.
z
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 5414 bytes --]
next prev parent reply other threads:[~2026-05-15 5:49 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-14 22:48 [PATCH v3 0/5] Fix some issues from igt runs Maaz Mombasawala
2026-05-14 22:48 ` [PATCH v3 1/5] drm/vmwgfx: Add some checks to vmw_cursor_plane_atomic_update Maaz Mombasawala
2026-05-16 0:17 ` Claude review: " Claude Code Review Bot
2026-05-14 22:48 ` [PATCH v3 2/5] drm/vmwgfx: Check vrefresh in drm_mode_setcrtc Maaz Mombasawala
2026-05-16 0:17 ` Claude review: " Claude Code Review Bot
2026-05-14 22:48 ` [PATCH v3 3/5] drm/vmwgfx: Reserve ttm object before resv usage Maaz Mombasawala
2026-05-16 0:17 ` Claude review: " Claude Code Review Bot
2026-05-14 22:48 ` [PATCH v3 4/5] drm/vmwgfx: Change ttm refs for dumb buffers Maaz Mombasawala
2026-05-15 5:49 ` Zack Rusin [this message]
2026-05-16 0:17 ` Claude review: " Claude Code Review Bot
2026-05-14 22:48 ` [PATCH v3 5/5] drm/vmwgfx: Remove duplicates in vmwgfx_bo.h Maaz Mombasawala
2026-05-16 0:17 ` Claude review: " Claude Code Review Bot
2026-05-16 0:17 ` Claude review: Fix some issues from igt runs Claude Code Review Bot
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=CABQX2QN4yojsoZ9pkzw1y5a_PEaxa_nfur0V2qaKyiezTgYZHg@mail.gmail.com \
--to=zack.rusin@broadcom.com \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=ian.forbes@broadcom.com \
--cc=maaz.mombasawala@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