From nobody Sat Feb 7 08:45:26 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E89A2306D37 for ; Mon, 27 Oct 2025 14:04:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761573882; cv=none; b=Gre6UhMIW4uL4egOQNKuVD2hqjAUf6H/tSv29ZcQn7NZ/TcDkbp/rsicmeEmPYWTFeJ74nK+zwvtRBLdfCynTu7UFc9swu51WKLGhwN3FBDe3mSs7MxpVYP3w0Q2sbXMJU+KDmJwqTTS9lypC3F2hPL1+7MTYXRRFBsWVGWQKQw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761573882; c=relaxed/simple; bh=9zxjz9NOhoRdOTYGuUCKAVqb/6KCrud23EzmthKL0OU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=YHkR+tz17uOysGlTR90FlYzb0cySAo4TFbqwSCgAqhn/AUfbyWG72PIGr6usagrLqSTGZ/PuwF3POZbZOJsazWA/LSAya6fpOedRbGBW9R8Q6L9+80SrXCRSektJnf+2FSQrjAaYUcaig20/vBt61T8R46YX7Xaf0nZos/9v4oM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 28304169E; Mon, 27 Oct 2025 07:04:32 -0700 (PDT) Received: from e120398-lin.trondheim.arm.com (e120398-lin.trondheim.arm.com [10.40.16.110]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4B6973F63F; Mon, 27 Oct 2025 07:04:37 -0700 (PDT) From: Ketil Johnsen To: Boris Brezillon , Steven Price , Liviu Dudau , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Heiko Stuebner Cc: Ketil Johnsen , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH v3] drm/panthor: Fix UAF race between device unplug and FW event processing Date: Mon, 27 Oct 2025 15:02:15 +0100 Message-ID: <20251027140217.121274-1-ketil.johnsen@arm.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The function panthor_fw_unplug() will free the FW memory sections. The problem is that there could still be pending FW events which are yet not handled at this point. process_fw_events_work() can in this case try to access said freed memory. Simply call disable_work_sync() to both drain and prevent future invocation of process_fw_events_work(). Signed-off-by: Ketil Johnsen Fixes: de85488138247 ("drm/panthor: Add the scheduler logical block") Reviewed-by: Boris Brezillon Reviewed-by: Liviu Dudau --- v2: - Followed Boris's advice and handle the race purely within the scheduler block (by adding a destroyed state) v3: - New approach, one single call to disable_work_sync() --- drivers/gpu/drm/panthor/panthor_sched.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/panthor/panthor_sched.c b/drivers/gpu/drm/pant= hor/panthor_sched.c index 0cc9055f4ee52..b7595beaa0205 100644 --- a/drivers/gpu/drm/panthor/panthor_sched.c +++ b/drivers/gpu/drm/panthor/panthor_sched.c @@ -3880,6 +3880,7 @@ void panthor_sched_unplug(struct panthor_device *ptde= v) struct panthor_scheduler *sched =3D ptdev->scheduler; =20 cancel_delayed_work_sync(&sched->tick_work); + disable_work_sync(&sched->fw_events_work); =20 mutex_lock(&sched->lock); if (sched->pm.has_ref) { --=20 2.47.2