stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* FAILED: patch "[PATCH] crypto: virtio: Fix dest length calculation in" failed to apply to 5.4-stable tree
@ 2020-06-15 20:30 gregkh
  2020-06-16  1:14 ` Sasha Levin
  0 siblings, 1 reply; 2+ messages in thread
From: gregkh @ 2020-06-15 20:30 UTC (permalink / raw)
  To: longpeng2, arei.gonglei, davem, herbert, jasowang, mst; +Cc: stable


The patch below does not apply to the 5.4-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From d90ca42012db2863a9a30b564a2ace6016594bda Mon Sep 17 00:00:00 2001
From: "Longpeng(Mike)" <longpeng2@huawei.com>
Date: Tue, 2 Jun 2020 15:05:01 +0800
Subject: [PATCH] crypto: virtio: Fix dest length calculation in
 __virtio_crypto_skcipher_do_req()

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@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@lists.linux-foundation.org
Cc: linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Signed-off-by: Longpeng(Mike) <longpeng2@huawei.com>
Link: https://lore.kernel.org/r/20200602070501.2023-4-longpeng2@huawei.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

diff --git a/drivers/crypto/virtio/virtio_crypto_algs.c b/drivers/crypto/virtio/virtio_crypto_algs.c
index 52261b6c247e..cb8a6ea2a4bc 100644
--- a/drivers/crypto/virtio/virtio_crypto_algs.c
+++ b/drivers/crypto/virtio/virtio_crypto_algs.c
@@ -407,6 +407,7 @@ __virtio_crypto_skcipher_do_req(struct virtio_crypto_sym_request *vc_sym_req,
 		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);
 


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: FAILED: patch "[PATCH] crypto: virtio: Fix dest length calculation in" failed to apply to 5.4-stable tree
  2020-06-15 20:30 FAILED: patch "[PATCH] crypto: virtio: Fix dest length calculation in" failed to apply to 5.4-stable tree gregkh
@ 2020-06-16  1:14 ` Sasha Levin
  0 siblings, 0 replies; 2+ messages in thread
From: Sasha Levin @ 2020-06-16  1:14 UTC (permalink / raw)
  To: gregkh; +Cc: longpeng2, arei.gonglei, davem, herbert, jasowang, mst, stable

On Mon, Jun 15, 2020 at 10:30:24PM +0200, gregkh@linuxfoundation.org wrote:
>
>The patch below does not apply to the 5.4-stable tree.
>If someone wants it applied there, or to any other stable or longterm
>tree, then please email the backport, including the original git commit
>id to <stable@vger.kernel.org>.
>
>thanks,
>
>greg k-h
>
>------------------ original commit in Linus's tree ------------------
>
>From d90ca42012db2863a9a30b564a2ace6016594bda Mon Sep 17 00:00:00 2001
>From: "Longpeng(Mike)" <longpeng2@huawei.com>
>Date: Tue, 2 Jun 2020 15:05:01 +0800
>Subject: [PATCH] crypto: virtio: Fix dest length calculation in
> __virtio_crypto_skcipher_do_req()
>
>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@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@lists.linux-foundation.org
>Cc: linux-kernel@vger.kernel.org
>Cc: stable@vger.kernel.org
>Signed-off-by: Longpeng(Mike) <longpeng2@huawei.com>
>Link: https://lore.kernel.org/r/20200602070501.2023-4-longpeng2@huawei.com
>Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

Conflict due to missing eee1d6fca0a0 ("crypto: virtio - switch to
skcipher API"). I've fixed it and queued up for 5.4, 4.19, and 4.14.
-- 
Thanks,
Sasha

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-06-16  1:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-15 20:30 FAILED: patch "[PATCH] crypto: virtio: Fix dest length calculation in" failed to apply to 5.4-stable tree gregkh
2020-06-16  1:14 ` Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).