Skip to contentSkip to conversation

iscsi-target: graceful disconnect on invalid mapping to iovec

PATCH New Imran Haider 1 participant 1 message May 8, 2016

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

PATCH 1/1 iscsi-target: graceful disconnect on invalid mapping to iovec

Ensures the first page entry is within bounds. A failed check would terminate the iSCSI connection instead of causing a NULL-dereference.

This violation seems to happen with certain iSCSI commands where the computed CDB length is zero but the expected transfer length is non-zero. The real problem is probably on the iSCSI initiator side since there is a discrepancy between the iSCSI header and the encapsulated CDB Opcode.

---
 drivers/target/iscsi/iscsi_target.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/target/iscsi/iscsi_target.c +8 -1
index 961202f..963e9a7 100644
@@ -737,7 +737,14 @@ static int iscsit_map_iovec(
 	/*
 	 * We know each entry in t_data_sg contains a page.
 	 */
-	sg = &cmd->se_cmd.t_data_sg[data_offset / PAGE_SIZE];
+	u32 ent = data_offset / PAGE_SIZE;
+
+	if (ent >= cmd->se_cmd.t_data_nents) {
+		pr_err("Initial page entry out-of-bounds\n");
+		return -1;
+	}
+
+	sg = &cmd->se_cmd.t_data_sg[ent];
 	page_off = (data_offset % PAGE_SIZE);
 
 	cmd->first_data_sg = sg;
Signature · 1 line
2.8.0