From: Andy Grover Subject: [PATCH 13/15] target: Enforce 1 page max for control cdb buffer sizes Date: Tue, 28 Jun 2011 12:29:35 -0700 Message-ID: <1309289377-8029-14-git-send-email-agrover@redhat.com> References: <1309289377-8029-1-git-send-email-agrover@redhat.com> Return-path: Received: from mx1.redhat.com ([209.132.183.28]:9673 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751642Ab1F1T3x (ORCPT ); Tue, 28 Jun 2011 15:29:53 -0400 In-Reply-To: <1309289377-8029-1-git-send-email-agrover@redhat.com> Sender: linux-scsi-owner@vger.kernel.org List-Id: linux-scsi@vger.kernel.org To: target-devel@vger.kernel.org Cc: linux-scsi@vger.kernel.org Due to all cdbs' data buffers being referenced by scatterlists, buffers of more than a page are not contiguous. Instead of handling this in all control command handlers, we may be able to get away with just limiting control cdb data buffers to one page. The only control CDBs we handle that have potentially large data buffers are REPORT LUNS and UNMAP, so if we didn't want to live with this limitation, they would need to be modified to walk the pages in the data buffer's sgl. Signed-off-by: Andy Grover --- drivers/target/target_core_transport.c | 5 +++++ include/target/target_core_base.h | 1 + 2 files changed, 6 insertions(+), 0 deletions(-) diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index c647e1f..a6b7a46 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -3459,6 +3459,11 @@ static int transport_generic_cmd_sequencer( cmd->data_length = size; } + /* Let's limit control cdbs to a page, for simplicity's sake. */ + if ((cmd->se_cmd_flags & SCF_SCSI_CONTROL_SG_IO_CDB) + && size > PAGE_SIZE) + goto out_invalid_cdb_field; + transport_set_supported_SAM_opcode(cmd); return ret; diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h index 2c5a748..32a1a48 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h @@ -15,6 +15,7 @@ /* Used by transport_generic_allocate_iovecs() */ #define TRANSPORT_IOV_DATA_BUFFER 5 /* Maximum Number of LUNs per Target Portal Group */ +/* Don't raise above 511 or REPORT_LUNS needs to handle >1 page */ #define TRANSPORT_MAX_LUNS_PER_TPG 256 /* * By default we use 32-byte CDBs in TCM Core and subsystem plugin code. -- 1.7.1