From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 45D451A76C4; Mon, 14 Oct 2024 14:25:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728915918; cv=none; b=Gl2wSxgbP8XW4s5jkrLaH+fOhGTrM92D2zO5n4iIp+WCvTUkQJ2KivBZDBlMWy92FWUV2Hpo1CA2U4lwVaoSPWTEgQ8Ob6UWax9agkvgHrdL444eA2px+E5tsPrsybVHPvzhniMAqg/XVnUThVZ0GgZOpda6rSEufyhUAfuoJfY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728915918; c=relaxed/simple; bh=f9M893cL+iUT5rTMukE/iFmLkx0JlPoG20G2SYjZgC8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WZSB5MX9+S5dpWAb+2+DKFua0mhL5Cka2j7B33P6w6DFKE8YUJKigMp5vNPeE9BldAg9rhCZe2Y5JFossh7iFa/4yXuQZi9sqLEDqzbMj02anGnxSR/sSW+8Y3sjiZNT0cU/Y9hf8nPifEO6dp2yCjXpImE0sCkOxEwa1X9ItRg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=2UPXtOZG; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="2UPXtOZG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB6B4C4CEC3; Mon, 14 Oct 2024 14:25:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1728915918; bh=f9M893cL+iUT5rTMukE/iFmLkx0JlPoG20G2SYjZgC8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2UPXtOZGr4+8YVHe+pNw94uzFpnG+yiLTgvkMGpjH3gdqsh/y9ZiVPvlDqj1u5/9B nBQ6vUsDGuURE6zcbaB6wlLi0qwwS61J96QtFjm/6JsHhYEZWImL6USZwxx2qFFgXm LRJL4zXOJFVGlOWmqu3X05irbFiKYuFVTfzrAQ0I= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Kaixin Wang , Alexandre Belloni , Sasha Levin Subject: [PATCH 6.11 037/214] i3c: master: cdns: Fix use after free vulnerability in cdns_i3c_master Driver Due to Race Condition Date: Mon, 14 Oct 2024 16:18:20 +0200 Message-ID: <20241014141046.439881511@linuxfoundation.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241014141044.974962104@linuxfoundation.org> References: <20241014141044.974962104@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.11-stable review patch. If anyone has any objections, please let me know. ------------------ From: Kaixin Wang [ Upstream commit 609366e7a06d035990df78f1562291c3bf0d4a12 ] In the cdns_i3c_master_probe function, &master->hj_work is bound with cdns_i3c_master_hj. And cdns_i3c_master_interrupt can call cnds_i3c_master_demux_ibis function to start the work. If we remove the module which will call cdns_i3c_master_remove to make cleanup, it will free master->base through i3c_master_unregister while the work mentioned above will be used. The sequence of operations that may lead to a UAF bug is as follows: CPU0 CPU1 | cdns_i3c_master_hj cdns_i3c_master_remove | i3c_master_unregister(&master->base) | device_unregister(&master->dev) | device_release | //free master->base | | i3c_master_do_daa(&master->base) | //use master->base Fix it by ensuring that the work is canceled before proceeding with the cleanup in cdns_i3c_master_remove. Signed-off-by: Kaixin Wang Link: https://lore.kernel.org/r/20240911153544.848398-1-kxwang23@m.fudan.edu.cn Signed-off-by: Alexandre Belloni Signed-off-by: Sasha Levin --- drivers/i3c/master/i3c-master-cdns.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/i3c/master/i3c-master-cdns.c b/drivers/i3c/master/i3c-master-cdns.c index c1627f3552ce3..c2d26beb3da2b 100644 --- a/drivers/i3c/master/i3c-master-cdns.c +++ b/drivers/i3c/master/i3c-master-cdns.c @@ -1666,6 +1666,7 @@ static void cdns_i3c_master_remove(struct platform_device *pdev) { struct cdns_i3c_master *master = platform_get_drvdata(pdev); + cancel_work_sync(&master->hj_work); i3c_master_unregister(&master->base); clk_disable_unprepare(master->sysclk); -- 2.43.0