From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2182E606A31A for ; Tue, 1 Dec 2026 16:42:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=I9wM3LRM Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8A42610FAC8; Tue, 1 Dec 2026 16:42:08 +0000 (UTC) Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4AF2010E3CA for ; Tue, 1 Dec 2026 16:42:02 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 9244D605D7; Tue, 1 Dec 2026 16:42:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 259CA1F000C1; Tue, 1 Dec 2026 16:42:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796143321; bh=+QYhsVeWWkNKmey0GLeyySJrhSLdf22ltdgxMfPI1/s=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=I9wM3LRM+q/m5ZxqIWSxLY+fAw/jgm+vL6D019rzLt4YPxKHFYboAlRwbOb6v3Mvy AEnRSaywU7yzW1TLjip3hlNbvJtP3XVFTp4hDOC8vHeQUkMRjQByugY38AFzU974fs SS+ehcELwO+jBYsnSSASsWTssKcfj0SxUPR1MCx5CMyql77NUge4Czj7SPNn++fzeY Z8vsut1yG8R0jaE/N0k0fZQSBcEqrFA9vgugCxdD3p9/juUpIPx06ISnWBH/ejpzbH 49jbh5C1bBeSobsKR1eDlRqlqc+zXxRlikSpx/ux/NmR2LmR9DoX7vamyQWeeDzZyg IC7V3KyUa8f/Q== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2] drm/panthor: Explode container fences to optimize pipelining To: "Boris Brezillon" Cc: dri-devel@lists.freedesktop.org, media-ci@linuxtv.org In-Reply-To: <20261201-panhtor-dep-skip-v2-1-1b38efda8a0d@collabora.com> References: <20261201-panhtor-dep-skip-v2-1-1b38efda8a0d@collabora.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 16:42:00 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sashiko-reviews@lists.linux.dev Sender: "dri-devel" X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: 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 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/pant= hor/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 panth= or_submit_ctx *ctx, > return ret; > } > =20 > - ret =3D 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 =3D drm_sched_job_add_dependency(job, inner_fence); > + if (ret) { > + dma_fence_put(iter.chain); > + return ret; > + } > + } > } > =20 > 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. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261201-panhtor-de= p-skip-v2-1-1b38efda8a0d@collabora.com?part=3D1