lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAPaKu7QuUS_Nkh9cya4Nf9_=gTEMSZR-iUrFXMYyV3C=2jFjhg@mail.gmail.com>
Date: Thu, 4 Dec 2025 09:42:37 -0800
From: Chia-I Wu <olvaffe@...il.com>
To: Tvrtko Ursulin <tvrtko.ursulin@...lia.com>
Cc: Boris Brezillon <boris.brezillon@...labora.com>, Steven Price <steven.price@....com>, 
	Liviu Dudau <liviu.dudau@....com>, Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>, 
	Maxime Ripard <mripard@...nel.org>, Thomas Zimmermann <tzimmermann@...e.de>, 
	David Airlie <airlied@...il.com>, Simona Vetter <simona@...ll.ch>, 
	Grant Likely <grant.likely@...aro.org>, Heiko Stuebner <heiko@...ech.de>, 
	dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] drm/panthor: fix for dma-fence safe access rules

On Thu, Dec 4, 2025 at 1:27 AM Tvrtko Ursulin <tvrtko.ursulin@...lia.com> wrote:
>
>
> On 04/12/2025 01:50, Chia-I Wu wrote:
> > Commit 506aa8b02a8d6 ("dma-fence: Add safe access helpers and document
> > the rules") details the dma-fence safe access rules. The most common
> > culprit is that drm_sched_fence_get_timeline_name may race with
> > group_free_queue.
> >
> > Fixes: d2624d90a0b77 ("drm/panthor: assign unique names to queues")
> > Signed-off-by: Chia-I Wu <olvaffe@...il.com>
> > ---
> >   drivers/gpu/drm/panthor/panthor_sched.c | 4 ++++
> >   1 file changed, 4 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/panthor/panthor_sched.c b/drivers/gpu/drm/panthor/panthor_sched.c
> > index 33b9ef537e359..a8b1347e4da71 100644
> > --- a/drivers/gpu/drm/panthor/panthor_sched.c
> > +++ b/drivers/gpu/drm/panthor/panthor_sched.c
> > @@ -23,6 +23,7 @@
> >   #include <linux/module.h>
> >   #include <linux/platform_device.h>
> >   #include <linux/pm_runtime.h>
> > +#include <linux/rcupdate.h>
> >
> >   #include "panthor_devfreq.h"
> >   #include "panthor_device.h"
> > @@ -923,6 +924,9 @@ static void group_release_work(struct work_struct *work)
> >                                                  release_work);
> >       u32 i;
> >
> > +     /* dma-fences may still be accessing group->queues under rcu lock. */
> > +     synchronize_rcu();
> > +
> >       for (i = 0; i < group->queue_count; i++)
> >               group_free_queue(group, group->queues[i]);
> >
>
> This handles the shared queue->fence_ctx.lock as well (which is also
> unsafe until Christian lands the inline lock, etc patch series) so it
> looks good to me as well.
Yeah, I will send v2 to drop the misleading "Fixes:" tag.

FWIW, the UAF I saw was from accessing the string returned by

static const char *drm_sched_fence_get_timeline_name(struct dma_fence *f)
{
        struct drm_sched_fence *fence = to_drm_sched_fence(f);
        return (const char *)fence->sched->name;
}

I thought it was "name" and added the "Fixes:" tag. But actually
"sched" was also freed by group_release_work.

>
> Just to mention an alternative could be to simply switch release_work to
> INIT_RCU_WORK/queue_rcu_work, but I am not sure if that has an advantage.
>
> Regards,
>
> Tvrtko
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