Skip to content

Commit

Permalink
virtio-crypto: verify src&dst buffer length for sym request
Browse files Browse the repository at this point in the history
For symmetric algorithms, the length of ciphertext must be as same
as the plaintext.
The missing verification of the src_len and the dst_len in
virtio_crypto_sym_op_helper() may lead buffer overflow/divulged.

This patch is originally written by Yiming Tao for QEMU-SECURITY,
resend it(a few changes of error message) in qemu-devel.

Fixes: CVE-2023-3180
Fixes: 04b9b37("virtio-crypto: add data queue processing handler")
Cc: Gonglei <arei.gonglei@huawei.com>
Cc: Mauro Matteo Cascella <mcascell@redhat.com>
Cc: Yiming Tao <taoym@zju.edu.cn>
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
Message-Id: <20230803024314.29962-2-pizhenwei@bytedance.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 9d38a84)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
  • Loading branch information
pizhenwei authored and Michael Tokarev committed Aug 4, 2023
1 parent fd902c5 commit 49f1e02
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions hw/virtio/virtio-crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,11 @@ virtio_crypto_sym_op_helper(VirtIODevice *vdev,
return NULL;
}

if (unlikely(src_len != dst_len)) {
virtio_error(vdev, "sym request src len is different from dst len");
return NULL;
}

max_len = (uint64_t)iv_len + aad_len + src_len + dst_len + hash_result_len;
if (unlikely(max_len > vcrypto->conf.max_size)) {
virtio_error(vdev, "virtio-crypto too big length");
Expand Down

0 comments on commit 49f1e02

Please sign in to comment.