On 6/16/26 20:32, helei wrote:
> enforce the global max_size boundary for akcipher session creation
>
> Signed-off-by: helei <lhestz@163.com>
> ---
> 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) {
sorry, i accidentally missed the cover letter, here is the changelog for
this version:
v2:
- dropped the hardcoded limit mirroring the linux kernel.
- enforced the global max_size boundary for akcipher session creation.