Greg Kroah-Hartman
2020-Jun-16 15:34 UTC
[PATCH 5.7 093/163] crypto: virtio: Fix dest length calculation in __virtio_crypto_skcipher_do_req()
From: Longpeng(Mike) <longpeng2 at huawei.com> commit d90ca42012db2863a9a30b564a2ace6016594bda 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: dbaf0624ffa5 ("crypto: add virtio-crypto driver") Cc: Gonglei <arei.gonglei at huawei.com> Cc: Herbert Xu <herbert at gondor.apana.org.au> Cc: "Michael S. Tsirkin" <mst at redhat.com> Cc: Jason Wang <jasowang at redhat.com> Cc: "David S. Miller" <davem at davemloft.net> Cc: virtualization at lists.linux-foundation.org Cc: linux-kernel at vger.kernel.org Cc: stable at vger.kernel.org Signed-off-by: Longpeng(Mike) <longpeng2 at huawei.com> Link: https://lore.kernel.org/r/20200602070501.2023-4-longpeng2 at huawei.com Signed-off-by: Michael S. Tsirkin <mst at redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh at linuxfoundation.org> --- drivers/crypto/virtio/virtio_crypto_algs.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/crypto/virtio/virtio_crypto_algs.c +++ b/drivers/crypto/virtio/virtio_crypto_algs.c @@ -402,6 +402,7 @@ __virtio_crypto_skcipher_do_req(struct v goto free; } + dst_len = min_t(unsigned int, req->cryptlen, dst_len); pr_debug("virtio_crypto: src_len: %u, dst_len: %llu\n", req->cryptlen, dst_len);
Maybe Matching Threads
- Patch "crypto: virtio: Fix dest length calculation in __virtio_crypto_skcipher_do_req()" has been added to the 5.7-stable tree
- Patch "crypto: virtio: Fix dest length calculation in __virtio_crypto_skcipher_do_req()" has been added to the 5.6-stable tree
- [PATCH 5.6 098/161] crypto: virtio: Fix dest length calculation in __virtio_crypto_skcipher_do_req()
- [PATCH 5.4 088/134] crypto: virtio: Fix dest length calculation in __virtio_crypto_skcipher_do_req()
- [PATCH 4.14 051/190] crypto: virtio: Fix dest length calculation in __virtio_crypto_skcipher_do_req()