Skip to content

Commit dcaaaea

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending
Pull SCSI target fixes from Nicholas Bellinger: "The first patch is to address a long standing issue where INQUIRY vendor + model response data was not correctly padded with ASCII spaces, causing MSFT and Falconstor multipath stacks to not function with our LUNs. The second -> forth patches are additional iscsi-target regression fixes for the post >= v3.10 iser-target changes. The second and third are failure cases that have appeared during further testing, and the forth is only reproducible with malformed NOP packets. The fifth patch is a v3.11 specific regression caused by a recent optimization that showed up during WRITE I/O failure testing. I'll be sending Patch #1 and Patch #5 to Greg-KH separately for stable" * git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending: target: Fix se_cmd->state_list leak regression during WRITE failure iscsi-target: Fix potential NULL pointer in solicited NOPOUT reject iscsi-target: Fix iscsit_transport reference leak during NP thread reset iscsi-target: Fix ImmediateData=Yes failure regression in >= v3.10 target: Fix trailing ASCII space usage in INQUIRY vendor+model
2 parents f66c83d + c130480 commit dcaaaea

File tree

4 files changed

+31
-15
lines changed

4 files changed

+31
-15
lines changed

drivers/target/iscsi/iscsi_target.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,7 +1086,6 @@ int iscsit_process_scsi_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
10861086
if (cmd->reject_reason)
10871087
return 0;
10881088

1089-
target_put_sess_cmd(conn->sess->se_sess, &cmd->se_cmd);
10901089
return 1;
10911090
}
10921091
/*
@@ -1124,14 +1123,10 @@ iscsit_get_immediate_data(struct iscsi_cmd *cmd, struct iscsi_scsi_req *hdr,
11241123
*/
11251124
cmdsn_ret = iscsit_sequence_cmd(cmd->conn, cmd,
11261125
(unsigned char *)hdr, hdr->cmdsn);
1127-
if (cmdsn_ret == CMDSN_ERROR_CANNOT_RECOVER) {
1126+
if (cmdsn_ret == CMDSN_ERROR_CANNOT_RECOVER)
11281127
return -1;
1129-
} else if (cmdsn_ret == CMDSN_LOWER_THAN_EXP) {
1130-
target_put_sess_cmd(conn->sess->se_sess, &cmd->se_cmd);
1131-
return 0;
1132-
}
11331128

1134-
if (cmd->sense_reason) {
1129+
if (cmd->sense_reason || cmdsn_ret == CMDSN_LOWER_THAN_EXP) {
11351130
int rc;
11361131

11371132
rc = iscsit_dump_data_payload(cmd->conn,
@@ -1527,6 +1522,10 @@ int iscsit_setup_nop_out(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
15271522
if (hdr->itt == RESERVED_ITT && !(hdr->opcode & ISCSI_OP_IMMEDIATE)) {
15281523
pr_err("NOPOUT ITT is reserved, but Immediate Bit is"
15291524
" not set, protocol error.\n");
1525+
if (!cmd)
1526+
return iscsit_add_reject(conn, ISCSI_REASON_PROTOCOL_ERROR,
1527+
(unsigned char *)hdr);
1528+
15301529
return iscsit_reject_cmd(cmd, ISCSI_REASON_PROTOCOL_ERROR,
15311530
(unsigned char *)hdr);
15321531
}
@@ -1536,6 +1535,10 @@ int iscsit_setup_nop_out(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
15361535
" greater than MaxXmitDataSegmentLength: %u, protocol"
15371536
" error.\n", payload_length,
15381537
conn->conn_ops->MaxXmitDataSegmentLength);
1538+
if (!cmd)
1539+
return iscsit_add_reject(conn, ISCSI_REASON_PROTOCOL_ERROR,
1540+
(unsigned char *)hdr);
1541+
15391542
return iscsit_reject_cmd(cmd, ISCSI_REASON_PROTOCOL_ERROR,
15401543
(unsigned char *)hdr);
15411544
}

drivers/target/iscsi/iscsi_target_login.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,12 +1163,11 @@ static int __iscsi_target_login_thread(struct iscsi_np *np)
11631163
if (np->np_thread_state == ISCSI_NP_THREAD_RESET) {
11641164
spin_unlock_bh(&np->np_thread_lock);
11651165
complete(&np->np_restart_comp);
1166-
if (ret == -ENODEV) {
1167-
iscsit_put_transport(conn->conn_transport);
1168-
kfree(conn);
1169-
conn = NULL;
1166+
iscsit_put_transport(conn->conn_transport);
1167+
kfree(conn);
1168+
conn = NULL;
1169+
if (ret == -ENODEV)
11701170
goto out;
1171-
}
11721171
/* Get another socket */
11731172
return 1;
11741173
}

drivers/target/target_core_spc.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,12 @@ spc_emulate_inquiry_std(struct se_cmd *cmd, unsigned char *buf)
9797

9898
buf[7] = 0x2; /* CmdQue=1 */
9999

100-
snprintf(&buf[8], 8, "LIO-ORG");
101-
snprintf(&buf[16], 16, "%s", dev->t10_wwn.model);
102-
snprintf(&buf[32], 4, "%s", dev->t10_wwn.revision);
100+
memcpy(&buf[8], "LIO-ORG ", 8);
101+
memset(&buf[16], 0x20, 16);
102+
memcpy(&buf[16], dev->t10_wwn.model,
103+
min_t(size_t, strlen(dev->t10_wwn.model), 16));
104+
memcpy(&buf[32], dev->t10_wwn.revision,
105+
min_t(size_t, strlen(dev->t10_wwn.revision), 4));
103106
buf[4] = 31; /* Set additional length to 31 */
104107

105108
return 0;

drivers/target/target_core_transport.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2134,6 +2134,7 @@ static void transport_write_pending_qf(struct se_cmd *cmd)
21342134

21352135
int transport_generic_free_cmd(struct se_cmd *cmd, int wait_for_tasks)
21362136
{
2137+
unsigned long flags;
21372138
int ret = 0;
21382139

21392140
if (!(cmd->se_cmd_flags & SCF_SE_LUN_CMD)) {
@@ -2144,6 +2145,16 @@ int transport_generic_free_cmd(struct se_cmd *cmd, int wait_for_tasks)
21442145
} else {
21452146
if (wait_for_tasks)
21462147
transport_wait_for_tasks(cmd);
2148+
/*
2149+
* Handle WRITE failure case where transport_generic_new_cmd()
2150+
* has already added se_cmd to state_list, but fabric has
2151+
* failed command before I/O submission.
2152+
*/
2153+
if (cmd->state_active) {
2154+
spin_lock_irqsave(&cmd->t_state_lock, flags);
2155+
target_remove_from_state_list(cmd);
2156+
spin_unlock_irqrestore(&cmd->t_state_lock, flags);
2157+
}
21472158

21482159
if (cmd->se_lun)
21492160
transport_lun_remove_cmd(cmd);

0 commit comments

Comments
 (0)