From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF14AC00A8F for ; Tue, 24 Oct 2023 02:01:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231978AbjJXCBn (ORCPT ); Mon, 23 Oct 2023 22:01:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231740AbjJXCBm (ORCPT ); Mon, 23 Oct 2023 22:01:42 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B928DC2 for ; Mon, 23 Oct 2023 19:01:39 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F2750C433C7; Tue, 24 Oct 2023 02:01:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698112899; bh=fc3NKMfZoje2hmQNMCXwrEeKB9yHVquKxP4o2hHyQ+A=; h=In-Reply-To:References:Subject:From:Cc:To:Date:From; b=Pv5Cwg6lrfNB4MajdApvNEULjDz3t0D2/xLwROHqGAQ0KyWhnAq3U/HwPS07lav57 0RuuIPkEZCxv6FsT9lB1DD10IxtXfng+3fjyxJOAFuHJBhdrawOg3GJp6twfi1r0SK ADO2tr3Smk5HojfVBb0dRqABH7e8ld9VsbBdRPeL8+TwSOZ7NGmVmjSH6IXf58AUiV IzQzHFB0VOC90BRHf5tCREzTJhB5A+wR1rQj3Biykm1aXpIlgM33AtD2TWWZQQqHxj ej7u+EDYAcEYkC/wnM8e5y8pbx8IxAvbzqzBM8GxULHDiQ3MZBRPhEOP1XV3vxcNBa 79E//dVbSaOgg== Message-ID: Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: <20230717173934.1.If004a6e055a189c7f2d0724fa814422c26789839@changeid> References: <20230717173934.1.If004a6e055a189c7f2d0724fa814422c26789839@changeid> Subject: Re: [PATCH] spmi: mediatek: Fix UAF on device remove From: Stephen Boyd Cc: Yu-Che Cheng , Fei Shao , AngeloGioacchino Del Regno , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org To: James Lo , Matthias Brugger , Yu-Che Cheng Date: Mon, 23 Oct 2023 19:01:36 -0700 User-Agent: alot/0.10 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Yu-Che Cheng (2023-07-17 02:39:35) > The pmif driver data that contains the clocks is allocated along with > spmi_controller. > On device remove, spmi_controller will be freed first, and then devres > , including the clocks, will be cleanup. > This leads to UAF because putting the clocks will access the clocks in > the pmif driver data, which is already freed along with spmi_controller. >=20 > This can be reproduced by enabling DEBUG_TEST_DRIVER_REMOVE and > building the kernel with KASAN. >=20 > Fix the UAF issue by using unmanaged clk_bulk_get() and putting the > clocks before freeing spmi_controller. >=20 > Reported-by: Fei Shao > Signed-off-by: Yu-Che Cheng > --- Applied to spmi-next