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 6689229AAEF for ; Wed, 18 Jun 2025 11:16:16 +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=1750245376; cv=none; b=PasKpXy+vO1udTquBciwiAnMtouJd1L2OiQGtMKxyqDdvcsQassmFtZEwTbGOMrzwcph1cAaO+oDK30gRkjz3Y+sSjhuEwo0AgXl/hW0RSnc9jFG30QSDY7gNt8+4Yo32jCq44wLtdzRioBCZKk12Km1X5ItfhXC8ZVoSEK//Eg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750245376; c=relaxed/simple; bh=Q0CBA114h7nwnBDVneeounrJzzRvtGEEKfe+oOiWPus=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=qn+EvvFfyfmL7sFVKCZT2ZsnzBEg2ewyUCVinLUhYvxsA4yRSnpo+oKAsinAo7bQN+EhX1M61YImexJi3dxQ50Y3MY8vfLJUnB/JxsutA++pYXVdJcEW099CvPfgzjWCm4+bZDskBJYthbP0IuzocN3dcrA0QKgQZUxrMBArWNE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=I5kttgaz; 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="I5kttgaz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E04A5C4CEF1; Wed, 18 Jun 2025 11:16:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1750245376; bh=Q0CBA114h7nwnBDVneeounrJzzRvtGEEKfe+oOiWPus=; h=From:To:Cc:Subject:Date:Reply-to:From; b=I5kttgaz+XDrL2tPrNYwVVO8OyZe+b6PH9VAecsBE5OM+dk/2hDmPRmjK7+6ao9wu aYJt7lN9QKHDXzUxrWwb4t2pspWLliSKa2Jo80qMrmDWlDoHb8xvo1mU+enGb27mls U//o5fKhJUbaZp86Amb+xxRr2N07DY8ahVqimgxA= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2022-50214: coresight: Clear the connection field properly Date: Wed, 18 Jun 2025 13:04:39 +0200 Message-ID: <2025061844-CVE-2022-50214-6569@gregkh> X-Mailer: git-send-email 2.49.0 Precedence: bulk X-Mailing-List: linux-cve-announce@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Reply-to: , X-Developer-Signature: v=1; a=openpgp-sha256; l=6940; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=fKePHHAfSjHsU6mtu9ENUX1v7EGKaoz5A0oQyFDsk08=; b=owGbwMvMwCRo6H6F97bub03G02pJDBlBc2a+yop4PeVD+9y5D+7bC0v/md+kvnJu/Mka+ZNlS rvcay7P6IhlYRBkYpAVU2T5so3n6P6KQ4pehranYeawMoEMYeDiFICJfO5hWHDNzLN23w4bsU8r d2z/8oblv+/D+VMY5lnpcteWR286pycQ8X9fAFeszXlzFQA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit From: Greg Kroah-Hartman Description =========== In the Linux kernel, the following vulnerability has been resolved: coresight: Clear the connection field properly coresight devices track their connections (output connections) and hold a reference to the fwnode. When a device goes away, we walk through the devices on the coresight bus and make sure that the references are dropped. This happens both ways: a) For all output connections from the device, drop the reference to the target device via coresight_release_platform_data() b) Iterate over all the devices on the coresight bus and drop the reference to fwnode if *this* device is the target of the output connection, via coresight_remove_conns()->coresight_remove_match(). However, the coresight_remove_match() doesn't clear the fwnode field, after dropping the reference, this causes use-after-free and additional refcount drops on the fwnode. e.g., if we have two devices, A and B, with a connection, A -> B. If we remove B first, B would clear the reference on B, from A via coresight_remove_match(). But when A is removed, it still has a connection with fwnode still pointing to B. Thus it tries to drops the reference in coresight_release_platform_data(), raising the bells like : [ 91.990153] ------------[ cut here ]------------ [ 91.990163] refcount_t: addition on 0; use-after-free. [ 91.990212] WARNING: CPU: 0 PID: 461 at lib/refcount.c:25 refcount_warn_saturate+0xa0/0x144 [ 91.990260] Modules linked in: coresight_funnel coresight_replicator coresight_etm4x(-) crct10dif_ce coresight ip_tables x_tables ipv6 [last unloaded: coresight_cpu_debug] [ 91.990398] CPU: 0 PID: 461 Comm: rmmod Tainted: G W T 5.19.0-rc2+ #53 [ 91.990418] Hardware name: ARM LTD ARM Juno Development Platform/ARM Juno Development Platform, BIOS EDK II Feb 1 2019 [ 91.990434] pstate: 600000c5 (nZCv daIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 91.990454] pc : refcount_warn_saturate+0xa0/0x144 [ 91.990476] lr : refcount_warn_saturate+0xa0/0x144 [ 91.990496] sp : ffff80000c843640 [ 91.990509] x29: ffff80000c843640 x28: ffff800009957c28 x27: ffff80000c8439a8 [ 91.990560] x26: ffff00097eff1990 x25: ffff8000092b6ad8 x24: ffff00097eff19a8 [ 91.990610] x23: ffff80000c8439a8 x22: 0000000000000000 x21: ffff80000c8439c2 [ 91.990659] x20: 0000000000000000 x19: ffff00097eff1a10 x18: ffff80000ab99c40 [ 91.990708] x17: 0000000000000000 x16: 0000000000000000 x15: ffff80000abf6fa0 [ 91.990756] x14: 000000000000001d x13: 0a2e656572662d72 x12: 657466612d657375 [ 91.990805] x11: 203b30206e6f206e x10: 6f69746964646120 x9 : ffff8000081aba28 [ 91.990854] x8 : 206e6f206e6f6974 x7 : 69646461203a745f x6 : 746e756f63666572 [ 91.990903] x5 : ffff00097648ec58 x4 : 0000000000000000 x3 : 0000000000000027 [ 91.990952] x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff00080260ba00 [ 91.991000] Call trace: [ 91.991012] refcount_warn_saturate+0xa0/0x144 [ 91.991034] kobject_get+0xac/0xb0 [ 91.991055] of_node_get+0x2c/0x40 [ 91.991076] of_fwnode_get+0x40/0x60 [ 91.991094] fwnode_handle_get+0x3c/0x60 [ 91.991116] fwnode_get_nth_parent+0xf4/0x110 [ 91.991137] fwnode_full_name_string+0x48/0xc0 [ 91.991158] device_node_string+0x41c/0x530 [ 91.991178] pointer+0x320/0x3ec [ 91.991198] vsnprintf+0x23c/0x750 [ 91.991217] vprintk_store+0x104/0x4b0 [ 91.991238] vprintk_emit+0x8c/0x360 [ 91.991257] vprintk_default+0x44/0x50 [ 91.991276] vprintk+0xcc/0xf0 [ 91.991295] _printk+0x68/0x90 [ 91.991315] of_node_release+0x13c/0x14c [ 91.991334] kobject_put+0x98/0x114 [ 91.991354] of_node_put+0x24/0x34 [ 91.991372] of_fwnode_put+0x40/0x5c [ 91.991390] fwnode_handle_put+0x38/0x50 [ 91.991411] coresight_release_platform_data+0x74/0xb0 [coresight] [ 91.991472] coresight_unregister+0x64/0xcc [coresight] [ 91.991525] etm4_remove_dev+0x64/0x78 [coresight_etm4x] [ 91.991563] etm4_remove_amba+0x1c/0x2c [coresight_etm4x] [ 91.991598] amba_remove+0x3c/0x19c Reproducible by: (Build all coresight components as modules): #!/bin/sh while true do for m in tmc stm cpu_debug etm4x replicator funnel do modprobe coresight_${m} done for m in tmc stm cpu_debug etm4x replicator funnel do rmmode coresight_${m} done done The Linux kernel CVE team has assigned CVE-2022-50214 to this issue. Affected and fixed versions =========================== Issue introduced in 5.3 with commit 37ea1ffddffa63c920ce826786fe610c78f57842 and fixed in 5.4.211 with commit e9205d8dd1cafb7cff689ef9ddf06276a68f54a4 Issue introduced in 5.3 with commit 37ea1ffddffa63c920ce826786fe610c78f57842 and fixed in 5.10.137 with commit 847b9273dd61567fb77617eabc5fa002594db062 Issue introduced in 5.3 with commit 37ea1ffddffa63c920ce826786fe610c78f57842 and fixed in 5.15.61 with commit b49b29ee113a87997bcca0bb0585bb46582846c1 Issue introduced in 5.3 with commit 37ea1ffddffa63c920ce826786fe610c78f57842 and fixed in 5.18.18 with commit d43e967963c4d1b2b49f894d2f1b12865f87b098 Issue introduced in 5.3 with commit 37ea1ffddffa63c920ce826786fe610c78f57842 and fixed in 5.19.2 with commit bc57850fcb7e4cb91b6321d0ce83357cefd55c54 Issue introduced in 5.3 with commit 37ea1ffddffa63c920ce826786fe610c78f57842 and fixed in 6.0 with commit 2af89ebacf299b7fba5f3087d35e8a286ec33706 Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community. Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at https://cve.org/CVERecord/?id=CVE-2022-50214 will be updated if fixes are backported, please check that for the most up to date information about this issue. Affected files ============== The file(s) affected by this issue are: drivers/hwtracing/coresight/coresight-core.c Mitigation ========== The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits: https://git.kernel.org/stable/c/e9205d8dd1cafb7cff689ef9ddf06276a68f54a4 https://git.kernel.org/stable/c/847b9273dd61567fb77617eabc5fa002594db062 https://git.kernel.org/stable/c/b49b29ee113a87997bcca0bb0585bb46582846c1 https://git.kernel.org/stable/c/d43e967963c4d1b2b49f894d2f1b12865f87b098 https://git.kernel.org/stable/c/bc57850fcb7e4cb91b6321d0ce83357cefd55c54 https://git.kernel.org/stable/c/2af89ebacf299b7fba5f3087d35e8a286ec33706