linux/drivers/scsi/lpfc
John Evans 367cb5ffd8 scsi: lpfc: Fix buffer free/clear order in deferred receive path
commit 9dba9a45c3 upstream.

Fix a use-after-free window by correcting the buffer release sequence in
the deferred receive path. The code freed the RQ buffer first and only
then cleared the context pointer under the lock. Concurrent paths (e.g.,
ABTS and the repost path) also inspect and release the same pointer under
the lock, so the old order could lead to double-free/UAF.

Note that the repost path already uses the correct pattern: detach the
pointer under the lock, then free it after dropping the lock. The
deferred path should do the same.

Fixes: 472e146d1c ("scsi: lpfc: Correct upcalling nvmet_fc transport during io done downcall")
Cc: stable@vger.kernel.org
Signed-off-by: John Evans <evans1210144@gmail.com>
Link: https://lore.kernel.org/r/20250828044008.743-1-evans1210144@gmail.com
Reviewed-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2025-09-09 18:58:18 +02:00
..
lpfc.h scsi: lpfc: Fix unsolicited FLOGI kref imbalance when in direct attached topology 2024-08-02 21:48:05 -04:00
lpfc_attr.c Merge patch series "Update lpfc to revision 14.4.0.3" 2024-07-04 23:25:40 -04:00
lpfc_attr.h scsi: lpfc: Revise copyright for new company language 2018-07-10 22:15:09 -04:00
lpfc_bsg.c scsi: lpfc: Change lpfc_nodelist nlp_flag member into a bitmask 2025-07-10 16:04:59 +02:00
lpfc_bsg.h scsi: lpfc: Copyright updates for 14.2.0.5 patches 2022-07-07 17:21:44 -04:00
lpfc_compat.h scsi: lpfc: Revise copyright for new company language 2018-07-10 22:15:09 -04:00
lpfc_crtn.h scsi: lpfc: Remove NLP_RELEASE_RPI flag from nodelist structure 2025-07-10 16:04:59 +02:00
lpfc_ct.c scsi: lpfc: Change lpfc_nodelist nlp_flag member into a bitmask 2025-07-10 16:04:59 +02:00
lpfc_debugfs.c scsi: lpfc: Remove redundant assignment to avoid memory leak 2025-08-20 18:30:50 +02:00
lpfc_debugfs.h scsi: lpfc: Copyright updates for 14.2.0.6 patches 2022-08-31 23:39:58 -04:00
lpfc_disc.h scsi: lpfc: Change lpfc_nodelist nlp_flag member into a bitmask 2025-07-10 16:04:59 +02:00
lpfc_els.c scsi: lpfc: Change lpfc_nodelist nlp_flag member into a bitmask 2025-07-10 16:04:59 +02:00
lpfc_hbadisc.c scsi: lpfc: Ensure HBA_SETUP flag is used only for SLI4 in dev_loss_tmo_callbk 2025-08-20 18:30:43 +02:00
lpfc_hw.h scsi: lpfc: Support loopback tests with VMID enabled 2024-09-12 21:21:19 -04:00
lpfc_hw4.h scsi: lpfc: Restrict support for 32 byte CDBs to specific HBAs 2024-09-12 21:21:19 -04:00
lpfc_ids.h scsi: lpfc: Copyright updates for 14.2.0.5 patches 2022-07-07 17:21:44 -04:00
lpfc_init.c scsi: lpfc: Change lpfc_nodelist nlp_flag member into a bitmask 2025-07-10 16:04:59 +02:00
lpfc_logmsg.h scsi: lpfc: Introduce LOG_NODE_VERBOSE messaging flag 2023-10-13 16:58:27 -04:00
lpfc_mbox.c scsi: lpfc: Define types in a union for generic void *context3 ptr 2024-03-10 18:56:44 -04:00
lpfc_mem.c scsi: lpfc: Copyright updates for 14.2.0.16 patches 2023-11-15 09:52:58 -05:00
lpfc_nl.h scsi: lpfc: Revise copyright for new company language 2018-07-10 22:15:09 -04:00
lpfc_nportdisc.c scsi: lpfc: Change lpfc_nodelist nlp_flag member into a bitmask 2025-07-10 16:04:59 +02:00
lpfc_nvme.c scsi: lpfc: Change lpfc_nodelist nlp_flag member into a bitmask 2025-07-10 16:04:59 +02:00
lpfc_nvme.h scsi: lpfc: Copyright updates for 14.2.0.0 patches 2022-03-15 13:51:50 -04:00
lpfc_nvmet.c scsi: lpfc: Fix buffer free/clear order in deferred receive path 2025-09-09 18:58:18 +02:00
lpfc_scsi.c scsi: lpfc: Check for hdwq null ptr when cleaning up lpfc_vport structure 2025-08-20 18:30:44 +02:00
lpfc_scsi.h scsi: lpfc: Copyright updates for 14.4.0.2 patches 2024-05-06 21:53:58 -04:00
lpfc_sli.c scsi: lpfc: Restore clearing of NLP_UNREG_INP in ndlp->nlp_flag 2025-07-10 16:05:05 +02:00
lpfc_sli.h scsi: lpfc: Copyright updates for 14.4.0.1 patches 2024-03-10 18:56:44 -04:00
lpfc_sli4.h scsi: lpfc: Copyright updates for 14.4.0.1 patches 2024-03-10 18:56:44 -04:00
lpfc_version.h scsi: lpfc: Update lpfc version to 14.4.0.5 2024-09-12 21:21:19 -04:00
lpfc_vmid.c scsi: lpfc: Copyright updates for 14.4.0.4 patches 2024-08-02 21:48:06 -04:00
lpfc_vport.c scsi: lpfc: Change lpfc_nodelist nlp_flag member into a bitmask 2025-07-10 16:04:59 +02:00
lpfc_vport.h scsi: lpfc: Copyright updates for 14.2.0.6 patches 2022-08-31 23:39:58 -04:00
Makefile scsi: lpfc: Commonize VMID code location 2022-05-19 20:24:56 -04:00