From: sashiko-bot@kernel.org
To: "Boris Brezillon" <boris.brezillon@collabora.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 04/11] drm/panthor: Fix potential invalid pointer deref in group_process_tiler_oom()
Date: Thu, 25 Jun 2026 12:54:09 +0000 [thread overview]
Message-ID: <20260625125409.D93711F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260625-panthor-misc-fixes-v1-4-b67ed973fea6@collabora.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] `group->fatal_queues` is modified without any locking in `group_process_tiler_oom()`, leading to a data race with other contexts that update it, and `group->fatal_lock` is completely unused.
- [High] Firmware render pass counter validation check is vulnerable to 32-bit integer wrap-around, which can erroneously reject valid memory allocations.
--
commit 849043d96182c6a00588e13d1652d042b8e7a787
Author: Boris Brezillon <boris.brezillon@collabora.com>
drm/panthor: Fix potential invalid pointer deref in group_process_tiler_oom()
This commit prevents a potential invalid pointer dereference when
panthor_heap_pool_put() is called with an error pointer by ensuring heaps is
set to NULL on failure.
Reported-by: sashiko-bot@kernel.org
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_sched.c b/drivers/gpu/drm/panthor/panthor_sched.c
> index e97f29469d28a..8fd4d97b062e0 100644
> --- a/drivers/gpu/drm/panthor/panthor_sched.c
> +++ b/drivers/gpu/drm/panthor/panthor_sched.c
> @@ -1600,7 +1600,10 @@ static int group_process_tiler_oom(struct panthor_group *group, u32 cs_id)
> if (unlikely(csg_id < 0))
> return 0;
>
> - if (IS_ERR(heaps) || frag_end > vt_end || vt_end >= vt_start) {
> + if (IS_ERR(heaps)) {
> + ret = -EINVAL;
> + heaps = NULL;
> + } else if (frag_end > vt_end || vt_end >= vt_start) {
^^^^^^^^^^^^^^^^^^
[Severity: High]
This isn't a bug introduced by this patch, but does this condition incorrectly
handle 32-bit unsigned wrap-arounds for the FW pass counters?
If a long-running graphical application issues enough render passes, the 32-bit
counters can wrap around. For example, if vt_start = 0x00000001 and
vt_end = 0xFFFFFFFF, the direct comparison vt_end >= vt_start evaluates to
true even though vt_start is logically ahead.
This causes valid tiler OOM requests to fail with -EINVAL, marking the
affected queue as fatal.
Should sequence arithmetic like (s32)(vt_end - vt_start) >= 0 be used here
instead to safely compare wrapping sequence numbers?
> ret = -EINVAL;
> } else {
> /* We do the allocation without holding the scheduler lock to avoid
[Severity: High]
This is a pre-existing issue, but is there a data race when updating
group->fatal_queues later in this same function?
In group_process_tiler_oom(), which executes in the heap_alloc_wq workqueue,
the fatal_queues bitmask is updated without holding any locks:
drivers/gpu/drm/panthor/panthor_sched.c:group_process_tiler_oom() {
...
if (ret && ret != -ENOMEM) {
drm_warn(&ptdev->base, "Failed to extend the tiler heap\n");
group->fatal_queues |= BIT(cs_id);
...
}
Concurrently, cs_slot_process_fatal_event_locked() updates this same field
from process_fw_events_work in the sched->wq workqueue. Because |= is a
non-atomic read-modify-write operation, concurrent execution could result
in lost updates, potentially leaving a queue that experienced a fatal error
incorrectly marked as healthy.
Additionally, panthor_group defines spinlock_t fatal_lock to protect access
to fatal fields, but this lock appears to be completely unused.
Could fatal_lock be used here to prevent the race?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260625-panthor-misc-fixes-v1-0-b67ed973fea6@collabora.com?part=4
next prev parent reply other threads:[~2026-06-25 12:54 UTC|newest]
Thread overview: 31+ 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-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 [this message]
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-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
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=20260625125409.D93711F00A3A@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 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.