aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicholas Bellinger <nab@linux-iscsi.org>2012-10-02 17:00:33 -0400
committerNicholas Bellinger <nab@linux-iscsi.org>2012-10-02 17:16:19 -0400
commit944981c7e106af2aa004847e9177497856630980 (patch)
treecc3f3e84f26a13c18adb7b84055147ed9ea45b88
parent8f9f44f8957b262de717a48269a5ceca36c2b504 (diff)
target: Add control CDB READ payload zero work-around
This patch carries forward a work-around from tcm_loop to target core code to explicitly clear control CDB READ paylods in order to avoid bugs in scsi-generic user-space code for INQUIRY that do not explicitly zero CDB payload memory. (v2: Drop TARGET_SCF_MAP_CLEAR_MEM, and perform the explicit zero of READ memory for all target_submit_cmd_map_sgls users) Cc: Christoph Hellwig <hch@lst.de> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
-rw-r--r--drivers/target/target_core_transport.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index d96d9aa3a496..c33baff86aa6 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -1539,6 +1539,27 @@ int target_submit_cmd_map_sgls(struct se_cmd *se_cmd, struct se_session *se_sess
1539 if (sgl_count != 0) { 1539 if (sgl_count != 0) {
1540 BUG_ON(!sgl); 1540 BUG_ON(!sgl);
1541 1541
1542 /*
1543 * A work-around for tcm_loop as some userspace code via
1544 * scsi-generic do not memset their associated read buffers,
1545 * so go ahead and do that here for type non-data CDBs. Also
1546 * note that this is currently guaranteed to be a single SGL
1547 * for this case by target core in target_setup_cmd_from_cdb()
1548 * -> transport_generic_cmd_sequencer().
1549 */
1550 if (!(se_cmd->se_cmd_flags & SCF_SCSI_DATA_CDB) &&
1551 se_cmd->data_direction == DMA_FROM_DEVICE) {
1552 unsigned char *buf = NULL;
1553
1554 if (sgl)
1555 buf = kmap(sg_page(sgl)) + sgl->offset;
1556
1557 if (buf) {
1558 memset(buf, 0, sgl->length);
1559 kunmap(sg_page(sgl));
1560 }
1561 }
1562
1542 rc = transport_generic_map_mem_to_cmd(se_cmd, sgl, sgl_count, 1563 rc = transport_generic_map_mem_to_cmd(se_cmd, sgl, sgl_count,
1543 sgl_bidi, sgl_bidi_count); 1564 sgl_bidi, sgl_bidi_count);
1544 if (rc != 0) { 1565 if (rc != 0) {