Skip to contentSkip to conversation

hw/virtio-crypto: add akcipher keylen validation

PATCH Superseded helei 3 participants 11 messages Jun 6 – Jun 16

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

helei

author
#0 lore raw

cover hw/virtio-crypto: add akcipher keylen validation

The virtio-crypto spec does not dictate a maximum length limit for asymmetric cipher (akcipher) keys. We added a hard limit which mirrors the linux kernels's internal limit for akcipher keys (see keyctl framework and the add_key syscall).
Maybe we should update the virtio-spec and add a max_akcipher_key_len field for virtio crypto devices.

helei (1):
hw/virtio-crypto: enforce max akcipher key length

 hw/virtio/virtio-crypto.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
Signature · 1 line
2.43.0
author
#1 lore raw

PATCH 1/1 hw/virtio-crypto: enforce max akcipher key length

Introduce VIRTIO_CRYPTO_MAX_AKCIPHER_KEY_LEN. We set this hard limit to 1MB, which mirrors the linux kernel's internal payload restriction for the 'add_key' syscall.

---
 hw/virtio/virtio-crypto.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
hw/virtio/virtio-crypto.c +13 -0
index 6fceb39681..06be93a0ac 100644
@@ -25,6 +25,13 @@
 #include "system/cryptodev-vhost.h"
 
 #define VIRTIO_CRYPTO_VM_VERSION 1
