crypto: qce: skcipher: Fix incorrect sg count for dma transfers
authorThara Gopinath <thara.gopinath@linaro.org>
Fri, 21 May 2021 02:20:23 +0000 (22:20 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 14 Jul 2021 14:55:52 +0000 (16:55 +0200)
commitaddcb6bb584aef558ecab13c45bec0cd1bc3efb3
tree81dbfb0bac12e6107fe021d4b97f6d8801f0cb2f
parentd000c598db1d2eb24401a10236c68326208df7cd
crypto: qce: skcipher: Fix incorrect sg count for dma transfers

[ Upstream commit 1339a7c3ba05137a2d2fe75f602311bbfc6fab33 ]

Use the sg count returned by dma_map_sg to call into
dmaengine_prep_slave_sg rather than using the original sg count. dma_map_sg
can merge consecutive sglist entries, thus making the original sg count
wrong. This is a fix for memory coruption issues observed while testing
encryption/decryption of large messages using libkcapi framework.

Patch has been tested further by running full suite of tcrypt.ko tests
including fuzz tests.

Signed-off-by: Thara Gopinath <thara.gopinath@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/crypto/qce/skcipher.c