All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Maíra Canal" <mcanal@igalia.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 2/3] drm/vc4: Reset the binner overflow allocator on GPU reset
Date: Sat, 18 Jul 2026 17:42:25 +0000	[thread overview]
Message-ID: <20260718174226.487661F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260718-vc4-bin-oom-fixes-v1-2-8cba09558c33@igalia.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Blindly freeing `vc4->bin_alloc_overflow` during GPU reset causes a Use-After-Free for queued render jobs that still depend on the binner overflow memory.
--

--- Patch [2]: [PATCH 2/3] drm/vc4: Reset the binner overflow allocator on GPU reset ---
commit 74342beb01de4148c8046f07cd05468691648692
Author: Maíra Canal <mcanal@igalia.com>

drm/vc4: Reset the binner overflow allocator on GPU reset

This commit resets the binner overflow allocator during a GPU reset to
prevent leaking overflow slots. It frees the pending overflow slot and
clears the hardware overflow registers so the re-queued bin job starts
from a clean state.

> diff --git a/drivers/gpu/drm/vc4/vc4_irq.c b/drivers/gpu/drm/vc4/vc4_irq.c
> index 7877d493d80e6..9fac1b39e8b98 100644
> --- a/drivers/gpu/drm/vc4/vc4_irq.c
> +++ b/drivers/gpu/drm/vc4/vc4_irq.c

[ ... ]

> @@ -344,6 +344,18 @@ void vc4_irq_reset(struct drm_device *dev)
>  	V3D_WRITE(V3D_INTENA, V3D_DRIVER_IRQS);
>  
>  	spin_lock_irqsave(&vc4->job_lock, irqflags);
> +
> +	/*
> +	 * The reset wiped the binner's hardware state, and the job that may
> +	 * have been reading overflow memory is torn down just below. Free the
> +	 * current overflow slot and clear the overflow registers so the
> +	 * re-queued BIN job restarts from a clean OOM state.
> +	 */
> +	vc4->bin_alloc_used &= ~vc4->bin_alloc_overflow;
> +	vc4->bin_alloc_overflow = 0;

[Severity: High]
Does clearing the overflow slot here create a use-after-free for render jobs
that have already completed binning and are waiting in the render queue?

If we have the following sequence:
1. Job A is executing on the render thread.
2. Job B finishes binning, using an overflow slot (tracked in
   vc4->bin_alloc_overflow), and is placed in the render queue.
3. Job C starts binning, hangs, and triggers a GPU reset.

When vc4_irq_reset() runs, it frees the overflow slot used by Job B. Then
vc4_irq_finish_render_job() completes the active render job (Job A) and
submits Job B to the hardware.

Since Job B's overflow memory was just freed, could a subsequent binning job
encounter an out-of-memory condition, allocate this exact same slot, and
overwrite it while Job B is actively reading from it?

> +	V3D_WRITE(V3D_BPOA, 0);
> +	V3D_WRITE(V3D_BPOS, 0);
> +
>  	vc4_cancel_bin_job(dev);
>  	vc4_irq_finish_render_job(dev);
>  	spin_unlock_irqrestore(&vc4->job_lock, irqflags);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260718-vc4-bin-oom-fixes-v1-0-8cba09558c33@igalia.com?part=2

  reply	other threads:[~2026-07-18 17:42 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-18 17:28 [PATCH 0/3] drm/vc4: Fix binner overflow-memory corruption and GPU hangs Maíra Canal
2026-07-18 17:28 ` [PATCH 1/3] drm/vc4: Supply the overflow slot size in BPOS, not the whole bin BO size Maíra Canal
2026-07-18 17:28 ` [PATCH 2/3] drm/vc4: Reset the binner overflow allocator on GPU reset Maíra Canal
2026-07-18 17:42   ` sashiko-bot [this message]
2026-07-18 17:28 ` [PATCH 3/3] drm/vc4: Dynamically size the initial tile-alloc block Maíra Canal
2026-07-18 17:44   ` sashiko-bot

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=20260718174226.487661F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=mcanal@igalia.com \
    --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.