Skip to content

Commit

Permalink
scst_copy_mgr: Reject EXTENDED COPY(LID4) commands
Browse files Browse the repository at this point in the history
Since SCST only supports EXTENDED COPY(LID1) commands, reject EXTENDED
COPY(LID4) commands.

Signed-off-by: Bart Van Assche <[email protected]>
  • Loading branch information
bvanassche authored and lnocturno committed Feb 16, 2024
1 parent 316856c commit bee5066
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions scst/src/scst_copy_mgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -2971,6 +2971,7 @@ struct scst_cm_tgt_descr {
int param_offs;
};

/* Parse the copy source or copy destination (CSCD) descriptors. */
static int scst_cm_parse_id_tgt_descr(struct scst_cmd *cmd, const uint8_t *seg,
int offs, struct scst_cm_tgt_descr *tgt_descr)
{
Expand Down Expand Up @@ -3015,10 +3016,13 @@ static int scst_cm_parse_id_tgt_descr(struct scst_cmd *cmd, const uint8_t *seg,
list_for_each_entry(des, &scst_cm_desig_list, cm_desig_list_entry) {
TRACE_DBG("des %p (tgt_dev %p, lun %lld)", des, des->desig_tgt_dev,
(unsigned long long)des->desig_tgt_dev->lun);
/* Check the code set field. */
if (seg[4] != des->desig[0])
continue;
/* Check the association and designator type fields. */
if (seg[5] != des->desig[1])
continue;
/* Check the designator length. */
if (seg[7] > 20) {
PRINT_WARNING("Initiator sent non-compliant identification descriptor (len %u > 20)",
seg[7]);
Expand Down Expand Up @@ -3410,6 +3414,7 @@ static void scst_cm_free_ec_priv(struct scst_cmd *ec_cmd, bool unblock_dev)
return;
}

/* Parse the EXTENDED COPY parameter list. */
int scst_cm_parse_descriptors(struct scst_cmd *ec_cmd)
{
int res = 0, rc;
Expand All @@ -3426,6 +3431,18 @@ int scst_cm_parse_descriptors(struct scst_cmd *ec_cmd)

EXTRACHECKS_BUG_ON(ec_cmd->cmd_data_descriptors != NULL);

if (ec_cmd->cdb[1] != 0) {
/*
* SCST only supports the EXTENDED COPY(LID1) command.
* Reject EXTENDED COPY(LID4) commands since these have a
* completely different parameter format. Definitions for both
* commands are available in SPC-4 while the LID1 variant has
* been removed from SPC-5 and SPC-6.
*/
scst_set_invalid_field_in_cdb(ec_cmd, 1, 0);
goto out_abn;
}

length = scst_get_buf_full_sense(ec_cmd, &buf);
if (unlikely(length <= 0)) {
if (length == 0)
Expand Down

0 comments on commit bee5066

Please sign in to comment.