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 492521AA791 for ; Wed, 26 Feb 2025 01:59:08 +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=1740535148; cv=none; b=SifkIa3koCIEBCBEOxo/oqDR2Fh/kIJeO/SJypzlBgTIRh8zv9pPle1l3Eu9uVFX7TaY/3hej5T0lnuRsmGip1nYku9dytehyVzlggnz7ILQjDPiw8CfRSZ+45srABJ6ZL/iFVR51Wn77gzaR9hKMTA9rc1KMJCyUZ5zoHMc1fA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740535148; c=relaxed/simple; bh=aDQ+pyWS2qdGeBYjphw9glfPnxo1QsPy0M6pAPneDxY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=J3jPWa3HxaaWBb9ZJIbB/6IzPiBRc2w6miaZu1u6kAVL5pcIBVVRfpCIinyVcwjjyZdSX7Pkgjq0EKvR6rMnzK8GnbFucPV7A4ctY1P+qtsDobzshPQnZM1TGK0kSlimITcmQZ6Jf9RmOp4E325r8k21Yam77hfP7efO7atbt0U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Fqi/IyIj; 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="Fqi/IyIj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1F396C4CEDD; Wed, 26 Feb 2025 01:59:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1740535148; bh=aDQ+pyWS2qdGeBYjphw9glfPnxo1QsPy0M6pAPneDxY=; h=From:To:Cc:Subject:Date:Reply-to:From; b=Fqi/IyIjw2Y5/PfDCX1V++QU0bdKdbHyKTTzVGgfMcrX257ceivyiY0FY0injIVNl lg8PJaf75rNYgXGy0UbjkzNW5ZVeT7s0Q/YpN8pJppYxsH6oj76vXa5u2omUCDbZa2 vlWrMCfXsRzNaFxWYrh8uRpPNlpD4poWSZX3tZfs= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2022-49159: scsi: qla2xxx: Implement ref count for SRB Date: Wed, 26 Feb 2025 02:56:04 +0100 Message-ID: <2025022610-CVE-2022-49159-58f3@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=3968; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=aDQ+pyWS2qdGeBYjphw9glfPnxo1QsPy0M6pAPneDxY=; b=owGbwMvMwCRo6H6F97bub03G02pJDOn7SpyyPeYLno9bx3yh/hlbRdyvs69vfZ13TPCT9CrXg vgNktWsHbEsDIJMDLJiiixftvEc3V9xSNHL0PY0zBxWJpAhDFycAjARoRsM8z2mS+fZWHA6+tmb 3TaKrrp/46LeTYYFe3tzn8hPas6an/dClVGda84B+7/1AA== 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: qla2xxx: Implement ref count for SRB The timeout handler and the done function are racing. When qla2x00_async_iocb_timeout() starts to run it can be preempted by the normal response path (via the firmware?). qla24xx_async_gpsc_sp_done() releases the SRB unconditionally. When scheduling back to qla2x00_async_iocb_timeout() qla24xx_async_abort_cmd() will access an freed sp->qpair pointer: qla2xxx [0000:83:00.0]-2871:0: Async-gpsc timeout - hdl=63d portid=234500 50:06:0e:80:08:77:b6:21. qla2xxx [0000:83:00.0]-2853:0: Async done-gpsc res 0, WWPN 50:06:0e:80:08:77:b6:21 qla2xxx [0000:83:00.0]-2854:0: Async-gpsc OUT WWPN 20:45:00:27:f8:75:33:00 speeds=2c00 speed=0400. qla2xxx [0000:83:00.0]-28d8:0: qla24xx_handle_gpsc_event 50:06:0e:80:08:77:b6:21 DS 7 LS 6 rc 0 login 1|1 rscn 1|0 lid 5 BUG: unable to handle kernel NULL pointer dereference at 0000000000000004 IP: qla24xx_async_abort_cmd+0x1b/0x1c0 [qla2xxx] Obvious solution to this is to introduce a reference counter. One reference is taken for the normal code path (the 'good' case) and one for the timeout path. As we always race between the normal good case and the timeout/abort handler we need to serialize it. Also we cannot assume any order between the handlers. Since this is slow path we can use proper synchronization via locks. When we are able to cancel a timer (del_timer returns 1) we know there can't be any error handling in progress because the timeout handler hasn't expired yet, thus we can safely decrement the refcounter by one. If we are not able to cancel the timer, we know an abort handler is running. We have to make sure we call sp->done() in the abort handlers before calling kref_put(). The Linux kernel CVE team has assigned CVE-2022-49159 to this issue. Affected and fixed versions =========================== Fixed in 5.15.33 with commit e17111dd2fda81c35f309b1e5b6ab35809a375e7 Fixed in 5.16.19 with commit e140723f78ff418c8df7d990e102e07b65c87d4a Fixed in 5.17.2 with commit ceda7f794f3dfe272491e93e3e93049f8be5f07b Fixed in 5.18 with commit 31e6cdbe0eae37badceb5e0d4f06cf051432fd77 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-49159 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/qla2xxx/qla_bsg.c drivers/scsi/qla2xxx/qla_def.h drivers/scsi/qla2xxx/qla_edif.c drivers/scsi/qla2xxx/qla_gbl.h drivers/scsi/qla2xxx/qla_gs.c drivers/scsi/qla2xxx/qla_init.c drivers/scsi/qla2xxx/qla_inline.h drivers/scsi/qla2xxx/qla_iocb.c drivers/scsi/qla2xxx/qla_mbx.c drivers/scsi/qla2xxx/qla_mid.c drivers/scsi/qla2xxx/qla_mr.c drivers/scsi/qla2xxx/qla_os.c drivers/scsi/qla2xxx/qla_target.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/e17111dd2fda81c35f309b1e5b6ab35809a375e7 https://git.kernel.org/stable/c/e140723f78ff418c8df7d990e102e07b65c87d4a https://git.kernel.org/stable/c/ceda7f794f3dfe272491e93e3e93049f8be5f07b https://git.kernel.org/stable/c/31e6cdbe0eae37badceb5e0d4f06cf051432fd77