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 F3B80321F34 for ; Mon, 15 Sep 2025 14:47:47 +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=1757947668; cv=none; b=eYr2r+p2olGq2GWOsQ90ZJwEN3OoSn4WkQMaaIeYlh8rIzC962BrJkqbKf29w+7S7uFGRakE/W7Sdp6Q9B7MZlzKXbPOBTwo9q5O1xr2rDud6J21foelu3+DpChP404h2cO56opwAmbHsIlO/Uo9vKDojQ+pWMI2SSKECsOOnxE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757947668; c=relaxed/simple; bh=ZBWYXFQ/zz/ahETllcU5BTCSG+2FVxa53j5UrTr/jpU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=OPGEBS6c4SdTaqdZiiTKZ7FEhXcKo16gwwfpkDXATMGxdkBgJ5sjXb1ENbXYX3kyGBU4aqNfnuvHxBoWWBAPfBPfjWK0LFDOR3B2QMJodihQ1PBM7Nz53GRmn9QsQYBqlj1aWsdWL61OU+zSXvegnwRO6blO8MbBHMT+0jwUn1A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=KFeD4q8Z; 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="KFeD4q8Z" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1190FC4CEF1; Mon, 15 Sep 2025 14:47:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1757947667; bh=ZBWYXFQ/zz/ahETllcU5BTCSG+2FVxa53j5UrTr/jpU=; h=From:To:Cc:Subject:Date:Reply-to:From; b=KFeD4q8ZCvfCH1o7mw5TE8c1yhtApaU9De4kimZ5DiU/Ob+dnprHuPfRDCgBrkeGf TRBQ22XIiHPw1ADz4mtW0LpnIxrKlVV5XG6JEF1XP6WKT3DTzRleho4tl07vvSFJSA FyM8ScruZMtH4Y772Y2S0R2ILKvaCtIsA+fJs6fQ= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2022-50315: ata: ahci: Match EM_MAX_SLOTS with SATA_PMP_MAX_PORTS Date: Mon, 15 Sep 2025 16:46:17 +0200 Message-ID: <2025091500-CVE-2022-50315-a3b8@gregkh> X-Mailer: git-send-email 2.51.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=5022; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=+nPkJdiq8aGGcWWlBrbai7/BMB5tjWCSubEfljDgBVk=; b=owGbwMvMwCRo6H6F97bub03G02pJDBkn1Fbo5Z06w5vy+pGpyoScpS5LVvieOZOyean9l2l/l esK8ufIdMSyMAgyMciKKbJ82cZzdH/FIUUvQ9vTMHNYmUCGMHBxCsBE1s9hmB9zOn5CTGLv2ui4 yJuF56ckKfTnJjPM9z/gWratwOTiDxmpXfkyFZ/cONm2AgA= 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: ata: ahci: Match EM_MAX_SLOTS with SATA_PMP_MAX_PORTS UBSAN complains about array-index-out-of-bounds: [ 1.980703] kernel: UBSAN: array-index-out-of-bounds in /build/linux-9H675w/linux-5.15.0/drivers/ata/libahci.c:968:41 [ 1.980709] kernel: index 15 is out of range for type 'ahci_em_priv [8]' [ 1.980713] kernel: CPU: 0 PID: 209 Comm: scsi_eh_8 Not tainted 5.15.0-25-generic #25-Ubuntu [ 1.980716] kernel: Hardware name: System manufacturer System Product Name/P5Q3, BIOS 1102 06/11/2010 [ 1.980718] kernel: Call Trace: [ 1.980721] kernel: [ 1.980723] kernel: show_stack+0x52/0x58 [ 1.980729] kernel: dump_stack_lvl+0x4a/0x5f [ 1.980734] kernel: dump_stack+0x10/0x12 [ 1.980736] kernel: ubsan_epilogue+0x9/0x45 [ 1.980739] kernel: __ubsan_handle_out_of_bounds.cold+0x44/0x49 [ 1.980742] kernel: ahci_qc_issue+0x166/0x170 [libahci] [ 1.980748] kernel: ata_qc_issue+0x135/0x240 [ 1.980752] kernel: ata_exec_internal_sg+0x2c4/0x580 [ 1.980754] kernel: ? vprintk_default+0x1d/0x20 [ 1.980759] kernel: ata_exec_internal+0x67/0xa0 [ 1.980762] kernel: sata_pmp_read+0x8d/0xc0 [ 1.980765] kernel: sata_pmp_read_gscr+0x3c/0x90 [ 1.980768] kernel: sata_pmp_attach+0x8b/0x310 [ 1.980771] kernel: ata_eh_revalidate_and_attach+0x28c/0x4b0 [ 1.980775] kernel: ata_eh_recover+0x6b6/0xb30 [ 1.980778] kernel: ? ahci_do_hardreset+0x180/0x180 [libahci] [ 1.980783] kernel: ? ahci_stop_engine+0xb0/0xb0 [libahci] [ 1.980787] kernel: ? ahci_do_softreset+0x290/0x290 [libahci] [ 1.980792] kernel: ? trace_event_raw_event_ata_eh_link_autopsy_qc+0xe0/0xe0 [ 1.980795] kernel: sata_pmp_eh_recover.isra.0+0x214/0x560 [ 1.980799] kernel: sata_pmp_error_handler+0x23/0x40 [ 1.980802] kernel: ahci_error_handler+0x43/0x80 [libahci] [ 1.980806] kernel: ata_scsi_port_error_handler+0x2b1/0x600 [ 1.980810] kernel: ata_scsi_error+0x9c/0xd0 [ 1.980813] kernel: scsi_error_handler+0xa1/0x180 [ 1.980817] kernel: ? scsi_unjam_host+0x1c0/0x1c0 [ 1.980820] kernel: kthread+0x12a/0x150 [ 1.980823] kernel: ? set_kthread_struct+0x50/0x50 [ 1.980826] kernel: ret_from_fork+0x22/0x30 [ 1.980831] kernel: This happens because sata_pmp_init_links() initialize link->pmp up to SATA_PMP_MAX_PORTS while em_priv is declared as 8 elements array. I can't find the maximum Enclosure Management ports specified in AHCI spec v1.3.1, but "12.2.1 LED message type" states that "Port Multiplier Information" can utilize 4 bits, which implies it can support up to 16 ports. Hence, use SATA_PMP_MAX_PORTS as EM_MAX_SLOTS to resolve the issue. BugLink: https://bugs.launchpad.net/bugs/1970074 The Linux kernel CVE team has assigned CVE-2022-50315 to this issue. Affected and fixed versions =========================== Fixed in 4.9.332 with commit f70bd4339cb68bc7e206af4c922bc0d249244403 Fixed in 4.14.298 with commit da2ea4a961d9f89ed248734e7032350c260dc3a3 Fixed in 4.19.264 with commit 67a00c299c5c143817c948fbc7de1a2fa1af38fb Fixed in 5.4.221 with commit 383b7c50f5445ff8dbbf03080905648d6980c39d Fixed in 5.10.152 with commit 303d0f761431d848dd8d7ff9fd9b8c101879cabe Fixed in 5.15.76 with commit 8fbe13de1cc7cef2564be3cbf60400b33eee023b Fixed in 6.0.6 with commit d6314d5f68764550c84d732ce901ddd3ac6b415f Fixed in 6.1 with commit 1e41e693f458eef2d5728207dbd327cd3b16580a 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-50315 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/ata/ahci.h 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/f70bd4339cb68bc7e206af4c922bc0d249244403 https://git.kernel.org/stable/c/da2ea4a961d9f89ed248734e7032350c260dc3a3 https://git.kernel.org/stable/c/67a00c299c5c143817c948fbc7de1a2fa1af38fb https://git.kernel.org/stable/c/383b7c50f5445ff8dbbf03080905648d6980c39d https://git.kernel.org/stable/c/303d0f761431d848dd8d7ff9fd9b8c101879cabe https://git.kernel.org/stable/c/8fbe13de1cc7cef2564be3cbf60400b33eee023b https://git.kernel.org/stable/c/d6314d5f68764550c84d732ce901ddd3ac6b415f https://git.kernel.org/stable/c/1e41e693f458eef2d5728207dbd327cd3b16580a