]> git.baikalelectronics.ru Git - kernel.git/commit
crypto: caam - fix IV DMA mapping and updating
authorHoria Geantă <horia.geanta@nxp.com>
Wed, 28 Mar 2018 12:39:18 +0000 (15:39 +0300)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 20 Apr 2018 16:58:25 +0000 (00:58 +0800)
commit83e7edb835cb2fe35c4be546ec4cbbe4d982018d
tree6748f1fafa791b6c84432a1d19b21734c61f5a31
parent0253a2b1fcf4f7b0e9519c6b7911501c3bdfd223
crypto: caam - fix IV DMA mapping and updating

There are two IV-related issues:
(1) crypto API does not guarantee to provide an IV buffer that is DMAable,
thus it's incorrect to DMA map it
(2) for in-place decryption, since ciphertext is overwritten with
plaintext, updated req->info will contain the last block of plaintext
(instead of the last block of ciphertext)

While these two issues could be fixed separately, it's straightforward
to fix both in the same time - by allocating extra space in the
ablkcipher_edesc for the IV that will be fed to the crypto engine;
this allows for fixing (2) by saving req->src[last_block] in req->info
directly, i.e. without allocating another temporary buffer.

A side effect of the fix is that it's no longer possible to have the IV
and req->src contiguous. Code checking for this case is removed.

Cc: <stable@vger.kernel.org> # 4.13+
Fixes: eae6edc7eccb ("crypto: caam - properly set IV after {en,de}crypt")
Link: http://lkml.kernel.org/r/20170113084620.GF22022@gondor.apana.org.au
Reported-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/caam/caamalg.c