All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Boris Brezillon" <boris.brezillon@collabora.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v3 11/17] drm/panthor: Don't pre-allocate VMAs or page tables when preparing a full VM unmap
Date: Thu, 13 Aug 2026 11:12:29 +0000	[thread overview]
Message-ID: <20260813111229.7948C1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260813-panthor-unplug-fixes-v3-11-3ed4e961bbe7@collabora.com>

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

Pre-existing issues:
- [Critical] panthor_kernel_bo_destroy ignores the return value of panthor_vm_unmap_range, which can fail with -ENOMEM, leaving physical memory mapped in the GPU after it is freed.
--

--- Patch [11]: [PATCH v3 11/17] drm/panthor: Don't pre-allocate VMAs or page tables when preparing a full VM unmap ---
commit e1c4ff0ccf43825a86dfb74945a18fbc59b6d1ca
Author: Boris Brezillon <boris.brezillon@collabora.com>

drm/panthor: Don't pre-allocate VMAs or page tables when preparing a full VM unmap

In the cleanup path, we unmap the full VA range to make sure things are
clean before the VM is released. I'd rather not fail on memory
allocation in that path, so let's make sure
panthor_vm_pgtable_prepare_unmap_op_ctx() doesn't allocate VMAs or
page tables when the unmap range matches the VM virtual address range.

> diff --git a/drivers/gpu/drm/panthor/panthor_mmu.c b/drivers/gpu/drm/panthor/panthor_mmu.c
> index a48466788f4db..acdc0dd04f8be 100644
> --- a/drivers/gpu/drm/panthor/panthor_mmu.c
> +++ b/drivers/gpu/drm/panthor/panthor_mmu.c
> @@ -1466,6 +1466,10 @@ static int panthor_as_prepare_unmap_op_ctx(struct panthor_as_op_ctx *op_ctx,
>  	op_ctx->va.addr = va;
>  	op_ctx->flags = DRM_PANTHOR_VM_BIND_OP_TYPE_UNMAP;
>  
> +	/* Unmap on the whole VM range don't need new VMAs or page tables. */
> +	if (va == as->base.mm_start && size == as->base.mm_range)
> +		return 0;
> +

[Severity: Critical]
This is a pre-existing issue, but I noticed that memory allocation failures 
during teardown of a kernel BO can lead to a use-after-free condition.

Because this new early return only applies to full VM unmaps, non-full unmaps 
like those in panthor_kernel_bo_destroy() will still attempt allocations via
panthor_as_op_ctx_prealloc_vmas() which can fail with -ENOMEM.

If memory pressure causes this allocation to fail, panthor_vm_unmap_range() 
will abort and return -ENOMEM. However, panthor_kernel_bo_destroy() ignores 
this return value:

drivers/gpu/drm/panthor/panthor_gem.c:panthor_kernel_bo_destroy() {
	...
	panthor_vm_unmap_range(vm, bo->va_node.start, bo->va_node.size);
	panthor_vm_free_va(vm, &bo->va_node);
	if (vm == panthor_fw_vm(ptdev))
		panthor_gem_unpin(to_panthor_bo(bo->obj));
	drm_gem_object_put(bo->obj);
}

Does this leave physical memory mapped in the GPU after the underlying GEM 
object is destroyed and freed back to the system? 

If a local user can trigger this by creating and destroying scheduling groups 
or heap pools under memory pressure, could they exploit the stale GPU mapping 
to access newly allocated kernel or user memory?

>  	/* Pre-allocate L3 page tables to account for the split-2M-block
>  	 * situation on unmap.
>  	 */

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260813-panthor-unplug-fixes-v3-0-3ed4e961bbe7@collabora.com?part=11

  reply	other threads:[~2026-08-13 11:12 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-13 10:56 [PATCH v3 00/17] drm/panthor: Fix the unplug logic Boris Brezillon
2026-08-13 10:56 ` [PATCH v3 01/17] drm/panthor: Disable reset work before unplug Boris Brezillon
2026-08-13 10:57 ` [PATCH v3 02/17] drm/panthor: Further delay reset work enablement Boris Brezillon
2026-08-13 10:57 ` [PATCH v3 03/17] drm/panthor: Make sure reset requests in the resume path are not lost Boris Brezillon
2026-08-13 11:09   ` sashiko-bot
2026-08-13 10:57 ` [PATCH v3 04/17] drm/panthor: Make sure reset requests in the post reset " Boris Brezillon
2026-08-13 10:57 ` [PATCH v3 05/17] drm/panthor: Flush the cleanup_wq in the unplug path Boris Brezillon
2026-08-13 11:18   ` sashiko-bot
2026-08-13 10:57 ` [PATCH v3 06/17] drm/panthor: Drop unused vm argument passed to panthor_vm_prepare_sync_only_op_ctx() Boris Brezillon
2026-08-13 10:57 ` [PATCH v3 07/17] drm/panthor: Move the debugfs initialization to panthor_device.c Boris Brezillon
2026-08-13 10:57 ` [PATCH v3 08/17] drm/panthor: Split panthor_vm Boris Brezillon
2026-08-13 11:37   ` sashiko-bot
2026-08-13 10:57 ` [PATCH v3 09/17] drm/panthor: Add fine-grained restrictions on VMs Boris Brezillon
2026-08-13 10:57 ` [PATCH v3 10/17] drm/panthor: Check AS state before disabling Boris Brezillon
2026-08-13 10:57 ` [PATCH v3 11/17] drm/panthor: Don't pre-allocate VMAs or page tables when preparing a full VM unmap Boris Brezillon
2026-08-13 11:12   ` sashiko-bot [this message]
2026-08-13 10:57 ` [PATCH v3 12/17] drm/panthor: Make the VM cleanup path more robust against UAF Boris Brezillon
2026-08-13 11:20   ` sashiko-bot
2026-08-13 10:57 ` [PATCH v3 13/17] drm/panthor: Track user owned VMs Boris Brezillon
2026-08-13 11:18   ` sashiko-bot
2026-08-13 10:57 ` [PATCH v3 14/17] drm/panthor: Track user owned groups Boris Brezillon
2026-08-13 10:57 ` [PATCH v3 15/17] drm/panthor: Fix the unplug logic Boris Brezillon
2026-08-13 11:25   ` sashiko-bot
2026-08-13 10:57 ` [PATCH v3 16/17] drm/panthor: Add a debugfs knob to simulate unplug failures Boris Brezillon
2026-08-13 10:57 ` [PATCH v3 17/17] drm/panthor: Add a debugfs knobs to simulate reset failures Boris Brezillon
2026-08-13 11:23 ` [PATCH v3 00/17] drm/panthor: Fix the unplug logic Boris Brezillon
2026-08-13 15:11   ` Liviu Dudau
2026-08-13 15:55     ` Boris Brezillon
2026-08-13 17:06       ` Liviu Dudau

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=20260813111229.7948C1F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=boris.brezillon@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.