From: helei <[email protected]> enforce the global max_size boundary for akcipher session creation
Signed-off-by: helei <[email protected]> Reviewed-by: Michael S. Tsirkin <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]> Message-ID: <[email protected]> --- hw/virtio/virtio-crypto.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c index 6fceb39681..79e2acb56c 100644 --- a/hw/virtio/virtio-crypto.c +++ b/hw/virtio/virtio-crypto.c @@ -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) { -- MST
