dri-devel Archive on 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 04/12] drm/panthor: Flush the cleanup_wq before destroying the drm_device
Date: Tue, 04 Aug 2026 10:55:12 +0000	[thread overview]
Message-ID: <20260804105513.6A9891F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260804-panthor-unplug-fixes-v1-4-abbbd2d41b13@collabora.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Use-After-Free during device teardown due to incorrect `drmm` action registration order for `panthor_cleanup_wq`.
--

--- Patch [4]: [PATCH 04/12] drm/panthor: Flush the cleanup_wq before destroying the drm_device ---
commit 87cbd87d54cc32db384d8c3b01846063a45650f2
Author: Boris Brezillon <boris.brezillon@collabora.com>

drm/panthor: Flush the cleanup_wq before destroying the drm_device

This commit adds a drmm action to flush the panthor_cleanup_wq workqueue
during device teardown. It registers this action before initializing
subcomponents, intending to ensure that any cleanup work queued during
initialization or execution is flushed.

Closes: https://sashiko.dev/#/patchset/20260625-panthor-signal-from-irq-v5-0-8836a74e0ef9@collabora.com?part=2

> diff --git a/drivers/gpu/drm/panthor/panthor_device.c b/drivers/gpu/drm/panthor/panthor_device.c
> index 7d336f160d1fd..b7c55a6f4f081 100644
> --- a/drivers/gpu/drm/panthor/panthor_device.c
> +++ b/drivers/gpu/drm/panthor/panthor_device.c
[ ... ]
> @@ -220,6 +228,10 @@ int panthor_device_init(struct panthor_device *ptdev)
>  	if (ret)
>  		return ret;
>  
> +	ret = drmm_add_action(&ptdev->base, panthor_device_flush_cleanup_wq, NULL);
> +	if (ret)
> +		return ret;
> +

[Severity: High]
Does this execute the flush in the intended order?

Since drmm release actions execute in Last-In-First-Out (LIFO) order,
registering the flush action before subcomponent initializations (like
panthor_mmu_init() and panthor_fw_init()) means the flush will run after
those subcomponents have already been freed.

If there is pending work on panthor_cleanup_wq, could this lead to a
use-after-free? When panthor_device_flush_cleanup_wq() executes, pending jobs
could attempt to access the already-freed subcomponents. For example, tearing
down a BO accesses freed memory here:

panthor_device_flush_cleanup_wq()
  flush_workqueue()
    ...
    panthor_kernel_bo_destroy()
      if (vm == panthor_fw_vm(ptdev))  <-- ptdev->fw is already freed

>  	ret = panthor_clk_init(ptdev);
>  	if (ret)
>  		return ret;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260804-panthor-unplug-fixes-v1-0-abbbd2d41b13@collabora.com?part=4

  reply	other threads:[~2026-08-04 10:55 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-04 10:09 [PATCH 00/12] drm/panthor: Fix the unplug logic Boris Brezillon
2026-08-04 10:09 ` [PATCH 01/12] drm/panthor: Disable reset work before unplug Boris Brezillon
2026-08-04 10:21   ` sashiko-bot
2026-08-04 10:46   ` Boris Brezillon
2026-08-04 10:09 ` [PATCH 02/12] drm/panthor: Further delay reset work enablement Boris Brezillon
2026-08-04 10:35   ` sashiko-bot
2026-08-04 10:09 ` [PATCH 03/12] drm/panthor: Move the debugfs initialization to panthor_device.c Boris Brezillon
2026-08-04 12:50   ` Liviu Dudau
2026-08-04 10:09 ` [PATCH 04/12] drm/panthor: Flush the cleanup_wq before destroying the drm_device Boris Brezillon
2026-08-04 10:55   ` sashiko-bot [this message]
2026-08-04 10:09 ` [PATCH 05/12] drm/panthor: Drop unused vm argument passed to panthor_vm_prepare_sync_only_op_ctx() Boris Brezillon
2026-08-04 10:09 ` [PATCH 06/12] drm/panthor: Split panthor_vm Boris Brezillon
2026-08-04 10:09 ` [PATCH 07/12] drm/panthor: Add fine-grained restrictions on VMs Boris Brezillon
2026-08-04 13:27   ` sashiko-bot
2026-08-04 10:09 ` [PATCH 08/12] drm/panthor: Check AS state before disabling Boris Brezillon
2026-08-04 10:09 ` [PATCH 09/12] drm/panthor: Don't pre-allocate VMAs or page tables when preparing a full VM unmap Boris Brezillon
2026-08-04 10:09 ` [PATCH 10/12] drm/panthor: Make the VM cleanup path more robust against UAF Boris Brezillon
2026-08-04 15:23   ` sashiko-bot
2026-08-04 10:09 ` [PATCH 11/12] drm/panthor: Make the unplug logic more robust Boris Brezillon
2026-08-04 15:53   ` sashiko-bot
2026-08-04 10:09 ` [PATCH 12/12] drm/panthor: Fix unplug in the reset path Boris Brezillon
2026-08-04 16:01   ` sashiko-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=20260804105513.6A9891F000E9@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox