From: sashiko-bot@kernel.org
To: "Jiwoo Kim" <arpe1618@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/panthor: Fix unlocked pool->vm access in panthor_heap_create()
Date: Fri, 13 Nov 2026 17:29:57 +0000 [thread overview]
Message-ID: <sashiko-outbox-213309@kernel.org> (raw)
In-Reply-To: <20261113171211.836427578-1-arpe1618@gmail.com>
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] drm/panthor: use-after-free of pool->gpu_contexts in
panthor_heap_grow() [1]
--
commit 8965445d49e12381fc8f429998271cbb17e58ff7
Author: Jiwoo Kim <arpe1618@gmail.com>
drm/panthor: Fix unlocked pool->vm access in panthor_heap_create()
This commit passes an explicit panthor_vm pointer to
panthor_alloc_heap_chunk() and panthor_alloc_heap_chunks() so that
panthor_heap_create() uses the VM reference acquired under pool->lock
rather than reading pool->vm unlocked.
> diff --git a/drivers/gpu/drm/panthor/panthor_heap.c b/drivers/gpu/drm/panthor/panthor_heap.c
> index 99311abdf1e91..46f53699a2601 100644
> --- a/drivers/gpu/drm/panthor/panthor_heap.c
> +++ b/drivers/gpu/drm/panthor/panthor_heap.c
[ ... ]
> @@ -473,7 +479,7 @@ int panthor_heap_grow(struct panthor_heap_pool *pool,
> * further jobs in this queue fail immediately instead of having to
> * wait for the job timeout.
> */
> - ret = panthor_alloc_heap_chunk(pool, heap, false);
> + ret = panthor_alloc_heap_chunk(pool, pool->vm, heap, false);
> if (ret)
> goto out_unlock;
>
[Severity: High]
This problem wasn't introduced by this patch, but can panthor_heap_grow()
(and panthor_heap_return_chunk()) trigger a use-after-free on
pool->gpu_contexts [1] when racing with panthor_heap_pool_destroy()?
drivers/gpu/drm/panthor/panthor_heap.c:panthor_heap_grow() {
u64 offset = heap_gpu_va - panthor_kernel_bo_gpuva(pool->gpu_contexts);
u32 heap_id = (u32)offset / panthor_heap_ctx_stride(pool->ptdev);
...
if (offset > U32_MAX || heap_id >= MAX_HEAPS_PER_POOL)
return -EINVAL;
down_read(&pool->lock);
...
}
group_process_tiler_oom() grabs a reference to the heap pool under
sched->lock and drops the lock before calling panthor_heap_grow().
Because panthor_vm_destroy() does not flush sched->heap_alloc_wq,
panthor_heap_pool_destroy() can destroy pool->gpu_contexts under
pool->lock while the pool stays alive through the worker's reference:
kworker CPU0
group_tiler_oom_work()
group_process_tiler_oom()
panthor_vm_get_heap_pool()
panthor_vm_destroy()
panthor_heap_pool_destroy()
down_write(&pool->lock)
panthor_kernel_bo_destroy(...)
up_write(&pool->lock)
panthor_heap_grow()
panthor_kernel_bo_gpuva(...) <-- use-after-free
Both panthor_heap_grow() and panthor_heap_return_chunk() dereference
pool->gpu_contexts via panthor_kernel_bo_gpuva() before acquiring
pool->lock and checking whether the pool has been destroyed.
[1] https://sashiko.dev/#/bug/linux-7cebf7b5-5dd3-4267-b0af-8d80a7aa727d
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261113171211.836427578-1-arpe1618@gmail.com?part=1
prev parent reply other threads:[~2026-11-13 17:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-13 17:12 [PATCH] drm/panthor: Fix unlocked pool->vm access in panthor_heap_create() Jiwoo Kim
2026-11-13 17:29 ` sashiko-bot [this message]
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=sashiko-outbox-213309@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=arpe1618@gmail.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.