From nobody Sun Feb 8 17:22:09 2026 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (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 43AC2192D7F for ; Wed, 27 Nov 2024 10:35:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732703732; cv=none; b=lwuztJyTqJAKQxttNwhp6gUwf+qqiIHwNA6eV7UcPUS9FoKIFp+RDKLxw3u+oxHR7mK3bi5ZJgU14+is2j2EDEPKD2VyTk7weeCnmn8ViDtn1RvSrqf5RKxZlClEClBbyldbxtrQZ0aG/YlicIS/BcswHzuTafoYrpF/A26qQnc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732703732; c=relaxed/simple; bh=ZYvcVW323NA1Uz0R0y6vV9hQQgnQEtYSCpswGooTjps=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=hhE6uziYk0LGaN7LyLVv2WujvCJc3qhbwfrHQyPBLLvmg7LqFpWxas6TrAqI/IhybfP+QM6Hh4L8skzs2ueATuTnizU304aaySLcVIyC7D3V63rWx6JfExhC/lgshN3Wc9q+veWLALU+XF8rIbzfxwxEP+CnzyFXdAGBjHEGP84= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: 4b5c6b80acab11efa216b1d71e6e1362-20241127 X-CTIC-Tags: HR_CC_AS_FROM, HR_CC_COUNT, HR_CC_DOMAIN_COUNT, HR_CC_NAME, HR_CTE_8B HR_CTT_MISS, HR_DATE_H, HR_DATE_WKD, HR_DATE_ZONE, HR_FROM_DIGIT_LEN HR_FROM_NAME, HR_SJ_DIGIT_LEN, HR_SJ_LANG, HR_SJ_LEN, HR_SJ_LETTER HR_SJ_NOR_SYM, HR_SJ_PHRASE, HR_SJ_PHRASE_LEN, HR_SJ_WS, HR_TO_COUNT HR_TO_DOMAIN_COUNT, HR_TO_NO_NAME, IP_TRUSTED, SRC_TRUSTED, DN_TRUSTED SA_TRUSTED, SA_EXISTED, SN_TRUSTED, SN_EXISTED, SPF_NOPASS DKIM_NOPASS, DMARC_NOPASS, CIE_BAD, CIE_GOOD_SPF, GTI_FG_BS GTI_RG_INFO, GTI_C_BU, AMN_GOOD X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.38,REQID:87ae4f1d-adf2-492c-af4e-792c2f9d5e46,IP:0,U RL:0,TC:0,Content:-5,EDM:25,RT:0,SF:-5,FILE:0,BULK:0,RULE:Release_Ham,ACTI ON:release,TS:15 X-CID-INFO: VERSION:1.1.38,REQID:87ae4f1d-adf2-492c-af4e-792c2f9d5e46,IP:0,URL :0,TC:0,Content:-5,EDM:25,RT:0,SF:-5,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:15 X-CID-META: VersionHash:82c5f88,CLOUDID:9d23c5b4a4b6e64eb6e2fbffd11d9fdd,BulkI D:241127183519U1COWKNK,BulkQuantity:0,Recheck:0,SF:17|19|38|66|102,TC:nil, Content:0,EDM:5,IP:nil,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0 ,OSI:0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_FSD,TF_CID_SPAM_SNR,TF_CID_SPAM_FAS X-UUID: 4b5c6b80acab11efa216b1d71e6e1362-20241127 X-User: xiaopei01@kylinos.cn Received: from xiaopei-pc.. [(10.44.16.150)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA with TLSv1.3 TLS_AES_256_GCM_SHA384 256/256) with ESMTP id 193568006; Wed, 27 Nov 2024 18:35:17 +0800 From: Pei Xiao To: alexandre.belloni@bootlin.com, aniketmaurya@google.com, =linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Pei Xiao Subject: [PATCH] i3c: dw: Fix use-after-free in dw_i3c_master driver due to race condition Date: Wed, 27 Nov 2024 18:35:11 +0800 Message-Id: X-Mailer: git-send-email 2.34.1 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" In dw_i3c_common_probe, &master->hj_work is bound with dw_i3c_hj_work. And dw_i3c_master_irq_handler can call dw_i3c_master_irq_handle_ibis function to start the work. If we remove the module which will call dw_i3c_common_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 | dw_i3c_hj_work dw_i3c_common_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 dw_i3c_common_remove. Fixes: 1dd728f5d4d4 ("i3c: master: Add driver for Synopsys DesignWare IP") Signed-off-by: Pei Xiao --- drivers/i3c/master/dw-i3c-master.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/i3c/master/dw-i3c-master.c b/drivers/i3c/master/dw-i3c= -master.c index 8d694672c110..dbcd3984f257 100644 --- a/drivers/i3c/master/dw-i3c-master.c +++ b/drivers/i3c/master/dw-i3c-master.c @@ -1624,6 +1624,7 @@ EXPORT_SYMBOL_GPL(dw_i3c_common_probe); =20 void dw_i3c_common_remove(struct dw_i3c_master *master) { + cancel_work_sync(&master->hj_work); i3c_master_unregister(&master->base); =20 pm_runtime_disable(master->dev); --=20 2.34.1