]> git.hungrycats.org Git - linux/commitdiff
target: Check number of unmap descriptors against our limit
authorRoland Dreier <roland@purestorage.com>
Mon, 16 Jul 2012 22:34:25 +0000 (15:34 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 15 Aug 2012 14:53:02 +0000 (07:53 -0700)
commit 7409a6657aebf8be74c21d0eded80709b27275cb upstream.

Fail UNMAP commands that have more than our reported limit on unmap
descriptors.

Signed-off-by: Roland Dreier <roland@purestorage.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
[bwh: Backported to 3.2: adjust filename]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/target/target_core_cdb.c

index d7f3d12634541ac4ac1c7712c2cc2e0e9ffa9522..bf7d38a76e0ebeae052e235bc498da6ee548858f 100644 (file)
@@ -1032,6 +1032,11 @@ int target_emulate_unmap(struct se_cmd *cmd)
        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];