From mboxrd@z Thu Jan 1 00:00:00 1970 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 B340D1A9B2B for ; Wed, 26 Feb 2025 01:58:00 +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=1740535080; cv=none; b=TMQcBx1m/kmzzLqGHnYUOb8cH5YFsO/dQ2mB78kwgcDhW+xWHjafoo12JdWEv0oywa9Ii+ELqH05IAiuapABGo5hT9lJBXFgXi+oIYoQi2+MHrDFggzUAYr+mzoL3MPxSWJk+dkTREYCXmgj4QQFX1oDcQWCMlM8BCCLBUB9aqU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740535080; c=relaxed/simple; bh=30g3ZH+nRm3YHuL600cUhrK9jCvoHXwbjRe4LZtGkoo=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=D8U9JaXy3gMG6V5iw3oSjfpsx3EHLmHKasAu13pO8DDa3udEVuyP4QTKfa6IrW4Gwo/dLhn0/7x91SoixG1ngmy4A/XVrYFuMn+hgaNe/ZqEf8aSLJ8XaRmIM+cP6OEgb7V3CcB9nqhJEhpMZZVkPXoNhrbgE3FB+5gd4n4CQ6g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=gBIboWqO; 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="gBIboWqO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 87312C4CEE6; Wed, 26 Feb 2025 01:58:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1740535080; bh=30g3ZH+nRm3YHuL600cUhrK9jCvoHXwbjRe4LZtGkoo=; h=From:To:Cc:Subject:Date:Reply-to:From; b=gBIboWqO+xQb/+tCilV+F5wJCd+ed7dfooHT+2xMdYuMHi+ErfXlmYk+DSgraJKK5 9ViOFet3tkGZ26GJ2n3HGJaNsZekEY0r1FVvoAKylsLJp87i/iFpzpR6txzLFVGpNd kyL9O/mcZsON8Qxbaf62fhoPzrizmsLQh+Rc+xNo= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2022-49082: scsi: mpt3sas: Fix use after free in _scsih_expander_node_remove() Date: Wed, 26 Feb 2025 02:54:47 +0100 Message-ID: <2025022657-CVE-2022-49082-676c@gregkh> X-Mailer: git-send-email 2.48.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=4760; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=30g3ZH+nRm3YHuL600cUhrK9jCvoHXwbjRe4LZtGkoo=; b=owGbwMvMwCRo6H6F97bub03G02pJDOn7SkxvvXX6K8Qo7iTNVrnkZ7WAv0Eju1c561rRiu2Sc 37+2766I5aFQZCJQVZMkeXLNp6j+ysOKXoZ2p6GmcPKBDKEgYtTACbCuYxhftjabrMr/G9n1J5c 2FDjucffs7orh2HB6osVKvsP3Js7a9JVif3/bPr/zjoqAgA= 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: scsi: mpt3sas: Fix use after free in _scsih_expander_node_remove() The function mpt3sas_transport_port_remove() called in _scsih_expander_node_remove() frees the port field of the sas_expander structure, leading to the following use-after-free splat from KASAN when the ioc_info() call following that function is executed (e.g. when doing rmmod of the driver module): [ 3479.371167] ================================================================== [ 3479.378496] BUG: KASAN: use-after-free in _scsih_expander_node_remove+0x710/0x750 [mpt3sas] [ 3479.386936] Read of size 1 at addr ffff8881c037691c by task rmmod/1531 [ 3479.393524] [ 3479.395035] CPU: 18 PID: 1531 Comm: rmmod Not tainted 5.17.0-rc8+ #1436 [ 3479.401712] Hardware name: Supermicro Super Server/H12SSL-NT, BIOS 2.1 06/02/2021 [ 3479.409263] Call Trace: [ 3479.411743] [ 3479.413875] dump_stack_lvl+0x45/0x59 [ 3479.417582] print_address_description.constprop.0+0x1f/0x120 [ 3479.423389] ? _scsih_expander_node_remove+0x710/0x750 [mpt3sas] [ 3479.429469] kasan_report.cold+0x83/0xdf [ 3479.433438] ? _scsih_expander_node_remove+0x710/0x750 [mpt3sas] [ 3479.439514] _scsih_expander_node_remove+0x710/0x750 [mpt3sas] [ 3479.445411] ? _raw_spin_unlock_irqrestore+0x2d/0x40 [ 3479.452032] scsih_remove+0x525/0xc90 [mpt3sas] [ 3479.458212] ? mpt3sas_expander_remove+0x1d0/0x1d0 [mpt3sas] [ 3479.465529] ? down_write+0xde/0x150 [ 3479.470746] ? up_write+0x14d/0x460 [ 3479.475840] ? kernfs_find_ns+0x137/0x310 [ 3479.481438] pci_device_remove+0x65/0x110 [ 3479.487013] __device_release_driver+0x316/0x680 [ 3479.493180] driver_detach+0x1ec/0x2d0 [ 3479.498499] bus_remove_driver+0xe7/0x2d0 [ 3479.504081] pci_unregister_driver+0x26/0x250 [ 3479.510033] _mpt3sas_exit+0x2b/0x6cf [mpt3sas] [ 3479.516144] __x64_sys_delete_module+0x2fd/0x510 [ 3479.522315] ? free_module+0xaa0/0xaa0 [ 3479.527593] ? __cond_resched+0x1c/0x90 [ 3479.532951] ? lockdep_hardirqs_on_prepare+0x273/0x3e0 [ 3479.539607] ? syscall_enter_from_user_mode+0x21/0x70 [ 3479.546161] ? trace_hardirqs_on+0x1c/0x110 [ 3479.551828] do_syscall_64+0x35/0x80 [ 3479.556884] entry_SYSCALL_64_after_hwframe+0x44/0xae [ 3479.563402] RIP: 0033:0x7f1fc482483b ... [ 3479.943087] ================================================================== Fix this by introducing the local variable port_id to store the port ID value before executing mpt3sas_transport_port_remove(). This local variable is then used in the call to ioc_info() instead of dereferencing the freed port structure. The Linux kernel CVE team has assigned CVE-2022-49082 to this issue. Affected and fixed versions =========================== Issue introduced in 5.11 with commit 7d310f241001e090cf1ec0f3ae836b38d8c6ebec and fixed in 5.15.34 with commit 25c1353dca74ad7cf3fd7ce258fe7c957a147d5e Issue introduced in 5.11 with commit 7d310f241001e090cf1ec0f3ae836b38d8c6ebec and fixed in 5.16.20 with commit 17d66b1c92bcb41e72271ec60069d3684aaa1c9c Issue introduced in 5.11 with commit 7d310f241001e090cf1ec0f3ae836b38d8c6ebec and fixed in 5.17.3 with commit 1bb8a7fc64d63ec818e367e1b37676ea2ef2d20c Issue introduced in 5.11 with commit 7d310f241001e090cf1ec0f3ae836b38d8c6ebec and fixed in 5.18 with commit 87d663d40801dffc99a5ad3b0188ad3e2b4d1557 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-49082 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/scsi/mpt3sas/mpt3sas_scsih.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/25c1353dca74ad7cf3fd7ce258fe7c957a147d5e https://git.kernel.org/stable/c/17d66b1c92bcb41e72271ec60069d3684aaa1c9c https://git.kernel.org/stable/c/1bb8a7fc64d63ec818e367e1b37676ea2ef2d20c https://git.kernel.org/stable/c/87d663d40801dffc99a5ad3b0188ad3e2b4d1557