[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aMKtuwdk2HsejS-Q@google.com>
Date: Thu, 11 Sep 2025 11:08:43 +0000
From: Alice Ryhl <aliceryhl@...gle.com>
To: Boris Brezillon <boris.brezillon@...labora.com>
Cc: Danilo Krummrich <dakr@...nel.org>, Matthew Brost <matthew.brost@...el.com>,
"Thomas Hellström" <thomas.hellstrom@...ux.intel.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>,
Steven Price <steven.price@....com>, Daniel Almeida <daniel.almeida@...labora.com>,
Liviu Dudau <liviu.dudau@....com>, dri-devel@...ts.freedesktop.org,
linux-kernel@...r.kernel.org, rust-for-linux@...r.kernel.org
Subject: Re: [PATCH v2 2/2] panthor: use drm_gpuva_unlink_defer()
On Thu, Sep 11, 2025 at 12:15:37PM +0200, Boris Brezillon wrote:
> On Tue, 09 Sep 2025 13:36:23 +0000
> Alice Ryhl <aliceryhl@...gle.com> wrote:
>
> > static void panthor_vma_init(struct panthor_vma *vma, u32 flags)
> > @@ -2084,12 +2010,12 @@ static int panthor_gpuva_sm_step_map(struct drm_gpuva_op *op, void *priv)
> > if (ret)
> > return ret;
> >
> > - /* Ref owned by the mapping now, clear the obj field so we don't release the
> > - * pinning/obj ref behind GPUVA's back.
> > - */
> > drm_gpuva_map(&vm->base, &vma->base, &op->map);
> > panthor_vma_link(vm, vma, op_ctx->map.vm_bo);
> > +
> > + drm_gpuvm_bo_put_deferred(op_ctx->map.vm_bo);
> > op_ctx->map.vm_bo = NULL;
>
> Hm, I don't see why we need a drm_gpuvm_bo_put_deferred() here. The
> original idea was to delegate the vm_bo ownership to the VA being added
> to the VM tree, so if we put it here, we have a UAF situation, don't we?
The vm_bo refcount goes like this:
incr vm_bo_obtain()
incr vma_link()
decr vm_bo_put()
There is no decrement in panthor_vm_cleanup_op_ctx() due to this line:
op_ctx->map.vm_bo = NULL
So when everything is done, it is linked once and the refcount is
incremented by one, which is correct.
Alice
Powered by blists - more mailing lists