From: Boris Brezillon <boris.brezillon@collabora.com>
To: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
Cc: Steven Price <steven.price@arm.com>,
Liviu Dudau <liviu.dudau@arm.com>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
Chia-I Wu <olvaffe@gmail.com>,
Karunika Choo <karunika.choo@arm.com>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
sashiko-bot@kernel.org
Subject: Re: [PATCH 03/11] drm/panthor: Fix UAF on works queued to panthor_cleanup_wq
Date: Mon, 3 Aug 2026 11:29:54 +0200 [thread overview]
Message-ID: <20260803112954.69bf18f5@fedora1.home> (raw)
In-Reply-To: <bw7DeMSTSiqMFTSPLhpuNA@collabora.com>
On Mon, 20 Jul 2026 11:47:59 +0200
Nicolas Frattaroli <nicolas.frattaroli@collabora.com> wrote:
> On Thursday, 25 June 2026 14:40:29 Central European Summer Time Boris Brezillon wrote:
> > If we don't drain the panthor_cleanup_wq before
> > unregistering/destroying the panthor_device, we might end up with
> > cleanup works that are executed after the device is gone.
> >
> > Add a drain_workqueue() call in panthor_device_unplug() to prevent
> > that.
> >
> > Fixes: de8548813824 ("drm/panthor: Add the scheduler logical block")
> > Fixes: 647810ec2476 ("drm/panthor: Add the MMU/VM logical block")
> > Reported-by: sashiko-bot@kernel.org
> > Closes: https://sashiko.dev/#/patchset/20260625-panthor-signal-from-irq-v5-0-8836a74e0ef9@collabora.com?part=2
> > Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
> > ---
> > drivers/gpu/drm/panthor/panthor_device.c | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/panthor/panthor_device.c b/drivers/gpu/drm/panthor/panthor_device.c
> > index 0b25abebb803..a0774e28aa94 100644
> > --- a/drivers/gpu/drm/panthor/panthor_device.c
> > +++ b/drivers/gpu/drm/panthor/panthor_device.c
> > @@ -101,6 +101,11 @@ void panthor_device_unplug(struct panthor_device *ptdev)
> > panthor_gpu_unplug(ptdev);
> > panthor_pwr_unplug(ptdev);
> >
> > + /* Make sure works queued to panthor_cleanup_wq are executed
> > + * before the device is destroyed.
> > + */
> > + drain_workqueue(panthor_cleanup_wq);
> > +
> > pm_runtime_dont_use_autosuspend(ptdev->base.dev);
> > pm_runtime_put_sync_suspend(ptdev->base.dev);
> >
> >
> >
>
> I feel like nothing in the driver instance should be allowed to queue new
> work to that workqueue while the unplug mutex is being held, and
> panthor_sched_unplug should just disable_work_sync all the associated group
> release_work items as well. If there's not a strong enough relationship
> between a scheduler and the groups to ensure we get all the groups in a
> non-racey manner that might not work out cleanly though.
Release is a bit a special work though. It's something that happens
once we know the group has left the scheduler, and all it's supposed
to do is free the resources the group might hold (mostly memory).
>
> Having a scheduler unplug be completely disconnected from the associated
> groups being gone seems counter-intuitive to me.
It's actually the other way around: unplugging the scheduler might
result in new group_release work items being queued to the cleanup_wq.
The drain_worqueue() (which should actually be a flush_worqueue) is
here to guarantee that we're not leaving objects behind that would
still have references to objects that are about to be destroyed (in the
case of group_release, that's the drm_device, which holds all the GEM
database that we need to return the GEM refs the destroyed groups need
to release).
next prev parent reply other threads:[~2026-08-03 9:30 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-25 12:40 [PATCH 00/11] drm/panthor: Misc fixes for bugs found by shashiko Boris Brezillon
2026-06-25 12:40 ` [PATCH 01/11] drm/panthor: Always use the IRQ-safe variant when acquiring the fence lock Boris Brezillon
2026-06-25 12:51 ` sashiko-bot
2026-06-26 9:11 ` Liviu Dudau
2026-06-25 12:40 ` [PATCH 02/11] drm/panthor: Keep the reset work disabled until everything is initialized Boris Brezillon
2026-06-25 12:59 ` sashiko-bot
2026-06-26 9:13 ` Liviu Dudau
2026-06-25 12:40 ` [PATCH 03/11] drm/panthor: Fix UAF on works queued to panthor_cleanup_wq Boris Brezillon
2026-06-25 12:56 ` sashiko-bot
2026-06-25 14:20 ` Boris Brezillon
2026-07-20 9:47 ` Nicolas Frattaroli
2026-08-03 9:29 ` Boris Brezillon [this message]
2026-06-25 12:40 ` [PATCH 04/11] drm/panthor: Fix potential invalid pointer deref in group_process_tiler_oom() Boris Brezillon
2026-06-25 12:54 ` sashiko-bot
2026-06-26 9:14 ` Liviu Dudau
2026-06-25 12:40 ` [PATCH 05/11] drm/panthor: Fix theoretical IOMEM access in suspended state Boris Brezillon
2026-06-26 9:29 ` Liviu Dudau
2026-06-26 11:40 ` Boris Brezillon
2026-06-26 13:13 ` Liviu Dudau
2026-06-25 12:40 ` [PATCH 06/11] drm/panthor: Don't overrule pending immediate ticks in sched_resume_tick() Boris Brezillon
2026-06-26 12:45 ` Liviu Dudau
2026-06-26 13:19 ` Boris Brezillon
2026-06-29 14:55 ` Liviu Dudau
2026-06-29 12:10 ` Karunika Choo
2026-06-29 12:10 ` Karunika Choo
2026-06-30 13:20 ` Liviu Dudau
2026-06-25 12:40 ` [PATCH 07/11] drm/panthor: Fix panthor_pwr_unplug() Boris Brezillon
2026-06-26 12:42 ` Liviu Dudau
2026-06-25 12:40 ` [PATCH 08/11] drm/panthor: Drop a needless check in panthor_fw_unplug() Boris Brezillon
2026-06-25 12:53 ` sashiko-bot
2026-06-26 13:11 ` Liviu Dudau
2026-06-25 12:40 ` [PATCH 09/11] drm/panthor: Fix a leak when a group is evicted before the tiler OOM is serviced Boris Brezillon
2026-06-26 13:12 ` Liviu Dudau
2026-06-25 12:40 ` [PATCH 10/11] drm/panthor: Interrupt group start/resumption if group_bind_locked() fails Boris Brezillon
2026-06-26 13:14 ` Liviu Dudau
2026-06-25 12:40 ` [PATCH 11/11] drm/panthor: Keep interrupts masked until they are needed Boris Brezillon
2026-06-26 13:18 ` Liviu Dudau
2026-06-29 12:17 ` Karunika Choo
2026-06-30 15:33 ` [PATCH 00/11] drm/panthor: Misc fixes for bugs found by shashiko 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=20260803112954.69bf18f5@fedora1.home \
--to=boris.brezillon@collabora.com \
--cc=airlied@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=karunika.choo@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=liviu.dudau@arm.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=nicolas.frattaroli@collabora.com \
--cc=olvaffe@gmail.com \
--cc=sashiko-bot@kernel.org \
--cc=simona@ffwll.ch \
--cc=steven.price@arm.com \
--cc=tzimmermann@suse.de \
/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.