Skip to content

Commit 63ce3c3

Browse files
ddissmartinkpetersen
authored andcommitted
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: [email protected] Signed-off-by: David Disseldorp <[email protected]> Reviewed-by: Mike Christie <[email protected]> Tested-by: Maged Mokhtar <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 52ab976 commit 63ce3c3

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

drivers/target/target_core_pr.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3727,11 +3727,16 @@ core_scsi3_pri_read_keys(struct se_cmd *cmd)
37273727
* Check for overflow of 8byte PRI READ_KEYS payload and
37283728
* next reservation key list descriptor.
37293729
*/
3730-
if ((add_len + 8) > (cmd->data_length - 8))
3731-
break;
3732-
3733-
put_unaligned_be64(pr_reg->pr_res_key, &buf[off]);
3734-
off += 8;
3730+
if (off + 8 <= cmd->data_length) {
3731+
put_unaligned_be64(pr_reg->pr_res_key, &buf[off]);
3732+
off += 8;
3733+
}
3734+
/*
3735+
* SPC5r17: 6.16.2 READ KEYS service action
3736+
* The ADDITIONAL LENGTH field indicates the number of bytes in
3737+
* the Reservation key list. The contents of the ADDITIONAL
3738+
* LENGTH field are not altered based on the allocation length
3739+
*/
37353740
add_len += 8;
37363741
}
37373742
spin_unlock(&dev->t10_pr.registration_lock);

0 commit comments

Comments
 (0)