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:
committed by
Michael S. Tsirkin
parent
a63a6cd694
commit
a2134e938a
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user