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 09F26144D0B for ; Tue, 21 May 2024 15:35:36 +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=1716305736; cv=none; b=EXjLo/Y+xNGTcFABRhmmDrQqsDNorFxpPrOK1zs9TjQhZvF36cIc/yG7lW/fxvL0cbxK5S2J3aKCuOvtvkiMIqk2llEYRSw9/Y9Dy3ZwM9HpGhIL0g8Xt9SyXJSba6HnbfHYY9HMgQ0hk9rjFgCm1ZZphdZ1bx1TQRIhO4EnWcA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716305736; c=relaxed/simple; bh=almA4UKKdRYfiOKLINX6dvYkZU7O4XZhl4Kmgz/kqME=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=VT0LQBdscWs5EdFdBMDTWhn1tkR66ziCtnFIRPo8AFMPsR2l+JVI25AnI5hJuT7HP3uK8JdXOp35AK6irPTTRnUrwqDfGf+4jrsQlKVbxShOxHO0uLkQPQwYnss8Q93v8XzQuYHLMjclE9eT0J/eol4gtkMu5cpzhqZSssyjM30= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=j3ojco7L; 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="j3ojco7L" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8372EC2BD11; Tue, 21 May 2024 15:35:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1716305735; bh=almA4UKKdRYfiOKLINX6dvYkZU7O4XZhl4Kmgz/kqME=; h=From:To:Cc:Subject:Date:Reply-to:From; b=j3ojco7Lm9YZK2DbXSAlD6M4gxn6SngevbPhjlpOml3JiCGugpcto68oCFqU0xv4U y6K01vjRxwD8/qkDDz8q8gzPO/E8A6aUecEjtXFy26IqIVk/Zx4RAUSGLTbDLSeTHs pGZI6w0g3ke0by8j6pCCMpKJmyUSrfZxUufVJ7ho= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2023-52771: cxl/port: Fix delete_endpoint() vs parent unregistration race Date: Tue, 21 May 2024 17:31:07 +0200 Message-ID: <2024052150-CVE-2023-52771-43ad@gregkh> X-Mailer: git-send-email 2.45.1 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=3541; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=almA4UKKdRYfiOKLINX6dvYkZU7O4XZhl4Kmgz/kqME=; b=owGbwMvMwCRo6H6F97bub03G02pJDGk++7QKgt+9s/50orXJgWvGfA7+4oV3AmZ5BB9T+ezPt i6jdJlARywLgyATg6yYIsuXbTxH91ccUvQytD0NM4eVCWQIAxenAExEdxrDgumfVPvqnyWk8jNI Hp7+087tlkKYOMNcYUMugctmSaxmV7ak2vp+trq1d2MpAA== X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit Description =========== In the Linux kernel, the following vulnerability has been resolved: cxl/port: Fix delete_endpoint() vs parent unregistration race The CXL subsystem, at cxl_mem ->probe() time, establishes a lineage of ports (struct cxl_port objects) between an endpoint and the root of a CXL topology. Each port including the endpoint port is attached to the cxl_port driver. Given that setup, it follows that when either any port in that lineage goes through a cxl_port ->remove() event, or the memdev goes through a cxl_mem ->remove() event. The hierarchy below the removed port, or the entire hierarchy if the memdev is removed needs to come down. The delete_endpoint() callback is careful to check whether it is being called to tear down the hierarchy, or if it is only being called to teardown the memdev because an ancestor port is going through ->remove(). That care needs to take the device_lock() of the endpoint's parent. Which requires 2 bugs to be fixed: 1/ A reference on the parent is needed to prevent use-after-free scenarios like this signature: BUG: spinlock bad magic on CPU#0, kworker/u56:0/11 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS edk2-20230524-3.fc38 05/24/2023 Workqueue: cxl_port detach_memdev [cxl_core] RIP: 0010:spin_bug+0x65/0xa0 Call Trace: do_raw_spin_lock+0x69/0xa0 __mutex_lock+0x695/0xb80 delete_endpoint+0xad/0x150 [cxl_core] devres_release_all+0xb8/0x110 device_unbind_cleanup+0xe/0x70 device_release_driver_internal+0x1d2/0x210 detach_memdev+0x15/0x20 [cxl_core] process_one_work+0x1e3/0x4c0 worker_thread+0x1dd/0x3d0 2/ In the case of RCH topologies, the parent device that needs to be locked is not always @port->dev as returned by cxl_mem_find_port(), use endpoint->dev.parent instead. The Linux kernel CVE team has assigned CVE-2023-52771 to this issue. Affected and fixed versions =========================== Issue introduced in 5.18 with commit 8dd2bc0f8e02 and fixed in 6.5.13 with commit 37179fcc916b Issue introduced in 5.18 with commit 8dd2bc0f8e02 and fixed in 6.6.3 with commit 6b2e428e673b Issue introduced in 5.18 with commit 8dd2bc0f8e02 and fixed in 6.7 with commit 8d2ad999ca3c 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-2023-52771 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/cxl/core/port.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/37179fcc916bce8c3cc7b36d67ef814cce55142b https://git.kernel.org/stable/c/6b2e428e673b3f55965674a426c40922e91388aa https://git.kernel.org/stable/c/8d2ad999ca3c64cb08cf6a58d227b9d9e746d708