@samitouri / QOSamiQemu / commits / a2134e938a

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>

helei committed Jun 16, 2026 at 20:32 UTC a2134e938a0c43d2f06f04689c59de4052d0b986
1 file changed +6
hw/virtio/virtio-crypto.c
+6
@@ -216,6 +216,12 @@ virtio_crypto_create_asym_session(VirtIOCrypto *vcrypto,
216 return -VIRTIO_CRYPTO_NOTSUPP;
217 }
218
219 + if (unlikely(keylen > vcrypto->conf.max_size)) {
220 + error_report("virtio-crypto length of akcipher key is too large: %u",
221 + keylen);
222 + return -VIRTIO_CRYPTO_ERR;
223 + }
224 +
225 if (keylen) {
226 asym_info->key = g_malloc(keylen);
227 if (iov_to_buf(iov, out_num, 0, asym_info->key, keylen) != keylen) {