Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

target: Fix MAINTENANCE_IN service action CDB checks to use lower 5 bits

This patch fixes the MAINTENANCE_IN service action type checks to only
look at the proper lower 5 bits of cdb byte 1. This addresses the case
where MI_REPORT_TARGET_PGS w/ extended header using the upper three bits of
cdb byte 1 was not processed correctly in transport_generic_cmd_sequencer,
as well as the three cases for standby, unavailable, and transition ALUA
primary access state checks.

Also add MAINTENANCE_IN to the excluded list in transport_generic_prepare_cdb()
to prevent the PARAMETER DATA FORMAT bits from being cleared.

Cc: Hannes Reinecke <hare@suse.de>
Cc: Rob Evers <revers@redhat.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Roland Dreier <roland@purestorage.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>

+5 -4
+3 -3
drivers/target/target_core_alua.c
··· 387 387 case RECEIVE_DIAGNOSTIC: 388 388 case SEND_DIAGNOSTIC: 389 389 case MAINTENANCE_IN: 390 - switch (cdb[1]) { 390 + switch (cdb[1] & 0x1f) { 391 391 case MI_REPORT_TARGET_PGS: 392 392 return 0; 393 393 default: ··· 429 429 case INQUIRY: 430 430 case REPORT_LUNS: 431 431 case MAINTENANCE_IN: 432 - switch (cdb[1]) { 432 + switch (cdb[1] & 0x1f) { 433 433 case MI_REPORT_TARGET_PGS: 434 434 return 0; 435 435 default: ··· 469 469 case INQUIRY: 470 470 case REPORT_LUNS: 471 471 case MAINTENANCE_IN: 472 - switch (cdb[1]) { 472 + switch (cdb[1] & 0x1f) { 473 473 case MI_REPORT_TARGET_PGS: 474 474 return 0; 475 475 default:
+2 -1
drivers/target/target_core_transport.c
··· 1329 1329 case VERIFY_16: /* SBC - VRProtect */ 1330 1330 case WRITE_VERIFY: /* SBC - VRProtect */ 1331 1331 case WRITE_VERIFY_12: /* SBC - VRProtect */ 1332 + case MAINTENANCE_IN: /* SPC - Parameter Data Format for SA RTPG */ 1332 1333 break; 1333 1334 default: 1334 1335 cdb[1] &= 0x1f; /* clear logical unit number */ ··· 2598 2597 /* 2599 2598 * Check for emulated MI_REPORT_TARGET_PGS. 2600 2599 */ 2601 - if (cdb[1] == MI_REPORT_TARGET_PGS && 2600 + if ((cdb[1] & 0x1f) == MI_REPORT_TARGET_PGS && 2602 2601 su_dev->t10_alua.alua_type == SPC3_ALUA_EMULATED) { 2603 2602 cmd->execute_cmd = 2604 2603 target_emulate_report_target_port_groups;