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
atmel-aes.c
atmel-authenc.h
atmel-ecc.c
atmel-i2c.c
atmel-i2c.h
atmel-sha-regs.h
atmel-sha.c
atmel-sha204a.c
atmel-tdes-regs.h
atmel-tdes.c
exynos-rng.c
geode-aes.c
geode-aes.h
hifn_795x.c
img-hash.c
ixp4xx_crypto.c
mxs-dcp.c
n2_asm.S
n2_core.c
n2_core.h
omap-aes-gcm.c
omap-aes.c
omap-aes.h
omap-crypto.c
omap-crypto.h
omap-des.c
omap-sham.c
padlock-aes.c
padlock-sha.c
picoxcell_crypto.c
picoxcell_crypto_regs.h
qcom-rng.c
s5p-sss.c
sahara.c
talitos.c
talitos.h