+/*
+ * The virtio-crypto spec does not limit akcipher key lengths. To prevent
+ * guest-introduced OOM attacks via excessive host memory allocation, we
+ * enforce a 1MB limit. This aligns with the linux kernel's internal max
+ * payload limit for the add_key syscall.
+ */
+#define VIRTIO_CRYPTO_MAX_AKCIPHER_KEY_LEN ((1024 * 1024) - 1)
 
 typedef struct VirtIOCryptoSessionReq {
     VirtIODevice *vdev;
@@ -216,6 +223,12 @@ virtio_crypto_create_asym_session(VirtIOCrypto *vcrypto,
         return -VIRTIO_CRYPTO_NOTSUPP;
     }
 
+    if (keylen > VIRTIO_CRYPTO_MAX_AKCIPHER_KEY_LEN) {
+        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) {
Signature · 1 line
2.43.0
#2 lore raw

Re: [PATCH] hw/virtio-crypto: enforce max akcipher key length

Quoted 40 lines · On Sat, 6 Jun 2026, 10:52 helei, <[email protected]> wrote:

Introduce VIRTIO_CRYPTO_MAX_AKCIPHER_KEY_LEN. We set this hard limit to 1MB, which mirrors the linux kernel's internal payload restriction for the 'add_key' syscall.

---
 hw/virtio/virtio-crypto.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
hw/virtio/virtio-crypto.c +13 -0
index 6fceb39681..06be93a0ac 100644
@@ -25,6 +25,13 @@
 #include "system/cryptodev-vhost.h"
 
 #define VIRTIO_CRYPTO_VM_VERSION 1
+/*
+ * The virtio-crypto spec does not limit akcipher key lengths. To prevent
+ * guest-introduced OOM attacks via excessive host memory allocation, we
+ * enforce a 1MB limit. This aligns with the linux kernel's internal max
+ * payload limit for the add_key syscall.
+ */
+#define VIRTIO_CRYPTO_MAX_AKCIPHER_KEY_LEN ((1024 * 1024) - 1)
 
 typedef struct VirtIOCryptoSessionReq {
     VirtIODevice *vdev;
@@ -216,6 +223,12 @@ virtio_crypto_create_asym_session(VirtIOCrypto
 *vcrypto,
         return -VIRTIO_CRYPTO_NOTSUPP;
     }
 
+    if (keylen > VIRTIO_CRYPTO_MAX_AKCIPHER_KEY_LEN) {
+        error_report("virtio-crypto length of akcipher key is too large:
 %u",
+                     keylen);
+        return -VIRTIO_CRYPTO_ERR;
+    }
+
     if (keylen) {
Quoted 2 lines
         asym_info->key = g_malloc(keylen);

Unrelated to this patch, but this g_malloc could be g_try_malloc.

         if (iov_to_buf(iov, out_num, 0, asym_info->key, keylen) != keylen)
Quoted 6 lines

{
--
2.43.0

#3 lore raw
In reply to helei
Quoted 4 lines · helei

The virtio-crypto spec does not dictate a maximum length limit for asymmetric cipher (akcipher) keys. We added a hard limit which mirrors the linux kernels's internal limit for akcipher keys (see keyctl framework and the add_key syscall).

We have max_size - doesn't that apply?
backends/cryptodev-builtin.c actually sets it:
backends/cryptodev-builtin.c:#define CRYPTODEV_BUITLIN_MAX_REQUEST_SIZE (1024 * 1024)
backends/cryptodev-builtin.c: backend->conf.max_size = CRYPTODEV_BUITLIN_MAX_REQUEST_SIZE;

Quoted 2 lines

Maybe we should update the virtio-spec and add a max_akcipher_key_len field for virtio crypto devices.

maybe

Quoted 9 lines

helei (1):
hw/virtio-crypto: enforce max akcipher key length

 hw/virtio/virtio-crypto.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
Signature · 1 line
2.43.0
author
#4 lore raw
Quoted 9 lines · Michael S. Tsirkin
Quoted 4 lines · helei

The virtio-crypto spec does not dictate a maximum length limit for asymmetric cipher (akcipher) keys. We added a hard limit which mirrors the linux kernels's internal limit for akcipher keys (see keyctl framework and the add_key syscall).

We have max_size - doesn't that apply?
backends/cryptodev-builtin.c actually sets it:
backends/cryptodev-builtin.c:#define CRYPTODEV_BUITLIN_MAX_REQUEST_SIZE (1024 * 1024)
backends/cryptodev-builtin.c: backend->conf.max_size = CRYPTODEV_BUITLIN_MAX_REQUEST_SIZE;

Thanks for your review!  I have verified via testing that all processing requests in the dataq are strictly

bounded by max_size, but session creation requests in the ctrlq are not.

Quoted 13 lines
Quoted 3 lines

Maybe we should update the virtio-spec and add a max_akcipher_key_len field for virtio crypto devices.

maybe

Quoted 8 lines

helei (1):
hw/virtio-crypto: enforce max akcipher key length

  hw/virtio/virtio-crypto.c | 13 +++++++++++++
  1 file changed, 13 insertions(+)
Signature · 1 line
2.43.0
#5 lore raw
Quoted 12 lines · helei
Quoted 9 lines · Michael S. Tsirkin
Quoted 4 lines · helei

The virtio-crypto spec does not dictate a maximum length limit for asymmetric cipher (akcipher) keys. We added a hard limit which mirrors the linux kernels's internal limit for akcipher keys (see keyctl framework and the add_key syscall).

We have max_size - doesn't that apply?
backends/cryptodev-builtin.c actually sets it:
backends/cryptodev-builtin.c:#define CRYPTODEV_BUITLIN_MAX_REQUEST_SIZE (1024 * 1024)
backends/cryptodev-builtin.c: backend->conf.max_size = CRYPTODEV_BUITLIN_MAX_REQUEST_SIZE;

Quoted 4 lines

Thanks for your review!  I have verified via testing that all processing requests in the dataq are strictly

bounded by max_size, but session creation requests in the ctrlq are not.

well if we read the spec it's vague

max_size is defined as "the maximum size of the variable-length parameters of data operation of each crypto request's content." and
The driver SHOULD read max_size to discover the maximum size of the variable-length parameters of data operation of the crypto request's content

so data operation.

however:

"The device MUST set max_size to show the maximum size of crypto request the device supports".

seems to cover all requests?

btw vhost user sets max_size to max u64 - is that sane?

Quoted 13 lines
Quoted 13 lines
Quoted 3 lines

Maybe we should update the virtio-spec and add a max_akcipher_key_len field for virtio crypto devices.

maybe

Quoted 8 lines

helei (1):
hw/virtio-crypto: enforce max akcipher key length

  hw/virtio/virtio-crypto.c | 13 +++++++++++++
  1 file changed, 13 insertions(+)
Signature · 1 line
2.43.0
author
#6 lore raw
Quoted 28 lines · Michael S. Tsirkin
Quoted 12 lines · helei
Quoted 9 lines · Michael S. Tsirkin
Quoted 4 lines · helei

The virtio-crypto spec does not dictate a maximum length limit for asymmetric cipher (akcipher) keys. We added a hard limit which mirrors the linux kernels's internal limit for akcipher keys (see keyctl framework and the add_key syscall).

We have max_size - doesn't that apply?
backends/cryptodev-builtin.c actually sets it:
backends/cryptodev-builtin.c:#define CRYPTODEV_BUITLIN_MAX_REQUEST_SIZE (1024 * 1024)
backends/cryptodev-builtin.c: backend->conf.max_size = CRYPTODEV_BUITLIN_MAX_REQUEST_SIZE;

Quoted 4 lines

Thanks for your review!  I have verified via testing that all processing requests in the dataq are strictly

bounded by max_size, but session creation requests in the ctrlq are not.

well if we read the spec it's vague

max_size is defined as "the maximum size of the variable-length parameters of data operation of each crypto request's content." and
The driver SHOULD read max_size to discover the maximum size of the variable-length parameters of data operation of the crypto request's content

Quoted 9 lines

so data operation.

however:

"The device MUST set max_size to show the maximum size of crypto request the device supports".

seems to cover all requests?

the original architectural intent was almost certainly for max_size to govern data-plane payloads, while control messages are handled by their own independent limits (max_cipher_key_len and max_auth_key_len). both upstream linux guest driver (virtio_crypto_skcipher_algs.c) and qemu's builtin-backend actually implement it exactly this way:
- data path enforces max_size by checking it against payload length (note that cryptodev-builtin recently capped this to 1MB via CVE-2025-14876)
- control path completely ignores max_size when creating sessions

Quoted 4 lines

btw vhost user sets max_size to max u64 - is that sane?

this is sane for an out-of-process data plane from a transport perspective, but it creates a practical catch when backed by a dpdk implementation:
- in dpdk vhost_crypto.c, vhost_crypto_check_cipher_request() enforces a strict check: src_data_len <= RTE_MBUF_DEFAULT_BUF_SIZE (2176 bytes)
- the guest kernel driver simply wraps the incoming sg list and passes it to virtqueue directly.
this creates a tricky situation for users: because vhost-user claims max_size is max_u64, the users has no way of knowing this 2KB ceiling exists unless they explicitly know the host backend is dpdk and look at its source code.

Quoted 16 lines
Quoted 15 lines
Quoted 15 lines
Quoted 5 lines

Maybe we should update the virtio-spec and add a max_akcipher_key_len field for virtio crypto devices.

maybe

Quoted 8 lines

helei (1):
hw/virtio-crypto: enforce max akcipher key length

  hw/virtio/virtio-crypto.c | 13 +++++++++++++
  1 file changed, 13 insertions(+)
Signature · 1 line
2.43.0
#7 lore raw
Quoted 40 lines · helei
Quoted 28 lines · Michael S. Tsirkin
Quoted 12 lines · helei
Quoted 9 lines · Michael S. Tsirkin
Quoted 4 lines · helei

The virtio-crypto spec does not dictate a maximum length limit for asymmetric cipher (akcipher) keys. We added a hard limit which mirrors the linux kernels's internal limit for akcipher keys (see keyctl framework and the add_key syscall).

We have max_size - doesn't that apply?
backends/cryptodev-builtin.c actually sets it:
backends/cryptodev-builtin.c:#define CRYPTODEV_BUITLIN_MAX_REQUEST_SIZE (1024 * 1024)
backends/cryptodev-builtin.c: backend->conf.max_size = CRYPTODEV_BUITLIN_MAX_REQUEST_SIZE;

Quoted 4 lines

Thanks for your review!  I have verified via testing that all processing requests in the dataq are strictly

bounded by max_size, but session creation requests in the ctrlq are not.

well if we read the spec it's vague

max_size is defined as "the maximum size of the variable-length parameters of data operation of each crypto request's content." and
The driver SHOULD read max_size to discover the maximum size of the variable-length parameters of data operation of the crypto request's content

Quoted 9 lines

so data operation.

however:

"The device MUST set max_size to show the maximum size of crypto request the device supports".

seems to cover all requests?

Quoted 8 lines

the original architectural intent was almost certainly for max_size to govern data-plane payloads, while control messages are handled by their own independent limits (max_cipher_key_len and max_auth_key_len). both upstream linux guest driver (virtio_crypto_skcipher_algs.c) and qemu's builtin-backend actually implement it exactly this way:
- data path enforces max_size by checking it against payload length (note that cryptodev-builtin recently capped this to 1MB via CVE-2025-14876)
- control path completely ignores max_size when creating sessions

we can add akcipher key length feature but what to do about existing guests?

could max_size be a way to fix it?

Quoted 4 lines
Quoted 4 lines

btw vhost user sets max_size to max u64 - is that sane?

Quoted 11 lines

this is sane for an out-of-process data plane from a transport perspective, but it creates a practical catch when backed by a dpdk implementation:
- in dpdk vhost_crypto.c, vhost_crypto_check_cipher_request() enforces a strict check: src_data_len <= RTE_MBUF_DEFAULT_BUF_SIZE (2176 bytes)
- the guest kernel driver simply wraps the incoming sg list and passes it to virtqueue directly.
this creates a tricky situation for users: because vhost-user claims max_size is max_u64, the users has no way of knowing this 2KB ceiling exists unless they explicitly know the host backend is dpdk and look at its source code.

worth fixing maybe.

Quoted 16 lines
Quoted 16 lines
Quoted 15 lines
Quoted 15 lines
Quoted 5 lines

Maybe we should update the virtio-spec and add a max_akcipher_key_len field for virtio crypto devices.

maybe

Quoted 8 lines

helei (1):
hw/virtio-crypto: enforce max akcipher key length

  hw/virtio/virtio-crypto.c | 13 +++++++++++++
  1 file changed, 13 insertions(+)
Signature · 1 line
2.43.0
author
#8 lore raw
Quoted 50 lines · Michael S. Tsirkin
Quoted 40 lines · helei
Quoted 28 lines · Michael S. Tsirkin
Quoted 12 lines · helei
Quoted 9 lines · Michael S. Tsirkin
Quoted 4 lines · helei

The virtio-crypto spec does not dictate a maximum length limit for asymmetric cipher (akcipher) keys. We added a hard limit which mirrors the linux kernels's internal limit for akcipher keys (see keyctl framework and the add_key syscall).

We have max_size - doesn't that apply?
backends/cryptodev-builtin.c actually sets it:
backends/cryptodev-builtin.c:#define CRYPTODEV_BUITLIN_MAX_REQUEST_SIZE (1024 * 1024)
backends/cryptodev-builtin.c: backend->conf.max_size = CRYPTODEV_BUITLIN_MAX_REQUEST_SIZE;

Quoted 4 lines

Thanks for your review!  I have verified via testing that all processing requests in the dataq are strictly

bounded by max_size, but session creation requests in the ctrlq are not.

well if we read the spec it's vague

max_size is defined as "the maximum size of the variable-length parameters of data operation of each crypto request's content." and
The driver SHOULD read max_size to discover the maximum size of the variable-length parameters of data operation of the crypto request's content

Quoted 9 lines

so data operation.

however:

"The device MUST set max_size to show the maximum size of crypto request the device supports".

seems to cover all requests?

Quoted 8 lines

the original architectural intent was almost certainly for max_size to govern data-plane payloads, while control messages are handled by their own independent limits (max_cipher_key_len and max_auth_key_len). both upstream linux guest driver (virtio_crypto_skcipher_algs.c) and qemu's builtin-backend actually implement it exactly this way:
- data path enforces max_size by checking it against payload length (note that cryptodev-builtin recently capped this to 1MB via CVE-2025-14876)
- control path completely ignores max_size when creating sessions

Quoted 5 lines

we can add akcipher key length feature but what to do about existing guests?

could max_size be a way to fix it?

yes, using max_size as a fallback hard limit across all virtqueues(both dataq and ctrlq) is a very good way to close this gap without breaking backward compatibility.
as for existing guests, virtio-crypto spec only defined RSA and ECDSA for asymmetric services. even an excessively large 16384 RSA key is only 2KB, so no well-behaved guest will ever be affected by a 1MB boundary on a session creation request.

note that if we take this approach, we should explicitly check both the algorithm-specific limits (max_cipher_key_len/max_auth_key_len) and the global max_size boundary across all session creation requests.

Quoted 34 lines
Quoted 4 lines
Quoted 4 lines

btw vhost user sets max_size to max u64 - is that sane?

Quoted 11 lines

this is sane for an out-of-process data plane from a transport perspective, but it creates a practical catch when backed by a dpdk implementation:
- in dpdk vhost_crypto.c, vhost_crypto_check_cipher_request() enforces a strict check: src_data_len <= RTE_MBUF_DEFAULT_BUF_SIZE (2176 bytes)
- the guest kernel driver simply wraps the incoming sg list and passes it to virtqueue directly.
this creates a tricky situation for users: because vhost-user claims max_size is max_u64, the users has no way of knowing this 2KB ceiling exists unless they explicitly know the host backend is dpdk and look at its source code.

worth fixing maybe.

Quoted 16 lines
Quoted 16 lines
Quoted 15 lines
Quoted 15 lines
Quoted 5 lines

Maybe we should update the virtio-spec and add a max_akcipher_key_len field for virtio crypto devices.

maybe

Quoted 8 lines

helei (1):
hw/virtio-crypto: enforce max akcipher key length

  hw/virtio/virtio-crypto.c | 13 +++++++++++++
  1 file changed, 13 insertions(+)
Signature · 1 line
2.43.0
#9 lore raw
Quoted 66 lines · helei
Quoted 50 lines · Michael S. Tsirkin
Quoted 40 lines · helei
Quoted 28 lines · Michael S. Tsirkin
Quoted 12 lines · helei
Quoted 9 lines · Michael S. Tsirkin
Quoted 4 lines · helei

The virtio-crypto spec does not dictate a maximum length limit for asymmetric cipher (akcipher) keys. We added a hard limit which mirrors the linux kernels's internal limit for akcipher keys (see keyctl framework and the add_key syscall).

We have max_size - doesn't that apply?
backends/cryptodev-builtin.c actually sets it:
backends/cryptodev-builtin.c:#define CRYPTODEV_BUITLIN_MAX_REQUEST_SIZE (1024 * 1024)
backends/cryptodev-builtin.c: backend->conf.max_size = CRYPTODEV_BUITLIN_MAX_REQUEST_SIZE;

Quoted 4 lines

Thanks for your review!  I have verified via testing that all processing requests in the dataq are strictly

bounded by max_size, but session creation requests in the ctrlq are not.

well if we read the spec it's vague

max_size is defined as "the maximum size of the variable-length parameters of data operation of each crypto request's content." and
The driver SHOULD read max_size to discover the maximum size of the variable-length parameters of data operation of the crypto request's content

Quoted 9 lines

so data operation.

however:

"The device MUST set max_size to show the maximum size of crypto request the device supports".

seems to cover all requests?

Quoted 8 lines

the original architectural intent was almost certainly for max_size to govern data-plane payloads, while control messages are handled by their own independent limits (max_cipher_key_len and max_auth_key_len). both upstream linux guest driver (virtio_crypto_skcipher_algs.c) and qemu's builtin-backend actually implement it exactly this way:
- data path enforces max_size by checking it against payload length (note that cryptodev-builtin recently capped this to 1MB via CVE-2025-14876)
- control path completely ignores max_size when creating sessions

Quoted 5 lines

we can add akcipher key length feature but what to do about existing guests?

could max_size be a way to fix it?

yes, using max_size as a fallback hard limit across all virtqueues(both dataq and ctrlq) is a very good way to close this gap without breaking backward compatibility.
as for existing guests, virtio-crypto spec only defined RSA and ECDSA for asymmetric services. even an excessively large 16384 RSA key is only 2KB, so no well-behaved guest will ever be affected by a 1MB boundary on a session creation request.

Quoted 3 lines

note that if we take this approach, we should explicitly check both the algorithm-specific limits (max_cipher_key_len/max_auth_key_len) and the global max_size boundary across all session creation requests.

why should we?
one could argue alg specific limits override the max_size.

Quoted 34 lines
Quoted 34 lines
Quoted 4 lines
Quoted 4 lines

btw vhost user sets max_size to max u64 - is that sane?

Quoted 11 lines

this is sane for an out-of-process data plane from a transport perspective, but it creates a practical catch when backed by a dpdk implementation:
- in dpdk vhost_crypto.c, vhost_crypto_check_cipher_request() enforces a strict check: src_data_len <= RTE_MBUF_DEFAULT_BUF_SIZE (2176 bytes)
- the guest kernel driver simply wraps the incoming sg list and passes it to virtqueue directly.
this creates a tricky situation for users: because vhost-user claims max_size is max_u64, the users has no way of knowing this 2KB ceiling exists unless they explicitly know the host backend is dpdk and look at its source code.

worth fixing maybe.

Quoted 16 lines
Quoted 16 lines
Quoted 15 lines
Quoted 15 lines
Quoted 5 lines

Maybe we should update the virtio-spec and add a max_akcipher_key_len field for virtio crypto devices.

maybe

Quoted 8 lines

helei (1):
hw/virtio-crypto: enforce max akcipher key length

  hw/virtio/virtio-crypto.c | 13 +++++++++++++
  1 file changed, 13 insertions(+)
Signature · 1 line
2.43.0
author
#10 lore raw
Quoted 67 lines · Michael S. Tsirkin
Quoted 66 lines · helei
Quoted 50 lines · Michael S. Tsirkin
Quoted 40 lines · helei
Quoted 28 lines · Michael S. Tsirkin
Quoted 12 lines · helei
Quoted 9 lines · Michael S. Tsirkin
Quoted 4 lines · helei

The virtio-crypto spec does not dictate a maximum length limit for asymmetric cipher (akcipher) keys. We added a hard limit which mirrors the linux kernels's internal limit for akcipher keys (see keyctl framework and the add_key syscall).

We have max_size - doesn't that apply?
backends/cryptodev-builtin.c actually sets it:
backends/cryptodev-builtin.c:#define CRYPTODEV_BUITLIN_MAX_REQUEST_SIZE (1024 * 1024)
backends/cryptodev-builtin.c: backend->conf.max_size = CRYPTODEV_BUITLIN_MAX_REQUEST_SIZE;

Quoted 4 lines

Thanks for your review!  I have verified via testing that all processing requests in the dataq are strictly

bounded by max_size, but session creation requests in the ctrlq are not.

well if we read the spec it's vague

max_size is defined as "the maximum size of the variable-length parameters of data operation of each crypto request's content." and
The driver SHOULD read max_size to discover the maximum size of the variable-length parameters of data operation of the crypto request's content

Quoted 9 lines

so data operation.

however:

"The device MUST set max_size to show the maximum size of crypto request the device supports".

seems to cover all requests?

Quoted 8 lines

the original architectural intent was almost certainly for max_size to govern data-plane payloads, while control messages are handled by their own independent limits (max_cipher_key_len and max_auth_key_len). both upstream linux guest driver (virtio_crypto_skcipher_algs.c) and qemu's builtin-backend actually implement it exactly this way:
- data path enforces max_size by checking it against payload length (note that cryptodev-builtin recently capped this to 1MB via CVE-2025-14876)
- control path completely ignores max_size when creating sessions

Quoted 5 lines

we can add akcipher key length feature but what to do about existing guests?

could max_size be a way to fix it?

yes, using max_size as a fallback hard limit across all virtqueues(both dataq and ctrlq) is a very good way to close this gap without breaking backward compatibility.
as for existing guests, virtio-crypto spec only defined RSA and ECDSA for asymmetric services. even an excessively large 16384 RSA key is only 2KB, so no well-behaved guest will ever be affected by a 1MB boundary on a session creation request.

Quoted 7 lines
Quoted 3 lines

note that if we take this approach, we should explicitly check both the algorithm-specific limits (max_cipher_key_len/max_auth_key_len) and the global max_size boundary across all session creation requests.

why should we?
one could argue alg specific limits override the max_size.

fine, just leave symmetric-ciphers entirely as-is, and use max_size as the hard ceiling ceiling specifically for akcipher session creations requests. I will update the patch to V2.

Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
Quoted 5 lines
Quoted 5 lines

btw vhost user sets max_size to max u64 - is that sane?

Quoted 11 lines

this is sane for an out-of-process data plane from a transport perspective, but it creates a practical catch when backed by a dpdk implementation:
- in dpdk vhost_crypto.c, vhost_crypto_check_cipher_request() enforces a strict check: src_data_len <= RTE_MBUF_DEFAULT_BUF_SIZE (2176 bytes)
- the guest kernel driver simply wraps the incoming sg list and passes it to virtqueue directly.
this creates a tricky situation for users: because vhost-user claims max_size is max_u64, the users has no way of knowing this 2KB ceiling exists unless they explicitly know the host backend is dpdk and look at its source code.

worth fixing maybe.

Quoted 16 lines
Quoted 16 lines
Quoted 15 lines
Quoted 15 lines
Quoted 5 lines

Maybe we should update the virtio-spec and add a max_akcipher_key_len field for virtio crypto devices.

maybe

Quoted 8 lines

helei (1):
hw/virtio-crypto: enforce max akcipher key length

  hw/virtio/virtio-crypto.c | 13 +++++++++++++
  1 file changed, 13 insertions(+)
Signature · 1 line
2.43.0