Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Matthew Auld" <matthew.auld@intel.com>
Cc: intel-xe@lists.freedesktop.org
Subject: Re: [PATCH v5 6/8] drm/xe/mmio_gem: fix destroy flow
Date: Tue, 08 Sep 2026 17:12:41 +0000	[thread overview]
Message-ID: <20260908171241.EE84B1F00A3F@smtp.kernel.org> (raw)
In-Reply-To: <20260908165046.1393557-16-matthew.auld@intel.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] GFP_KERNEL allocation under dma_resv lock triggers lockdep splat and potential deadlock
--

commit 6f195ca9ff5839faa94b4a50effe5cb10176e87b
Author: Ilia Levi <ilia.levi@intel.com>
Subject: drm/xe/mmio_gem: fix destroy flow

This commit fixes a use-after-free in the gem object destroy flow by
introducing proper synchronization and refcounting. It uses the dma_resv lock
to serialize the fault handler with the destroy operation and unmaps existing
pages to cut off access to the real mmio after destruction.

> diff --git a/drivers/gpu/drm/xe/xe_mmio_gem.c b/drivers/gpu/drm/xe/xe_mmio_gem.c
> index 970b1e2f49815..5ffe03d361902 100644
> --- a/drivers/gpu/drm/xe/xe_mmio_gem.c
> +++ b/drivers/gpu/drm/xe/xe_mmio_gem.c
[ ... ]
> @@ -176,10 +189,9 @@ static int alloc_dummy_page_if_needed(struct drm_gem_object *base)
>  {
>  	struct xe_mmio_gem *obj = to_xe_mmio_gem(base);
>  
> -	dma_resv_lock(base->resv, NULL);
> +	dma_resv_assert_held(base->resv);
>  	if (!obj->dummy_page)
>  		obj->dummy_page = alloc_page(GFP_KERNEL | __GFP_ZERO);

[Severity: High]
This isn't a bug introduced by this patch, but does this allocation context
create a lockdep violation or potential deadlock?

The vma fault handler calls xe_mmio_gem_vm_fault, which takes the
dma_resv_lock. If the device is unplugged, it eventually calls
alloc_dummy_page_if_needed, executing alloc_page(GFP_KERNEL | __GFP_ZERO)
while holding base->resv. Since dma_resv locks are taken by shrinkers during
memory reclaim, holding it while doing a GFP_KERNEL allocation creates a
circular dependency.

This can be reached by any unprivileged userspace process that mmaps the mmio
gem object and triggers a page fault while the device is in an unplugged
state.

> -	dma_resv_unlock(base->resv);
>  
>  	return obj->dummy_page ? 0 : -ENOMEM;
>  }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260908165046.1393557-10-matthew.auld@intel.com?part=6

  reply	other threads:[~2026-09-08 17:12 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-08 16:50 [PATCH v5 0/8] drm/xe/mmio_gem: fix fault handler and destroy path Matthew Auld
2026-09-08 16:50 ` [PATCH v5 1/8] drm/xe/mmio_gem: forbid VMA split Matthew Auld
2026-09-08 16:50 ` [PATCH v5 2/8] drm/xe/mmio_gem: use write-back mapping for dummy page Matthew Auld
2026-09-08 16:50 ` [PATCH v5 3/8] drm/xe/mmio_gem: simplify fault handler loop Matthew Auld
2026-09-08 16:50 ` [PATCH v5 4/8] drm/xe/mmio_gem: Revoke drm_vma_node on xe_mmio_gem destroy Matthew Auld
2026-09-08 16:50 ` [PATCH v5 5/8] drm/xe/mmio_gem: cache the dummy page per object Matthew Auld
2026-09-08 16:50 ` [PATCH v5 6/8] drm/xe/mmio_gem: fix destroy flow Matthew Auld
2026-09-08 17:12   ` sashiko-bot [this message]
2026-09-08 17:23     ` Matthew Auld
2026-09-08 16:50 ` [PATCH v5 7/8] drm/xe/mmio_gem: reject VM_EXEC and drop VM_DONTCOPY Matthew Auld
2026-09-08 16:50 ` [PATCH v5 8/8] drm/xe: convert PCI barrier mmap to use xe_mmio_gem Matthew Auld
2026-09-08 17:07   ` Thomas Hellström
2026-09-08 17:23   ` sashiko-bot
2026-09-08 16:59 ` ✓ CI.KUnit: success for drm/xe/mmio_gem: fix fault handler and destroy path (rev5) Patchwork
2026-09-08 17:36 ` ✓ Xe.CI.BAT: " Patchwork
2026-09-08 22:52 ` ✓ Xe.CI.FULL: " Patchwork

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=20260908171241.EE84B1F00A3F@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=matthew.auld@intel.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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