Commit 5528d031 authored by Varun Prakash's avatar Varun Prakash Committed by Martin K. Petersen

scsi: target: iscsi: Fix data digest calculation

Current code does not consider 'page_off' in data digest calculation. To
fix this, add a local variable 'first_sg' and set first_sg.offset to
sg->offset + page_off.

Link: https://lore.kernel.org/r/1598358910-3052-1-git-send-email-varun@chelsio.com
Fixes: e48354ce ("iscsi-target: Add iSCSI fabric support for target v4.1")
Cc: <stable@vger.kernel.org>
Reviewed-by: default avatarMike Christie <michael.christie@oralce.com>
Signed-off-by: default avatarVarun Prakash <varun@chelsio.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent bc534069
......@@ -1389,14 +1389,27 @@ static u32 iscsit_do_crypto_hash_sg(
sg = cmd->first_data_sg;
page_off = cmd->first_data_sg_off;
if (data_length && page_off) {
struct scatterlist first_sg;
u32 len = min_t(u32, data_length, sg->length - page_off);
sg_init_table(&first_sg, 1);
sg_set_page(&first_sg, sg_page(sg), len, sg->offset + page_off);
ahash_request_set_crypt(hash, &first_sg, NULL, len);
crypto_ahash_update(hash);
data_length -= len;
sg = sg_next(sg);
}
while (data_length) {
u32 cur_len = min_t(u32, data_length, (sg->length - page_off));
u32 cur_len = min_t(u32, data_length, sg->length);
ahash_request_set_crypt(hash, sg, NULL, cur_len);
crypto_ahash_update(hash);
data_length -= cur_len;
page_off = 0;
/* iscsit_map_iovec has already checked for invalid sg pointers */
sg = sg_next(sg);
}
......
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