Merge git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending

Pull SCSI target fixes from Nicholas Bellinger:
"Here are the remaining fixes for v3.15.

This series includes:

- iser-target fix for ImmediateData exception reference count bug
(Sagi + nab)
- iscsi-target fix for MC/S login + potential iser-target MRDSL
buffer overrun (Santosh + Roland)
- iser-target fix for v3.15-rc multi network portal shutdown
regression (nab)
- target fix for allowing READ_CAPCITY during ALUA Standby access
state (Chris + nab)
- target fix for NULL pointer dereference of alua_access_state for
un-configured devices (Chris + nab)"

* git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending:
target: Fix alua_access_state attribute OOPs for un-configured devices
target: Allow READ_CAPACITY opcode in ALUA Standby access state
iser-target: Fix multi network portal shutdown regression
iscsi-target: Fix wrong buffer / buffer overrun in iscsi_change_param_value()
iser-target: Add missing target_put_sess_cmd for ImmedateData failure

+2
drivers/infiniband/ulp/isert/ib_isert.c
··· 1210 1210 1211 1211 if (!rc && dump_payload == false && unsol_data) 1212 1212 iscsit_set_unsoliticed_dataout(cmd); 1213 + else if (dump_payload && imm_data) 1214 + target_put_sess_cmd(conn->sess->se_sess, &cmd->se_cmd); 1213 1215 1214 1216 return 0; 1215 1217 }
+1
drivers/target/iscsi/iscsi_target.c
··· 460 460 spin_lock_bh(&np->np_thread_lock); 461 461 np->np_exports--; 462 462 if (np->np_exports) { 463 + np->enabled = true; 463 464 spin_unlock_bh(&np->np_thread_lock); 464 465 return 0; 465 466 }
+31 -39
drivers/target/iscsi/iscsi_target_login.c
··· 249 249 mutex_unlock(&auth_id_lock); 250 250 } 251 251 252 + static __printf(2, 3) int iscsi_change_param_sprintf( 253 + struct iscsi_conn *conn, 254 + const char *fmt, ...) 255 + { 256 + va_list args; 257 + unsigned char buf[64]; 258 + 259 + memset(buf, 0, sizeof buf); 260 + 261 + va_start(args, fmt); 262 + vsnprintf(buf, sizeof buf, fmt, args); 263 + va_end(args); 264 + 265 + if (iscsi_change_param_value(buf, conn->param_list, 0) < 0) { 266 + iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR, 267 + ISCSI_LOGIN_STATUS_NO_RESOURCES); 268 + return -1; 269 + } 270 + 271 + return 0; 272 + } 273 + 252 274 /* 253 275 * This is the leading connection of a new session, 254 276 * or session reinstatement. ··· 361 339 { 362 340 struct iscsi_node_attrib *na; 363 341 struct iscsi_session *sess = conn->sess; 364 - unsigned char buf[32]; 365 342 bool iser = false; 366 343 367 344 sess->tpg = conn->tpg; ··· 401 380 * 402 381 * In our case, we have already located the struct iscsi_tiqn at this point. 403 382 */ 404 - memset(buf, 0, 32); 405 - sprintf(buf, "TargetPortalGroupTag=%hu", sess->tpg->tpgt); 406 - if (iscsi_change_param_value(buf, conn->param_list, 0) < 0) { 407 - iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR, 408 - ISCSI_LOGIN_STATUS_NO_RESOURCES); 383 + if (iscsi_change_param_sprintf(conn, "TargetPortalGroupTag=%hu", sess->tpg->tpgt)) 409 384 return -1; 410 - } 411 385 412 386 /* 413 387 * Workaround for Initiators that have broken connection recovery logic. 414 388 * 415 389 * "We would really like to get rid of this." Linux-iSCSI.org team 416 390 */ 417 - memset(buf, 0, 32); 418 - sprintf(buf, "ErrorRecoveryLevel=%d", na->default_erl); 419 - if (iscsi_change_param_value(buf, conn->param_list, 0) < 0) { 420 - iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR, 421 - ISCSI_LOGIN_STATUS_NO_RESOURCES); 391 + if (iscsi_change_param_sprintf(conn, "ErrorRecoveryLevel=%d", na->default_erl)) 422 392 return -1; 423 - } 424 393 425 394 if (iscsi_login_disable_FIM_keys(conn->param_list, conn) < 0) 426 395 return -1; ··· 422 411 unsigned long mrdsl, off; 423 412 int rc; 424 413 425 - sprintf(buf, "RDMAExtensions=Yes"); 426 - if (iscsi_change_param_value(buf, conn->param_list, 0) < 0) { 427 - iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR, 428 - ISCSI_LOGIN_STATUS_NO_RESOURCES); 414 + if (iscsi_change_param_sprintf(conn, "RDMAExtensions=Yes")) 429 415 return -1; 430 - } 416 + 431 417 /* 432 418 * Make MaxRecvDataSegmentLength PAGE_SIZE aligned for 433 419 * Immediate Data + Unsolicitied Data-OUT if necessary.. ··· 454 446 pr_warn("Aligning ISER MaxRecvDataSegmentLength: %lu down" 455 447 " to PAGE_SIZE\n", mrdsl); 456 448 457 - sprintf(buf, "MaxRecvDataSegmentLength=%lu\n", mrdsl); 458 - if (iscsi_change_param_value(buf, conn->param_list, 0) < 0) { 459 - iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR, 460 - ISCSI_LOGIN_STATUS_NO_RESOURCES); 449 + if (iscsi_change_param_sprintf(conn, "MaxRecvDataSegmentLength=%lu\n", mrdsl)) 461 450 return -1; 462 - } 463 451 /* 464 452 * ISER currently requires that ImmediateData + Unsolicited 465 453 * Data be disabled when protection / signature MRs are enabled. ··· 465 461 (TARGET_PROT_DOUT_STRIP | TARGET_PROT_DOUT_PASS | 466 462 TARGET_PROT_DOUT_INSERT)) { 467 463 468 - sprintf(buf, "ImmediateData=No"); 469 - if (iscsi_change_param_value(buf, conn->param_list, 0) < 0) { 470 - iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR, 471 - ISCSI_LOGIN_STATUS_NO_RESOURCES); 464 + if (iscsi_change_param_sprintf(conn, "ImmediateData=No")) 472 465 return -1; 473 - } 474 466 475 - sprintf(buf, "InitialR2T=Yes"); 476 - if (iscsi_change_param_value(buf, conn->param_list, 0) < 0) { 477 - iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR, 478 - ISCSI_LOGIN_STATUS_NO_RESOURCES); 467 + if (iscsi_change_param_sprintf(conn, "InitialR2T=Yes")) 479 468 return -1; 480 - } 469 + 481 470 pr_debug("Forcing ImmediateData=No + InitialR2T=Yes for" 482 471 " T10-PI enabled ISER session\n"); 483 472 } ··· 615 618 * 616 619 * In our case, we have already located the struct iscsi_tiqn at this point. 617 620 */ 618 - memset(buf, 0, 32); 619 - sprintf(buf, "TargetPortalGroupTag=%hu", sess->tpg->tpgt); 620 - if (iscsi_change_param_value(buf, conn->param_list, 0) < 0) { 621 - iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR, 622 - ISCSI_LOGIN_STATUS_NO_RESOURCES); 621 + if (iscsi_change_param_sprintf(conn, "TargetPortalGroupTag=%hu", sess->tpg->tpgt)) 623 622 return -1; 624 - } 625 623 626 624 return iscsi_login_disable_FIM_keys(conn->param_list, conn); 627 625 }
+2 -1
drivers/target/iscsi/iscsi_target_tpg.c
··· 184 184 return; 185 185 } 186 186 187 - tpg_np->tpg_np->enabled = false; 187 + if (shutdown) 188 + tpg_np->tpg_np->enabled = false; 188 189 iscsit_reset_np_thread(tpg_np->tpg_np, tpg_np, tpg, shutdown); 189 190 } 190 191
+9
drivers/target/target_core_alua.c
··· 576 576 case REPORT_LUNS: 577 577 case RECEIVE_DIAGNOSTIC: 578 578 case SEND_DIAGNOSTIC: 579 + case READ_CAPACITY: 579 580 return 0; 581 + case SERVICE_ACTION_IN: 582 + switch (cdb[1] & 0x1f) { 583 + case SAI_READ_CAPACITY_16: 584 + return 0; 585 + default: 586 + set_ascq(cmd, ASCQ_04H_ALUA_TG_PT_STANDBY); 587 + return 1; 588 + } 580 589 case MAINTENANCE_IN: 581 590 switch (cdb[1] & 0x1f) { 582 591 case MI_REPORT_TARGET_PGS:
+5
drivers/target/target_core_configfs.c
··· 2227 2227 " tg_pt_gp ID: %hu\n", tg_pt_gp->tg_pt_gp_valid_id); 2228 2228 return -EINVAL; 2229 2229 } 2230 + if (!(dev->dev_flags & DF_CONFIGURED)) { 2231 + pr_err("Unable to set alua_access_state while device is" 2232 + " not configured\n"); 2233 + return -ENODEV; 2234 + } 2230 2235 2231 2236 ret = kstrtoul(page, 0, &tmp); 2232 2237 if (ret < 0) {