Commit 63ce3c38 authored by David Disseldorp's avatar David Disseldorp Committed by Martin K. Petersen

scsi: target: Fix truncated PR-in ReadKeys response

SPC5r17 states that the contents of the ADDITIONAL LENGTH field are not
altered based on the allocation length, so always calculate and pack the
full key list length even if the list itself is truncated.

According to Maged:

  Yes it fixes the "Storage Spaces Persistent Reservation" test in the
  Windows 2016 Server Failover Cluster validation suites when having
  many connections that result in more than 8 registrations. I tested
  your patch on 4.17 with iblock.

This behaviour can be tested using the libiscsi PrinReadKeys.Truncate test.

Cc: stable@vger.kernel.org
Signed-off-by: default avatarDavid Disseldorp <ddiss@suse.de>
Reviewed-by: default avatarMike Christie <mchristi@redhat.com>
Tested-by: default avatarMaged Mokhtar <mmokhtar@petasan.org>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 52ab9768
......@@ -3727,11 +3727,16 @@ core_scsi3_pri_read_keys(struct se_cmd *cmd)
* Check for overflow of 8byte PRI READ_KEYS payload and
* next reservation key list descriptor.
*/
if ((add_len + 8) > (cmd->data_length - 8))
break;
put_unaligned_be64(pr_reg->pr_res_key, &buf[off]);
off += 8;
if (off + 8 <= cmd->data_length) {
put_unaligned_be64(pr_reg->pr_res_key, &buf[off]);
off += 8;
}
/*
* SPC5r17: 6.16.2 READ KEYS service action
* The ADDITIONAL LENGTH field indicates the number of bytes in
* the Reservation key list. The contents of the ADDITIONAL
* LENGTH field are not altered based on the allocation length
*/
add_len += 8;
}
spin_unlock(&dev->t10_pr.registration_lock);
......
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