Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 E8571215075; Thu, 20 Aug 2026 17:52:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787248368; cv=none; b=WbA1lZK4U+qIip2yk3jtOynwCqmIgAzBXCCK3LymnSoT4IVT7fJHmtPPi/wuEyNwFxhjrq9+O8SZs1bcJc+0S4QRVyN/Mptg2fUh3rGShpyqdMML4e04KWHAaU3BTYmkjvgg23Rv8l4BvV83UgsvqpLVyn6XhTpzDwJWRM4eTe4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787248368; c=relaxed/simple; bh=qYWAP1Bi2XaB8Sds6A+iEr9cN/tWOpaz/RHGS9qOd04=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CyeI4orRMwHosO/7Mci8UM5O6xqdyBIHiUG4meSZy5+Es+2VzevV9SIPpdqJFJ8AJ7EHDeLV/DjKBN8waRxVYbrQQU31PhaGpibxLIKC1tGxO48H7mGrCejMGzDmbQ5gErd9eNHpAJJSZTilno8Ao1jA0R6FDWUkP7KA2SJS+EI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=s5kGFXfr; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="s5kGFXfr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0F4B31F000E9; Thu, 20 Aug 2026 17:52:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1787248366; bh=OBIt1gfH7LBVRDiH9so+TFdwDF6q1lWLUXr+m+dlxSc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=s5kGFXfrXeZq1qvRHeNLBsQXIZ4Dmmx3ZV/q/pS3DAUHhfJIHUOgVf0cye0yy51vm UhRdNH6OidLKC/dJNKb4LgLNOyffNwC4nD/dN6T0axdHS+4y1SXS+G6786nhwRMZTc /bdyC7yCtnhy5p5TFdLHK3lJf6m8XWrYfixxqnME= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable , Menachem Adin , Alexander Usyskin , Sasha Levin Subject: [PATCH 6.1 204/303] mei: bus: access mei_device under device_lock on cleanup Date: Thu, 20 Aug 2026 16:55:40 +0200 Message-ID: <20260820145259.520464184@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260820145253.200766705@linuxfoundation.org> References: <20260820145253.200766705@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Alexander Usyskin [ Upstream commit f112ea910e554d58b4b39a4492b7d302f0f4204f ] Fix couple of problems in mei_cl_bus_dev_release(): mei_cl_flush_queues() is running without lock. bus->file_list access after mei_dev_bus_put(bus) can become a use-after-free if this was the last reference to bus. Protect queues cleanup and WARN traversal by device lock there to avoid the concurrent access problems. Move WARN traversal before mei_dev_bus_put(bus). This file uses bus variable name for mei_device, adjust code of mei_cl_bus_dev_release() to use bus variable too. Cc: stable Fixes: 35e8a426b16a ("mei: bus: Check for still connected devices in mei_cl_bus_dev_release()") Reviewed-by: Menachem Adin Signed-off-by: Alexander Usyskin Link: https://patch.msgid.link/20260705151259.3054795-1-alexander.usyskin@intel.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/misc/mei/bus.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) --- a/drivers/misc/mei/bus.c +++ b/drivers/misc/mei/bus.c @@ -4,6 +4,7 @@ * Intel Management Engine Interface (Intel MEI) Linux driver */ +#include #include #include #include @@ -1113,18 +1114,19 @@ static void mei_dev_bus_put(struct mei_d static void mei_cl_bus_dev_release(struct device *dev) { struct mei_cl_device *cldev = to_mei_cl_device(dev); - struct mei_device *mdev = cldev->cl->dev; + struct mei_device *bus = cldev->bus; struct mei_cl *cl; if (!cldev) return; - mei_cl_flush_queues(cldev->cl, NULL); - mei_me_cl_put(cldev->me_cl); - mei_dev_bus_put(cldev->bus); - - list_for_each_entry(cl, &mdev->file_list, link) - WARN_ON(cl == cldev->cl); + scoped_guard(mutex, &bus->device_lock) { + mei_cl_flush_queues(cldev->cl, NULL); + mei_me_cl_put(cldev->me_cl); + list_for_each_entry(cl, &bus->file_list, link) + WARN_ON(cl == cldev->cl); + } + mei_dev_bus_put(bus); kfree(cldev->cl); kfree(cldev);