summaryrefslogtreecommitdiffstats
path: root/drivers/crypto/caam/caampkc.c
diff options
context:
space:
mode:
authorHoria Geantă2019-06-10 15:30:58 +0200
committerHerbert Xu2019-06-20 08:18:33 +0200
commit059d73eea6409873446a858dd64a5bec9bf68b70 (patch)
tree64bcd3c478e63f213731115d7f132d9e42cd0a0b /drivers/crypto/caam/caampkc.c
parenthwrng: iproc-rng200 - Add support for 7211 (diff)
downloadkernel-qcow2-linux-059d73eea6409873446a858dd64a5bec9bf68b70.tar.gz
kernel-qcow2-linux-059d73eea6409873446a858dd64a5bec9bf68b70.tar.xz
kernel-qcow2-linux-059d73eea6409873446a858dd64a5bec9bf68b70.zip
crypto: caam - use len instead of nents for bulding HW S/G table
Currently, conversion of SW S/G table into HW S/G layout relies on nents returned by sg_nents_for_len(sg, len). However this leaves the possibility of HW S/G referencing more data then needed: since buffer length in HW S/G entries is filled using sg_dma_len(sg), the last entry in HW S/G table might have a length that is bigger than needed for the crypto request. This way of S/G table conversion is fine, unless after converting a table more entries have to be appended to the HW S/G table. In this case, crypto engine would access data from the S/G entry having the incorrect length, instead of advancing in the S/G table. This situation doesn't exist, but the upcoming implementation of IV update for skcipher algorithms needs to add a S/G entry after req->dst S/G (corresponding to output IV). Signed-off-by: Horia Geantă <horia.geanta@nxp.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto/caam/caampkc.c')
-rw-r--r--drivers/crypto/caam/caampkc.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/crypto/caam/caampkc.c b/drivers/crypto/caam/caampkc.c
index 19b02c1973fc..80574106af29 100644
--- a/drivers/crypto/caam/caampkc.c
+++ b/drivers/crypto/caam/caampkc.c
@@ -306,11 +306,11 @@ static struct rsa_edesc *rsa_edesc_alloc(struct akcipher_request *req,
0);
if (sec4_sg_index)
- sg_to_sec4_sg_last(req_ctx->fixup_src, src_nents,
+ sg_to_sec4_sg_last(req_ctx->fixup_src, req_ctx->fixup_src_len,
edesc->sec4_sg + !!diff_size, 0);
if (dst_nents > 1)
- sg_to_sec4_sg_last(req->dst, dst_nents,
+ sg_to_sec4_sg_last(req->dst, req->dst_len,
edesc->sec4_sg + sec4_sg_index, 0);
/* Save nents for later use in Job Descriptor */