Commit 3e51f8ab authored by Roland Dreier's avatar Roland Dreier Committed by Ben Hutchings

target: Check number of unmap descriptors against our limit

commit 7409a665 upstream.

Fail UNMAP commands that have more than our reported limit on unmap
descriptors.
Signed-off-by: default avatarRoland Dreier <roland@purestorage.com>
Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
[bwh: Backported to 3.2: adjust filename]
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent 76191bb2
......@@ -1133,6 +1133,11 @@ int target_emulate_unmap(struct se_task *task)
bd_dl = get_unaligned_be16(&buf[2]);
size = min(size - 8, bd_dl);
if (size / 16 > dev->se_sub_dev->se_dev_attrib.max_unmap_block_desc_count) {
cmd->scsi_sense_reason = TCM_INVALID_PARAMETER_LIST;
ret = -EINVAL;
goto err;
}
/* First UNMAP block descriptor starts at 8 byte offset */
ptr = &buf[8];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment