Skip to contentSkip to conversation

scsi: qla2xxx: avoid crash in qlt_handle_abts_completion() if mcmd == NULL

PATCH In review Thomas Abraham 4 participants 4 messages Nov 4, 2019 – Nov 20, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: qla2xxx: avoid crash in qlt_handle_abts_completion() if mcmd == NULL

qlt_ctio_to_cmd() will return a NULL mcmd if h == QLA_TGT_SKIP_HANDLE. If the error subcodes don't match the exact codes checked a crash will occur when calling free_mcmd on the null mcmd

---
 drivers/scsi/qla2xxx/qla_target.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/scsi/qla2xxx/qla_target.c +2 -1
index a06e56224a55..611ab224662f 100644
@@ -5732,7 +5732,8 @@ static void qlt_handle_abts_completion(struct scsi_qla_host *vha,
 			    vha->vp_idx, entry->compl_status,
 			    entry->error_subcode1,
 			    entry->error_subcode2);
-			ha->tgt.tgt_ops->free_mcmd(mcmd);
+			if (mcmd)
+				ha->tgt.tgt_ops->free_mcmd(mcmd);
 		}
 	} else if (mcmd) {
 		ha->tgt.tgt_ops->free_mcmd(mcmd);
Signature · 1 line
2.16.4
#1 lore raw

Hi Thomas,

The fix for the issue was sent earlier:
https://patchwork.kernel.org/patch/11141981/

It's not important to me what fixes goes into tree but I'd like to keep the commit message because it covers how the situation arises. Also, the cover letter of the patch series points out another issue not covered in either of the fixes (lack of explicit LOGO instead of BA_RJT).

Thank you,
Roman

Quoted 26 lines · Thomas Abraham

qlt_ctio_to_cmd() will return a NULL mcmd if h == QLA_TGT_SKIP_HANDLE. If the error subcodes don't match the exact codes checked a crash will occur when calling free_mcmd on the null mcmd

---
 drivers/scsi/qla2xxx/qla_target.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/scsi/qla2xxx/qla_target.c +2 -1
index a06e56224a55..611ab224662f 100644
@@ -5732,7 +5732,8 @@ static void qlt_handle_abts_completion(struct scsi_qla_host *vha,
 			    vha->vp_idx, entry->compl_status,
 			    entry->error_subcode1,
 			    entry->error_subcode2);
-			ha->tgt.tgt_ops->free_mcmd(mcmd);
+			if (mcmd)
+				ha->tgt.tgt_ops->free_mcmd(mcmd);
 		}
 	} else if (mcmd) {
 		ha->tgt.tgt_ops->free_mcmd(mcmd);
Signature · 1 line
2.16.4
#2 lore raw
In reply to Thomas Abraham

Himanshu: Ping.

Also see: https://patchwork.kernel.org/patch/11141981/

Quoted 23 lines

qlt_ctio_to_cmd() will return a NULL mcmd if h == QLA_TGT_SKIP_HANDLE. If the error subcodes don't match the exact codes checked a crash will occur when calling free_mcmd on the null mcmd

---
 drivers/scsi/qla2xxx/qla_target.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/scsi/qla2xxx/qla_target.c +2 -1
index a06e56224a55..611ab224662f 100644
@@ -5732,7 +5732,8 @@ static void qlt_handle_abts_completion(struct scsi_qla_host *vha,
 			    vha->vp_idx, entry->compl_status,
 			    entry->error_subcode1,
 			    entry->error_subcode2);
-			ha->tgt.tgt_ops->free_mcmd(mcmd);
+			if (mcmd)
+				ha->tgt.tgt_ops->free_mcmd(mcmd);
 		}
 	} else if (mcmd) {
 		ha->tgt.tgt_ops->free_mcmd(mcmd);
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering
Reviewed-by on v1 1/1
#3 lore raw
In reply to Thomas Abraham
Quoted 15 lines · Thomas Abraham

qlt_ctio_to_cmd() will return a NULL mcmd if h == QLA_TGT_SKIP_HANDLE. If the error subcodes don't match the exact codes checked a crash will occur when calling free_mcmd on the null mcmd

---
 drivers/scsi/qla2xxx/qla_target.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/scsi/qla2xxx/qla_target.c +0 -0
index a06e56224a55..611ab224662f 100644

drivers/scsi/qla2xxx/qla_target.c static void qlt_handle_abts_completion(struct scsi_qla_host *vha, · line 5739

Quoted 9 lines
drivers/scsi/qla2xxx/qla_target.c +2 -1
@@ -5732,7 +5732,8 @@ static void qlt_handle_abts_completion(struct scsi_qla_host *vha,
 			    vha->vp_idx, entry->compl_status,
 			    entry->error_subcode1,
 			    entry->error_subcode2);
-			ha->tgt.tgt_ops->free_mcmd(mcmd);
+			if (mcmd)
+				ha->tgt.tgt_ops->free_mcmd(mcmd);
 		}
 	} else if (mcmd) {
 		ha->tgt.tgt_ops->free_mcmd(mcmd);