hw/virtio-crypto: enforce max akcipher key length

enforce the global max_size boundary for akcipher session creation

Signed-off-by: helei <lhestz@163.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-ID: <20260616123251.26446-2-lhestz@163.com>
This commit is contained in:
helei
2026-06-16 20:32:51 +08:00
committed by Michael S. Tsirkin
parent a63a6cd694
commit a2134e938a

View File

@@ -216,6 +216,12 @@ virtio_crypto_create_asym_session(VirtIOCrypto *vcrypto,
return -VIRTIO_CRYPTO_NOTSUPP;
}
if (unlikely(keylen > vcrypto->conf.max_size)) {
error_report("virtio-crypto length of akcipher key is too large: %u",
keylen);
return -VIRTIO_CRYPTO_ERR;
}
if (keylen) {
asym_info->key = g_malloc(keylen);
if (iov_to_buf(iov, out_num, 0, asym_info->key, keylen) != keylen) {