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 44D1B3264F4; Sat, 12 Sep 2026 15:54:56 +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=1789228497; cv=none; b=LcStZra2K4Ju4oDxP66sdAvgdk9L0L5afJrrmbwpHiET1FqL9dF7cCS6LfD8UpXbwqKLbvLfOg3JC0iqN/XQOMX+H46eFTRO+HymoBs1w0IZRYJEO9oeZrEVaUUeQNf2tY3JRdX+rXtWxZtHYjqVR+oPrWfeqM2xmBAJnEljIiQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789228497; c=relaxed/simple; bh=7cRAFvxlSSipQITfC7mknfgm6knO3YgL/JVZxm4Gw/o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Uw9vqHPiJ6Tq5MMuPO7h/MoGgDR+/y0mdSw2BHbn5FmwpxMqXjtqaWmq+QxJ+yuRHt3fHOmycLZ17fMc7Mua8UCPhrFnHRJIkP8831WYaKRnDPjuSlcsMZ8KqSGeF2S3aHIzVB3RBzk239V+2uVvyYEJs3nomiJscOCyL2BwfX8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Ar92fC8u; 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="Ar92fC8u" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F2E8E1F000FF; Sat, 12 Sep 2026 15:54:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789228496; bh=BQcKKdYkYtJyXknFDz0Hm0bARA8Ax2mZU7gj2FloCMU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Ar92fC8uN5OpvF+g5Jm9mmtPsOh5jFz7gQQaDTLpveHeVMQkNF7pmxIMQKDNaPgES Gc/g40k/sZ8muAyQjE6CGpGjDgkshMq2rTErZQt7KXFAPZBuNT6di316MsV/hq5jNp PGgl/fWYx4xkWp/PxiIi48GUIN1CrwfpWWm2g6/E= 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.1 0397/1191] scsi: qla2xxx: Fix cs84xx use-after-free on host teardown Date: Sat, 12 Sep 2026 08:52:05 +0200 Message-ID: <20260912065557.155111404@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065548.086904252@linuxfoundation.org> References: <20260912065548.086904252@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.1-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 @@ -3926,8 +3926,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); @@ -3952,6 +3950,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); @@ -6800,8 +6800,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); @@ -6819,6 +6817,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);