aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Disseldorp <ddiss@suse.de>2017-01-02 12:04:06 -0500
committerBart Van Assche <bart.vanassche@sandisk.com>2017-01-10 11:41:13 -0500
commitf184210bca6c9d0091ff5e5629dea4cbb8a17c0f (patch)
tree52f839810a5504d80b7ef6310c95b9dcedb7ecb4
parent94aae4caacda89a1bdb7198b260f4ca3595b7ed7 (diff)
target: check XCOPY segment descriptor CSCD IDs
Ensure that the segment descriptor CSCD descriptor ID values correspond to CSCD descriptor entries located in the XCOPY command parameter list. SPC4r37 6.4.6.1 Table 150 specifies this range as 0000h to 07FFh, where the CSCD descriptor location in the parameter list can be located via: 16 + (id * 32) Signed-off-by: David Disseldorp <ddiss@suse.de> Reviewed-by: Christoph Hellwig <hch@lst.de> [ bvanassche: inserted "; " in the format string of an error message and also moved a "||" operator from the start of a line to the end of the previous line ] Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
-rw-r--r--drivers/target/target_core_xcopy.c8
-rw-r--r--drivers/target/target_core_xcopy.h6
2 files changed, 14 insertions, 0 deletions
diff --git a/drivers/target/target_core_xcopy.c b/drivers/target/target_core_xcopy.c
index 155db18ee4e7..41a2a8ad1046 100644
--- a/drivers/target/target_core_xcopy.c
+++ b/drivers/target/target_core_xcopy.c
@@ -278,6 +278,14 @@ static int target_xcopy_parse_segdesc_02(struct se_cmd *se_cmd, struct xcopy_op
278 278
279 xop->stdi = get_unaligned_be16(&desc[4]); 279 xop->stdi = get_unaligned_be16(&desc[4]);
280 xop->dtdi = get_unaligned_be16(&desc[6]); 280 xop->dtdi = get_unaligned_be16(&desc[6]);
281
282 if (xop->stdi > XCOPY_CSCD_DESC_ID_LIST_OFF_MAX ||
283 xop->dtdi > XCOPY_CSCD_DESC_ID_LIST_OFF_MAX) {
284 pr_err("XCOPY segment desc 0x02: unsupported CSCD ID > 0x%x; stdi: %hu dtdi: %hu\n",
285 XCOPY_CSCD_DESC_ID_LIST_OFF_MAX, xop->stdi, xop->dtdi);
286 return -EINVAL;
287 }
288
281 pr_debug("XCOPY seg desc 0x02: desc_len: %hu stdi: %hu dtdi: %hu, DC: %d\n", 289 pr_debug("XCOPY seg desc 0x02: desc_len: %hu stdi: %hu dtdi: %hu, DC: %d\n",
282 desc_len, xop->stdi, xop->dtdi, dc); 290 desc_len, xop->stdi, xop->dtdi, dc);
283 291
diff --git a/drivers/target/target_core_xcopy.h b/drivers/target/target_core_xcopy.h
index 4d3d4dd060f2..e2d141140342 100644
--- a/drivers/target/target_core_xcopy.h
+++ b/drivers/target/target_core_xcopy.h
@@ -5,6 +5,12 @@
5#define XCOPY_NAA_IEEE_REGEX_LEN 16 5#define XCOPY_NAA_IEEE_REGEX_LEN 16
6#define XCOPY_MAX_SECTORS 1024 6#define XCOPY_MAX_SECTORS 1024
7 7
8/*
9 * SPC4r37 6.4.6.1
10 * Table 150 — CSCD descriptor ID values
11 */
12#define XCOPY_CSCD_DESC_ID_LIST_OFF_MAX 0x07FF
13
8enum xcopy_origin_list { 14enum xcopy_origin_list {
9 XCOL_SOURCE_RECV_OP = 0x01, 15 XCOL_SOURCE_RECV_OP = 0x01,
10 XCOL_DEST_RECV_OP = 0x02, 16 XCOL_DEST_RECV_OP = 0x02,