linux-stable/drivers/crypto
Horia Geantă e5f55c5097 crypto: caam - fix concurrency issue in givencrypt descriptor
commit 48f89d2a29 upstream.

IV transfer from ofifo to class2 (set up at [29][30]) is not guaranteed
to be scheduled before the data transfer from ofifo to external memory
(set up at [38]:

[29] 10FA0004           ld: ind-nfifo (len=4) imm
[30] 81F00010               <nfifo_entry: ofifo->class2 type=msg len=16>
[31] 14820004           ld: ccb2-datasz len=4 offs=0 imm
[32] 00000010               data:0x00000010
[33] 8210010D    operation: cls1-op aes cbc init-final enc
[34] A8080B04         math: (seqin + math0)->vseqout len=4
[35] 28000010    seqfifold: skip len=16
[36] A8080A04         math: (seqin + math0)->vseqin len=4
[37] 2F1E0000    seqfifold: both msg1->2-last2-last1 len=vseqinsz
[38] 69300000   seqfifostr: msg len=vseqoutsz
[39] 5C20000C      seqstr: ccb2 ctx len=12 offs=0

If ofifo -> external memory transfer happens first, DECO will hang
(issuing a Watchdog Timeout error, if WDOG is enabled) waiting for
data availability in ofifo for the ofifo -> c2 ififo transfer.

Make sure IV transfer happens first by waiting for all CAAM internal
transfers to end before starting payload transfer.

New descriptor with jump command inserted at [37]:

[..]
[36] A8080A04         math: (seqin + math0)->vseqin len=4
[37] A1000401         jump: jsl1 all-match[!nfifopend] offset=[01] local->[38]
[38] 2F1E0000    seqfifold: both msg1->2-last2-last1 len=vseqinsz
[39] 69300000   seqfifostr: msg len=vseqoutsz
[40] 5C20000C      seqstr: ccb2 ctx len=12 offs=0

[Note: the issue is present in the descriptor from the very beginning
(cf. Fixes tag). However I've marked it v4.19+ since it's the oldest
maintained kernel that the patch applies clean against.]

Cc: <stable@vger.kernel.org> # v4.19+
Fixes: 1acebad3d8 ("crypto: caam - faster aead implementation")
Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-10-11 18:18:33 +02:00
..
amcc crypto: crypto4xx - fix a potential double free in ppc4xx_trng_probe 2019-07-31 07:28:36 +02:00
axis crypto: axis - fix for recursive locking from bottom half 2019-04-20 09:15:06 +02:00
bcm crypto: bcm - convert to use crypto_authenc_extractkeys() 2019-01-23 08:09:47 +01:00
caam crypto: caam - fix concurrency issue in givencrypt descriptor 2019-10-11 18:18:33 +02:00
cavium crypto: cavium/zip - Add missing single_release() 2019-10-11 18:18:33 +02:00
ccp crypto: ccp - Ignore unconfigured CCP device on suspend/resume 2019-09-06 10:20:59 +02:00
chelsio crypto: chelsio - Fix memory corruption in DMA Mapped buffers. 2018-10-13 09:27:28 +02:00
inside-secure crypto: inside-secure - fix the invalidation step during cra_exit 2018-05-25 16:17:46 +02:00
marvell License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
mediatek crypto: mediatek - fix error return code in mtk_crypto_probe() 2017-07-18 17:50:54 +08:00
nx crypto/NX: Set receive window credits to max number of CRBs in RxFIFO 2019-07-21 09:04:42 +02:00
qat crypto: qat - Silence smp_processor_id() warning 2019-10-11 18:18:32 +02:00
qce License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
rockchip crypto: rockchip - update IV buffer to contain the next IV 2019-05-21 18:50:15 +02:00
stm32 crypto: hash - annotate algorithms taking optional key 2018-02-16 20:23:00 +01:00
sunxi-ss crypto: sun4i-ss - Fix invalid calculation of hash end 2019-05-31 06:47:23 -07:00
ux500 crypto: ux500 - Use proper enum in hash_set_dma_transfer 2019-02-12 19:46:08 +01:00
virtio License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
vmx crypto: vmx - ghash: do nosimd fallback manually 2019-06-09 09:18:12 +02:00
Kconfig crypto: bcm - convert to use crypto_authenc_extractkeys() 2019-01-23 08:09:47 +01:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
atmel-aes-regs.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
atmel-aes.c crypto: atmel-aes - fix the keys zeroing on errors 2018-05-25 16:17:44 +02:00
atmel-authenc.h
atmel-ecc.c crypto: atmel-ecc - fix signed integer to u8 assignment 2017-08-03 13:47:23 +08:00
atmel-ecc.h crypto: atmel-ecc - introduce Microchip / Atmel ECC driver 2017-07-18 17:50:58 +08:00
atmel-sha-regs.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
atmel-sha.c crypto: atmel-sha - remove unnecessary static in atmel_sha_remove() 2017-08-03 13:47:16 +08:00
atmel-tdes-regs.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
atmel-tdes.c crypto: atmel-tdes - remove unnecessary static in atmel_tdes_remove() 2017-08-03 13:47:18 +08:00
bfin_crc.c crypto: hash - annotate algorithms taking optional key 2018-02-16 20:23:00 +01:00
bfin_crc.h
exynos-rng.c crypto: exynos - Add new Exynos RNG driver 2017-04-21 20:30:46 +08:00
geode-aes.c crypto: geode-aes - fixed coding style warnings and error 2017-07-18 18:15:57 +08:00
geode-aes.h
hifn_795x.c
img-hash.c crypto: img-hash - remove unnecessary static in img_hash_remove() 2017-08-03 13:47:18 +08:00
ixp4xx_crypto.c crypto: ixp4xx - Fix error handling path in 'aead_perform()' 2017-08-09 20:01:33 +08:00
mv_cesa.c crypto: mv_cesa - Use IPAD/OPAD constant 2017-05-23 12:52:08 +08:00
mv_cesa.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
mxc-scc.c crypto: mxc-scc - fix error code in mxc_scc_probe() 2017-07-18 17:50:54 +08:00
mxs-dcp.c crypto: mxs-dcp - Fix wait logic on chan threads 2018-10-10 08:54:27 +02:00
n2_asm.S License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
n2_core.c crypto: n2 - cure use after free 2018-01-10 09:31:18 +01:00
n2_core.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
omap-aes-gcm.c crypto: omap-aes - fix spelling mistake "Encryptio" -> "Encryption" 2017-06-20 11:21:29 +08:00
omap-aes.c crypto: omap-aes - fix error return code in omap_aes_probe() 2017-07-18 17:50:55 +08:00
omap-aes.h crypto: omap-aes - Add support for GCM mode 2017-06-10 12:04:19 +08:00
omap-crypto.c crypto: omap - add base support library for common routines 2017-06-10 12:04:15 +08:00
omap-crypto.h crypto: omap - add base support library for common routines 2017-06-10 12:04:15 +08:00
omap-des.c crypto: omap-des - fix error return code in omap_des_probe() 2017-07-18 17:50:55 +08:00
omap-sham.c crypto: omap-sham - fix memleak 2018-06-16 09:45:18 +02:00
padlock-aes.c crypto: padlock-aes - Fix Nano workaround data corruption 2018-08-06 16:20:51 +02:00
padlock-sha.c
picoxcell_crypto.c
picoxcell_crypto_regs.h
s5p-sss.c crypto: s5p-sss - Fix kernel Oops in AES-ECB mode 2018-02-25 11:08:04 +01:00
sahara.c crypto: sharah - Unregister correct algorithms for SAHARA 3 2018-09-26 08:38:05 +02:00
talitos.c crypto: talitos - fix missing break in switch statement 2019-10-05 12:47:33 +02:00
talitos.h