From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 E83AF22A7F6; Sat, 12 Sep 2026 14:06:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789221969; cv=none; b=BtXoVD5r413FLN2UMuYTTRx2BUXmFBnzQKZFHethXstLq0RTtW9tz7uI8UnvNliT7/8CxynJ1ZTEMuiRsQm6lxenYx6S0T3PcSW9goOfEurkO0K2OOaeA9S3Z12GeWBw2OmfjVQtC8ryOcS43XhCryfxWMdnt7S0kyROhu9/Mfc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789221969; c=relaxed/simple; bh=qmBZkPvz84mLUS6Q06aBVTUAbpi+SChbCzDwafOjozo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ipdYS9r1RkSm9atjmW6OAab9lO8vGEQlV6dukFSkUw+Bbo43xybtmFHS6fFCf93i9Q/CVncgaKOtjziEnlCKtrmwp3+LXpEHc3hX+3HuPBl8S43b0A8EBevxSDT3Jz284waN/tzYw7riq4fG897+YU0hAv86ARBrmZtzQMyUWKk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=tYa/qB6I; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="tYa/qB6I" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A0A561F000FF; Sat, 12 Sep 2026 14:06:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789221967; bh=YUoFMM1GkZTquYRRiTUg4QBUMElYo/Aq1dP8BzsHVgA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=tYa/qB6IjouMFQTqGkwirIRbUWjjpZ3hyhi/dR7wCPn/AXm7AI1YZ6I19IAVqEyOY 2/zKu9mZsCZMG04UeAzGAFODYpdPkQsglLCA0Vs3HYkWxIN3Zy1dyiBFxt07ggAKHv z+0yTSPJJOCuhyP9ofHEmLYu0vFbDgwI2lsqSkko= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Sashiko , Nilesh Javali , "Martin K. Petersen (Oracle)" Subject: [PATCH 6.6 0484/1424] scsi: qla2xxx: Fix cs84xx use-after-free on host teardown Date: Sat, 12 Sep 2026 08:48:36 +0200 Message-ID: <20260912065618.125405333@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065607.279695368@linuxfoundation.org> References: <20260912065607.279695368@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Nilesh Javali commit 33d102102d925357c5fd172dd6672a27d74b3215 upstream. qla84xx_put_chip() drops the last reference to ha->cs84xx and frees it via __qla84xx_chip_release() without clearing ha->cs84xx. During teardown it ran before scsi_remove_host(), which is what removes the 84xx_fw_version host sysfs attribute. A concurrent read of that attribute in the window between the two calls executes qla24xx_84xx_fw_version_show(), which dereferences the freed ha->cs84xx, resulting in a use-after-free. Move qla84xx_put_chip() to after scsi_remove_host() in both qla2x00_remove_one() and qla2x00_disable_board_on_pci_error(). Once scsi_remove_host() returns, the sysfs attribute is gone and kernfs has drained any in-flight show(), so no reader can touch cs84xx; the put still runs before the host and ha are freed. Fixes: fe1b806f4f71 ("[SCSI] qla2xxx: Refactor shutdown code so some functionality can be reused.") Cc: stable@vger.kernel.org Reported-by: Sashiko Signed-off-by: Nilesh Javali Link: https://patch.msgid.link/20260730155838.2119230-7-njavali@marvell.com Signed-off-by: Martin K. Petersen (Oracle) Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/qla2xxx/qla_os.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -3927,8 +3927,6 @@ qla2x00_remove_one(struct pci_dev *pdev) qla2x00_dfs_remove(base_vha); - qla84xx_put_chip(base_vha); - /* Disable timer */ if (base_vha->timer_active) qla2x00_stop_timer(base_vha); @@ -3953,6 +3951,8 @@ qla2x00_remove_one(struct pci_dev *pdev) scsi_remove_host(base_vha->host); + qla84xx_put_chip(base_vha); + qla2x00_free_device(base_vha); qla2x00_clear_drv_active(ha); @@ -6824,8 +6824,6 @@ qla2x00_disable_board_on_pci_error(struc qla2x00_dfs_remove(base_vha); - qla84xx_put_chip(base_vha); - if (base_vha->timer_active) qla2x00_stop_timer(base_vha); @@ -6843,6 +6841,8 @@ qla2x00_disable_board_on_pci_error(struc scsi_remove_host(base_vha->host); + qla84xx_put_chip(base_vha); + base_vha->flags.init_done = 0; qla25xx_delete_queues(base_vha); qla2x00_free_fcports(base_vha);