Linux SCSI subsystem development
 help / color / mirror / Atom feed
* [PATCH] scsi: lpfc: avoid post-loop iterator use in lpfc_sli_process_unsol_iocb()
@ 2026-12-05  7:44 Ziheng Wei
  2026-12-05  8:04 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Ziheng Wei @ 2026-12-05  7:44 UTC (permalink / raw)
  To: Justin Tee, Paul Ely, James E . J . Bottomley,
	Martin K . Petersen
  Cc: linux-scsi, linux-kernel, stable

In lpfc_sli_process_unsol_iocb(), if list_for_each_entry() does not find
a matching XRI on pring->iocb_continue_saveq, iocbq points to a type-
confused container_of() address derived from the list head. When
saveq->iocb.ulpStatus != IOSTAT_INTERMED_RSP, the code still executes
list_del_init(&iocbq->clist) and assigns saveq = iocbq, corrupting the
list head and dereferencing invalid memory.

Set iocbq = saveq when !found so the final-response branch unlinks and
processes saveq itself.

Found by LLM-assisted static analysis. Compile-tested on x86_64.

Fixes: 9c2face68782 ("[SCSI] lpfc 8.2.4 : Fix Unsolicited Data items")
Cc: stable@vger.kernel.org
Signed-off-by: Ziheng Wei <zihengw03@163.com>
---
 drivers/scsi/lpfc/lpfc_sli.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index 9173263c8..8bf28619d 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -3566,9 +3566,11 @@ lpfc_sli_process_unsol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
 				break;
 			}
 		}
-		if (!found)
+		if (!found) {
 			list_add_tail(&saveq->clist,
 				      &pring->iocb_continue_saveq);
+			iocbq = saveq;
+		}
 
 		if (saveq->iocb.ulpStatus != IOSTAT_INTERMED_RSP) {
 			list_del_init(&iocbq->clist);

base-commit: 97d73c8251226cf27cc6656b4c542869bb8c69fa
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-05  8:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-05  7:44 [PATCH] scsi: lpfc: avoid post-loop iterator use in lpfc_sli_process_unsol_iocb() Ziheng Wei
2026-12-05  8:04 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox