CEV fixes for virtio-crypto
cover CEV fixes for virtio-crypto
Hi Michael, Lei,
Yiming Tao, Yongkang Jia, Xiao Lei(from Zhejiang University) reported issuses and CVEs in the past days.
This series fixes a CVE and a BUG for virtio-crypto/cryptodev.
Zhenwei Pi (2):
virtio-crypto: verify src&dst buffer length for sym request
cryptodev: Handle unexpected request to avoid crash
backends/cryptodev.c | 10 ++++++++++ hw/virtio/virtio-crypto.c | 5 +++++ 2 files changed, 15 insertions(+)
Signature · 1 line
2.34.1
PATCH 1/2 virtio-crypto: verify src&dst buffer length for sym request
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.
--- hw/virtio/virtio-crypto.c | 5 +++++ 1 file changed, 5 insertions(+)
hw/virtio/virtio-crypto.c +5 -0
@@ -634,6 +634,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" );
Signature · 1 line
2.34.1
PATCH 2/2 cryptodev: Handle unexpected request to avoid crash
In reply to zhenwei piGenerally guest side should discover which services the device is able to offer, then do requests on device.
However it's also possible to break this rule in a guest. Handle unexpected request here to avoid NULL pointer dereference.
--- backends/cryptodev.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
backends/cryptodev.c +10 -0
@@ -191,6 +191,11 @@ static int cryptodev_backend_account(CryptoDevBackend *backend,if (algtype ==QCRYPTODEV_BACKEND_ALG_ASYM ) {CryptoDevBackendAsymOpInfo *asym_op_info = op_info->u.asym_op_info; len = asym_op_info->src_len; + +if (unlikely (!backend->asym_stat)) { +error_report ("cryptodev: Unexpected asym operation" ); +return -VIRTIO_CRYPTO_NOTSUPP ; + }switch (op_info->op_code) {case VIRTIO_CRYPTO_AKCIPHER_ENCRYPT :CryptodevAsymStatIncEncrypt (backend, len);
@@ -210,6 +215,11 @@ static int cryptodev_backend_account(CryptoDevBackend *backend, }else if (algtype ==QCRYPTODEV_BACKEND_ALG_SYM ) {CryptoDevBackendSymOpInfo *sym_op_info = op_info->u.sym_op_info; len = sym_op_info->src_len; + +if (unlikely (!backend->sym_stat)) { +error_report ("cryptodev: Unexpected sym operation" ); +return -VIRTIO_CRYPTO_NOTSUPP ; + }switch (op_info->op_code) {case VIRTIO_CRYPTO_CIPHER_ENCRYPT :CryptodevSymStatIncEncrypt (backend, len);
Signature · 1 line
2.34.1