Skip to content

Commit 504e84a

Browse files
Gilad Ben-Yossefherbertx
authored andcommitted
crypto: ccree - only try to map auth tag if needed
Make sure to only add the size of the auth tag to the source mapping for encryption if it is an in-place operation. Failing to do this previously caused us to try and map auth size len bytes from a NULL mapping and crashing if both the cryptlen and assoclen are zero. Reported-by: Geert Uytterhoeven <[email protected]> Tested-by: Geert Uytterhoeven <[email protected]> Signed-off-by: Gilad Ben-Yossef <[email protected]> Cc: [email protected] # v4.19+ Signed-off-by: Herbert Xu <[email protected]>
1 parent ce0fc6d commit 504e84a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/crypto/ccree/cc_buffer_mgr.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,9 +1109,11 @@ int cc_map_aead_request(struct cc_drvdata *drvdata, struct aead_request *req)
11091109
}
11101110

11111111
size_to_map = req->cryptlen + areq_ctx->assoclen;
1112-
if (areq_ctx->gen_ctx.op_type == DRV_CRYPTO_DIRECTION_ENCRYPT)
1112+
/* If we do in-place encryption, we also need the auth tag */
1113+
if ((areq_ctx->gen_ctx.op_type == DRV_CRYPTO_DIRECTION_ENCRYPT) &&
1114+
(req->src == req->dst)) {
11131115
size_to_map += authsize;
1114-
1116+
}
11151117
if (is_gcm4543)
11161118
size_to_map += crypto_aead_ivsize(tfm);
11171119
rc = cc_map_sg(dev, req->src, size_to_map, DMA_BIDIRECTIONAL,

0 commit comments

Comments
 (0)