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 <[email protected]> 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/[email protected]?part=1
