crypto: virtio: Fix dest length calculation in __virtio_crypto_skcipher_do_req()
Longpeng(Mike) authored
commit d90ca420 upstream.

The src/dst length is not aligned with AES_BLOCK_SIZE(which is 16) in some
testcases in tcrypto.ko.

For example, the src/dst length of one of cts(cbc(aes))'s testcase is 17, the
crypto_virtio driver will set @src_data_len=16 but @dst_data_len=17 in this
case and get a wrong at then end.

  SRC: pp pp pp pp pp pp pp pp pp pp pp pp pp pp pp pp pp (17 bytes)
  EXP: cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc pp (17 bytes)
  DST: cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc 00 (pollute the last bytes)
  (pp: plaintext  cc:ciphertext)

Fix this issue by limit the length of dest buffer.

Fixes: dbaf0624 ("crypto: add virtio-crypto driver")
Cc: Gonglei <arei.gonglei@huawei.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Jason Wang <jasowang@redhat.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: virtualization@l...
bae7e526
Name Last commit Last update
..
allwinner crypto: sun8i-ce - fix description of stat_fb
amcc crypto: crypto4xx - use GFP_KERNEL for big allocations
amlogic crypto: amlogic - fix removal of module
axis crypto: remove CRYPTO_TFM_RES_BAD_KEY_LEN
bcm crypto: bcm - Use scnprintf() for avoiding potential buffer overflow
caam crypto: caam - fix the address of the last entry of S/G
cavium crypto: cavium/nitrox - Fix 'nitrox_get_first_device()' when ndevlist is fully iterated
ccp crypto: ccp - use file mode for sev ioctl permissions
ccree crypto: ccree - remove duplicated include from cc_aead.c
chelsio crypto: chelsio/chtls: properly set tp->lsndtime
hisilicon crypto: hisilicon - Fix build error
inside-secure crypto: remove propagation of CRYPTO_TFM_RES_* flags
marvell crypto: marvell/octeontx - fix double free of ptr
mediatek crypto: Replace zero-length array with flexible-array member
nx crypto: Replace zero-length array with flexible-array member
qat crypto: qat - simplify the qat_crypto function
qce crypto: qce - fix wrong config symbol reference
rockchip crypto: remove CRYPTO_TFM_RES_BAD_KEY_LEN
stm32 crypto: remove CRYPTO_TFM_RES_BAD_KEY_LEN
ux500 crypto: remove CRYPTO_TFM_RES_BAD_KEY_LEN
virtio crypto: virtio: Fix dest length calculation in __virtio_crypto_skcipher_do_req()
vmx .gitignore: add SPDX License Identifier
xilinx crypto: xilinx - Add Xilinx AES driver
Kconfig crypto: marvell - create common Kconfig and Makefile for Marvell
Makefile crypto: marvell - create common Kconfig and Makefile for Marvell
atmel-aes-regs.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license
atmel-aes.c crypto: atmel-{aes,sha,tdes} - Retire crypto_platform_data
atmel-authenc.h crypto: remove propagation of CRYPTO_TFM_RES_* flags
atmel-ecc.c crypto: atmel-ecc - factor out code that can be shared
atmel-i2c.c crypto: atmel-i2c - Fix wakeup fail
atmel-i2c.h crypto: atmel - Fix -Wunused-const-variable warning
atmel-sha-regs.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license
atmel-sha.c crypto: atmel-{aes,sha,tdes} - Retire crypto_platform_data
atmel-sha204a.c crypto: atmel-sha204a - Use device-managed registration API
atmel-tdes-regs.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license
atmel-tdes.c crypto: atmel-{aes,sha,tdes} - Retire crypto_platform_data
exynos-rng.c crypto: exynos - use devm_platform_ioremap_resource() to simplify code
geode-aes.c crypto: remove propagation of CRYPTO_TFM_RES_* flags
geode-aes.h crypto: geode-aes - convert to skcipher API and make thread-safe
hifn_795x.c remove ioremap_nocache and devm_ioremap_nocache
img-hash.c crypto: img-hash - Replace zero-length array with flexible-array member
ixp4xx_crypto.c crypto: remove CRYPTO_TFM_RES_WEAK_KEY
mxs-dcp.c crypto: mxs-dcp - fix scatterlist linearization for hash
n2_asm.S License cleanup: add SPDX GPL-2.0 license identifier to files with no license
n2_core.c crypto: remove CRYPTO_TFM_RES_BAD_KEY_LEN
n2_core.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license
omap-aes-gcm.c crypto: omap-aes-gcm - convert to use crypto engine
omap-aes.c crypto: omap-aes-gcm - convert to use crypto engine
omap-aes.h crypto: omap-aes-gcm - convert to use crypto engine
omap-crypto.c crypto: omap-crypto - copy the temporary data to output buffer properly
omap-crypto.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500
omap-des.c crypto: omap-des - handle NULL cipher request
omap-sham.c crypto: Replace zero-length array with flexible-array member
padlock-aes.c crypto: Convert to new CPU match macros
padlock-sha.c crypto: Convert to new CPU match macros
picoxcell_crypto.c crypto: remove propagation of CRYPTO_TFM_RES_* flags
picoxcell_crypto_regs.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156
qcom-rng.c crypto: qcom-rng - use devm_platform_ioremap_resource() to simplify code
s5p-sss.c crypto: s5p-sss - Replace zero-length array with flexible-array member
sahara.c crypto: remove propagation of CRYPTO_TFM_RES_* flags
talitos.c crypto: remove CRYPTO_TFM_RES_BAD_KEY_LEN
talitos.h crypto: talitos - drop icv_ool