From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com [136.143.188.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 064E83D6690 for ; Mon, 20 Jul 2026 09:48:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.112 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784540901; cv=pass; b=Fc2Vden8Eceu5fXs5EP0eimvZMXtlM8oZ3hgT8+MzsoZ65ER0NJtxrtyUVOtnqEJ0rK7B3kZj2lUhF0ecGEzCistboQZ+m7IU6fjkbzr6VYEb6RVQjjnkwoyp7xAsGQfJppdNqqq3X6NJZ65R+46FfKmmI27icBgZKxVlOzFw3o= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784540901; c=relaxed/simple; bh=FFuSvO+VQfS6YllXqnDj2s4469I4vF6bk4UMtttqukY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=J2cfo6oEz4S+ZvAxoyrQ+S6s6Fwq8qzO+X0X+4bLd2TXYCG8aBoOj34Z+25WhhT4LL1UtQMDAEY2R0tuLMxsZcIP2FCLhUZpgqAnfi3h1Vc9U7BmvufmxieaZ3Apf6QDfGm0zAuQXPDQmEk+PCny9PGlP47nV5Q0KkJS6C2FmJ4= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (1024-bit key) header.d=collabora.com header.i=nicolas.frattaroli@collabora.com header.b=lLRgpw36; arc=pass smtp.client-ip=136.143.188.112 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=collabora.com header.i=nicolas.frattaroli@collabora.com header.b="lLRgpw36" ARC-Seal: i=1; a=rsa-sha256; t=1784540886; cv=none; d=zohomail.com; s=zohoarc; b=ZsocTz/8b0nVZF8qsJxiZUPQfX01++RPg63N2+4t22GehJNJ+sUMUIvbpb1uwD8x2dsOedaSQKv/fur6EnbEAHgIyV8smAX7rM+VnlEu8Gi76HjeCxv6CQcgC1t4XG5/uY1ux1hEOsGHqvmVnYNz9Yrswa4rEDj71ajTGV/vWg4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784540886; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To; bh=f06YDyvcwlZTxvovNFtb1iwHk4VC7nx7/aML7uTwEsI=; b=OlDK8pvYXTNtmhp44Z7q2JJRAUBn4iQvkA+d06kGtSVvWLSUVqe6YLbFyO23zfOBhLfnltm9/X2sluzyRR2koju87jgNCR7LRroYXW04+39BzM00QVEWOg/2zTtaewImCGA9TQ1qJBrSOedxxisDwbNp5UrWk7YzwAp5Ozy0bE0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=nicolas.frattaroli@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1784540886; s=zohomail; d=collabora.com; i=nicolas.frattaroli@collabora.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:In-Reply-To:MIME-Version:Content-Transfer-Encoding:Content-Type:Message-Id:Reply-To; bh=f06YDyvcwlZTxvovNFtb1iwHk4VC7nx7/aML7uTwEsI=; b=lLRgpw36yyE6HgjGZukGkOLNRqT8NVVhLC9KUPirfPangFD/IHHhYhldLeVabHX5 2iMz9g60zzKaJCbvLEuesmIGgfaSoMBk74UkeyPabyBXZ4GjroWiHZmNptE7m2q4WCW M4dRfRMnyfkEQHXovmhrimTavzwcdh/Bn3Oa+YBM= Received: by mx.zohomail.com with SMTPS id 1784540885604554.0929587352072; Mon, 20 Jul 2026 02:48:05 -0700 (PDT) From: Nicolas Frattaroli To: Steven Price , Liviu Dudau , Boris Brezillon Cc: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Chia-I Wu , Karunika Choo , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Boris Brezillon , sashiko-bot@kernel.org Subject: Re: [PATCH 03/11] drm/panthor: Fix UAF on works queued to panthor_cleanup_wq Date: Mon, 20 Jul 2026 11:47:59 +0200 Message-ID: In-Reply-To: <20260625-panthor-misc-fixes-v1-3-b67ed973fea6@collabora.com> References: <20260625-panthor-misc-fixes-v1-0-b67ed973fea6@collabora.com> <20260625-panthor-misc-fixes-v1-3-b67ed973fea6@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="utf-8" On Thursday, 25 June 2026 14:40:29 Central European Summer Time Boris Brezillon wrote: > If we don't drain the panthor_cleanup_wq before > unregistering/destroying the panthor_device, we might end up with > cleanup works that are executed after the device is gone. > > Add a drain_workqueue() call in panthor_device_unplug() to prevent > that. > > Fixes: de8548813824 ("drm/panthor: Add the scheduler logical block") > Fixes: 647810ec2476 ("drm/panthor: Add the MMU/VM logical block") > Reported-by: sashiko-bot@kernel.org > Closes: https://sashiko.dev/#/patchset/20260625-panthor-signal-from-irq-v5-0-8836a74e0ef9@collabora.com?part=2 > Signed-off-by: Boris Brezillon > --- > drivers/gpu/drm/panthor/panthor_device.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/drivers/gpu/drm/panthor/panthor_device.c b/drivers/gpu/drm/panthor/panthor_device.c > index 0b25abebb803..a0774e28aa94 100644 > --- a/drivers/gpu/drm/panthor/panthor_device.c > +++ b/drivers/gpu/drm/panthor/panthor_device.c > @@ -101,6 +101,11 @@ void panthor_device_unplug(struct panthor_device *ptdev) > panthor_gpu_unplug(ptdev); > panthor_pwr_unplug(ptdev); > > + /* Make sure works queued to panthor_cleanup_wq are executed > + * before the device is destroyed. > + */ > + drain_workqueue(panthor_cleanup_wq); > + > pm_runtime_dont_use_autosuspend(ptdev->base.dev); > pm_runtime_put_sync_suspend(ptdev->base.dev); > > > I feel like nothing in the driver instance should be allowed to queue new work to that workqueue while the unplug mutex is being held, and panthor_sched_unplug should just disable_work_sync all the associated group release_work items as well. If there's not a strong enough relationship between a scheduler and the groups to ensure we get all the groups in a non-racey manner that might not work out cleanly though. Having a scheduler unplug be completely disconnected from the associated groups being gone seems counter-intuitive to me. Kind regards, Nicolas Frattaroli