From: Zhenyu Wang <zhenyuw.linux@gmail.com>
To: Matt Evans <matt@ozlabs.org>
Cc: "Christian König" <christian.koenig@amd.com>,
"Sumit Semwal" <sumit.semwal@linaro.org>,
"Zack Rusin" <zack.rusin@broadcom.com>,
"Zhi Wang" <zhi.wang.linux@gmail.com>,
"Jani Nikula" <jani.nikula@linux.intel.com>,
"Joonas Lahtinen" <joonas.lahtinen@linux.intel.com>,
"Rodrigo Vivi" <rodrigo.vivi@intel.com>,
"Tvrtko Ursulin" <tursulin@ursulin.net>,
intel-gfx@lists.freedesktop.org, linux-media@vger.kernel.org,
dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org,
linux-kernel@vger.kernel.org, "Alex Mastro" <amastro@fb.com>,
"Alex Williamson" <alex@shazbot.org>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Maxime Ripard" <mripard@kernel.org>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"David Airlie" <airlied@gmail.com>,
stable@vger.kernel.org
Subject: Re: [PATCH v3 2/3] drm/i915/gvt: Read dmabuf->file only while valid
Date: Thu, 15 Oct 2026 14:25:10 +0900 [thread overview]
Message-ID: <atBjtqQTCxLuomi2@dell-wzy> (raw)
In-Reply-To: <20261013120211.135807-3-matt@ozlabs.org>
On Tue, Oct 13, 2026 at 01:02:05PM +0100, Matt Evans wrote:
> After 4ab59c3c638c6 ("dma-buf: Move dma_buf_release() from fops to
> dentry_ops"), dmabuf->file can close prior to the .release callback
> being invoked.
>
> intel_vgpu_get_dmabuf() exports the dmabuf, then dma_buf_fd()
> effectively transfers its file's reference to the fd. A debug print
> dereferences dmabuf->file after the dma_buf_fd(); however, the fd
> could be closed by another thread, making dmabuf->file stale.
>
> Read file_count() while the reference to dmabuf->file is still held,
> for later debug printing.
>
> Cc: stable@vger.kernel.org
> Fixes: 4ab59c3c638c6 ("dma-buf: Move dma_buf_release() from fops to dentry_ops")
> Signed-off-by: Matt Evans <matt@ozlabs.org>
> ---
> drivers/gpu/drm/i915/gvt/dmabuf.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gvt/dmabuf.c b/drivers/gpu/drm/i915/gvt/dmabuf.c
> index 8a1d6c5636c2..b6f50f2b912d 100644
> --- a/drivers/gpu/drm/i915/gvt/dmabuf.c
> +++ b/drivers/gpu/drm/i915/gvt/dmabuf.c
> @@ -503,6 +503,7 @@ int intel_vgpu_get_dmabuf(struct intel_vgpu *vgpu, unsigned int dmabuf_id)
> struct drm_device *dev = &vgpu->gvt->gt->i915->drm;
> struct intel_vgpu_dmabuf_obj *dmabuf_obj;
> struct drm_i915_gem_object *obj;
> + unsigned long db_fcount;
> struct dma_buf *dmabuf;
> int dmabuf_fd;
> int ret = 0;
> @@ -531,6 +532,7 @@ int intel_vgpu_get_dmabuf(struct intel_vgpu *vgpu, unsigned int dmabuf_id)
> ret = PTR_ERR(dmabuf);
> goto out_free_gem;
> }
> + db_fcount = file_count(dmabuf->file);
>
> ret = dma_buf_fd(dmabuf, DRM_CLOEXEC | DRM_RDWR);
> if (ret < 0) {
> @@ -552,8 +554,7 @@ int intel_vgpu_get_dmabuf(struct intel_vgpu *vgpu, unsigned int dmabuf_id)
> " file count: %ld, GEM ref: %d\n",
> vgpu->id, dmabuf_obj->dmabuf_id,
> kref_read(&dmabuf_obj->kref),
> - dmabuf_fd,
> - file_count(dmabuf->file),
> + dmabuf_fd, db_fcount,
> kref_read(&obj->base.refcount));
>
> i915_gem_object_put(obj);
> --
> 2.47.3
Acked-by: Zhenyu Wang <zhenyuw.linux@gmail.com>
next prev parent reply other threads:[~2026-10-15 5:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-13 12:02 [PATCH v3 0/3] dma-buf: dmabuf->file release-time cleanup Matt Evans
2026-10-13 12:02 ` [PATCH v3 1/3] drm/vmwgfx: Use get_file_active() for dmabuf->file Matt Evans
2026-10-15 16:42 ` Zack Rusin
2026-10-13 12:02 ` [PATCH v3 2/3] drm/i915/gvt: Read dmabuf->file only while valid Matt Evans
2026-10-15 5:25 ` Zhenyu Wang [this message]
2026-10-13 12:02 ` [PATCH v3 3/3] dma-buf: Annul dmabuf->file on file release Matt Evans
2026-10-13 12:13 ` Christian König
2026-10-15 16:45 ` Zack Rusin
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=atBjtqQTCxLuomi2@dell-wzy \
--to=zhenyuw.linux@gmail.com \
--cc=airlied@gmail.com \
--cc=alex@shazbot.org \
--cc=amastro@fb.com \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=matt@ozlabs.org \
--cc=mripard@kernel.org \
--cc=rodrigo.vivi@intel.com \
--cc=stable@vger.kernel.org \
--cc=sumit.semwal@linaro.org \
--cc=tursulin@ursulin.net \
--cc=tzimmermann@suse.de \
--cc=zack.rusin@broadcom.com \
--cc=zhi.wang.linux@gmail.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®