All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Boris Brezillon" <boris.brezillon@collabora.com>
Cc: dri-devel@lists.freedesktop.org, media-ci@linuxtv.org
Subject: Re: [PATCH v2] drm/panthor: Explode container fences to optimize pipelining
Date: Tue, 01 Dec 2026 16:42:00 +0000	[thread overview]
Message-ID: <sashiko-outbox-243728@kernel.org> (raw)
In-Reply-To: <20261201-panhtor-dep-skip-v2-1-1b38efda8a0d@collabora.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Critical] drm/panthor: UAF and fence leak in
  panthor_submit_ctx_add_sync_deps_to_job()
--

commit 3773f564b72f530f132073bcf4cc78bc75601759
Author: Boris Brezillon <boris.brezillon@collabora.com>

drm/panthor: Explode container fences to optimize pipelining

This commit unwraps fence containers with dma_fence_unwrap_for_each()
when adding sync dependencies to a job so that same-queue dependencies can
be eliminated by the DRM scheduler.

> diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/panthor/panthor_drv.c
> index dc8d0191aef42..a527ce86a113b 100644
> --- a/drivers/gpu/drm/panthor/panthor_drv.c
> +++ b/drivers/gpu/drm/panthor/panthor_drv.c
[ ... ]
> @@ -637,9 +639,16 @@ panthor_submit_ctx_add_sync_deps_to_job(struct panthor_submit_ctx *ctx,
>  				return ret;
>  		}
>  
> -		ret = drm_sched_job_add_dependency(job, fence);
> -		if (ret)
> -			return ret;
> +		/* Explode containers so that drm_sched_entity_add_dependency_cb() can
> +		 * eliminate fences that are coming from the same queue.
> +		 */
> +		dma_fence_unwrap_for_each(inner_fence, &iter, fence) {
> +			ret = drm_sched_job_add_dependency(job, inner_fence);
> +			if (ret) {
> +				dma_fence_put(iter.chain);
> +				return ret;
> +			}
> +		}
>  	}
>  
>  	return 0;

[Severity: Critical]
Does passing inner_fence directly to drm_sched_job_add_dependency()
underflow inner_fence's refcount while leaking fence?

dma_fence_unwrap_for_each() takes its own iterator reference on fence in
iter.chain and yields each inner_fence without taking a new reference on
it, whereas drm_sched_job_add_dependency() always consumes one reference
on the fence passed to it.  When fence is a container such as a
dma_fence_chain from a timeline syncobj, drm_sched_job_add_dependency()
drops the container's reference on inner_fence, causing a use-after-free,
while the caller's reference on fence acquired before the loop is never
released.

Passing dma_fence_get(inner_fence) to drm_sched_job_add_dependency() and
calling dma_fence_put(fence) after the loop (and on the error path) would
fix both issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261201-panhtor-dep-skip-v2-1-1b38efda8a0d@collabora.com?part=1

  reply	other threads:[~2026-12-01 16:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 16:35 [PATCH v2] drm/panthor: Explode container fences to optimize pipelining Boris Brezillon
2026-12-01 16:42 ` sashiko-bot [this message]
2026-12-01 16:52 ` Boris Brezillon
2026-12-01 17:00   ` Christian König
2026-12-02  3:41 ` Xianzhong Li

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-243728@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=boris.brezillon@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=media-ci@linuxtv.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.