* [PATCH 0/2] virtio-crypto: two easy fixes
@ 2026-12-04 11:39 Peter Maydell
2026-12-04 11:39 ` [PATCH 1/2] hw/virtio/virtio-crypto: Validate control request queue ID Peter Maydell
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Peter Maydell @ 2026-12-04 11:39 UTC (permalink / raw)
To: qemu-devel; +Cc: Gonglei (Arei), zhenwei pi, Michael S. Tsirkin
We've decided to mark virtio-crypto as outside the security support
umbrella, but before I realized that I did two fixes for easy issues
that have been in the bug tracking system for several months,
so I figured I might as well send them. These are both "virtio-crypto
doesn't sanity check arguments from the guest and so a bogus value
can make it crash or assert".
thanks
-- PMM
Peter Maydell (2):
hw/virtio/virtio-crypto: Validate control request queue ID
backends/cryptodev-lkcf: Return error for close of invalid session
backends/cryptodev-lkcf.c | 5 ++++-
hw/virtio/virtio-crypto.c | 16 ++++++++++++++++
2 files changed, 20 insertions(+), 1 deletion(-)
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] hw/virtio/virtio-crypto: Validate control request queue ID
2026-12-04 11:39 [PATCH 0/2] virtio-crypto: two easy fixes Peter Maydell
@ 2026-12-04 11:39 ` Peter Maydell
2026-12-04 12:20 ` Philippe Mathieu-Daudé
2026-12-04 11:39 ` [PATCH 2/2] backends/cryptodev-lkcf: Return error for close of invalid session Peter Maydell
2026-12-04 15:44 ` [PATCH 0/2] virtio-crypto: two easy fixes Michael S. Tsirkin
2 siblings, 1 reply; 6+ messages in thread
From: Peter Maydell @ 2026-12-04 11:39 UTC (permalink / raw)
To: qemu-devel; +Cc: Gonglei (Arei), zhenwei pi, Michael S. Tsirkin
The virtio-crypto device processes control requests which include
a queue ID from the guest. We weren't validating this to be in
range, but simply passing it down to the backend, which might
crash or assert. Check the queue ID is in range, and fail the
operation if it is not.
Cc: qemu-stable@nongnu.org
Fixes: 59c360ca42121e6f ("virtio-crypto: add control queue handler")
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3625
Reported-by: huntr bubble <https://gitlab.com/bubblehuntr>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
hw/virtio/virtio-crypto.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c
index 51a99a6cf6e..9b0acc6f4f1 100644
--- a/hw/virtio/virtio-crypto.c
+++ b/hw/virtio/virtio-crypto.c
@@ -356,6 +356,7 @@ static void virtio_crypto_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
int ret;
struct iovec *out_iov;
struct iovec *in_iov;
+ uint32_t queues = vcrypto->multiqueue ? vcrypto->max_queues : 1;
for (;;) {
g_autofree struct iovec *out_iov_copy = NULL;
@@ -397,6 +398,11 @@ static void virtio_crypto_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
switch (opcode) {
case VIRTIO_CRYPTO_CIPHER_CREATE_SESSION:
+ if (queue_id >= queues) {
+ virtio_crypto_create_session_completion(sreq,
+ VIRTIO_CRYPTO_ERR);
+ break;
+ }
sreq->cb = virtio_crypto_create_session_completion;
ret = virtio_crypto_create_sym_session(vcrypto,
&ctrl.u.sym_create_session,
@@ -409,6 +415,11 @@ static void virtio_crypto_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
break;
case VIRTIO_CRYPTO_AKCIPHER_CREATE_SESSION:
+ if (queue_id >= queues) {
+ virtio_crypto_create_session_completion(sreq,
+ VIRTIO_CRYPTO_ERR);
+ break;
+ }
sreq->cb = virtio_crypto_create_session_completion;
ret = virtio_crypto_create_asym_session(vcrypto,
&ctrl.u.akcipher_create_session,
@@ -425,6 +436,11 @@ static void virtio_crypto_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
case VIRTIO_CRYPTO_MAC_DESTROY_SESSION:
case VIRTIO_CRYPTO_AEAD_DESTROY_SESSION:
case VIRTIO_CRYPTO_AKCIPHER_DESTROY_SESSION:
+ if (queue_id >= queues) {
+ virtio_crypto_destroy_session_completion(sreq,
+ VIRTIO_CRYPTO_ERR);
+ break;
+ }
sreq->cb = virtio_crypto_destroy_session_completion;
ret = virtio_crypto_handle_close_session(vcrypto,
&ctrl.u.destroy_session, queue_id,
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] backends/cryptodev-lkcf: Return error for close of invalid session
2026-12-04 11:39 [PATCH 0/2] virtio-crypto: two easy fixes Peter Maydell
2026-12-04 11:39 ` [PATCH 1/2] hw/virtio/virtio-crypto: Validate control request queue ID Peter Maydell
@ 2026-12-04 11:39 ` Peter Maydell
2026-12-04 15:44 ` [PATCH 0/2] virtio-crypto: two easy fixes Michael S. Tsirkin
2 siblings, 0 replies; 6+ messages in thread
From: Peter Maydell @ 2026-12-04 11:39 UTC (permalink / raw)
To: qemu-devel; +Cc: Gonglei (Arei), zhenwei pi, Michael S. Tsirkin
cryptodev_lkcf_close_session() asserts that the session ID it is
passed is valid, but this is a value from the guest, so we can't
assume that. Instead we should treat an invalid session value as an
error; return -VIRTIO_CRYPTO_INVSESS for this, as
cryptodev_builtin_close_session() does.
Cc: qemu-stable@nongnu.org
Fixes: 39fff6f3e8b3d ("cryptodev: Add a lkcf-backend for cryptodev")
Reported-by: huntr bubble <https://gitlab.com/bubblehuntr>
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3624
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
backends/cryptodev-lkcf.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/backends/cryptodev-lkcf.c b/backends/cryptodev-lkcf.c
index 3fe29d3104c..407204344b8 100644
--- a/backends/cryptodev-lkcf.c
+++ b/backends/cryptodev-lkcf.c
@@ -609,7 +609,10 @@ static int cryptodev_lkcf_close_session(CryptoDevBackend *backend,
CryptoDevBackendLKCF *lkcf = CRYPTODEV_BACKEND_LKCF(backend);
CryptoDevBackendLKCFSession *session;
- assert(session_id < MAX_SESSIONS && lkcf->sess[session_id]);
+ if (session_id >= MAX_SESSIONS || !lkcf->sess[session_id]) {
+ return -VIRTIO_CRYPTO_INVSESS;
+ }
+
session = lkcf->sess[session_id];
lkcf->sess[session_id] = NULL;
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] hw/virtio/virtio-crypto: Validate control request queue ID
2026-12-04 11:39 ` [PATCH 1/2] hw/virtio/virtio-crypto: Validate control request queue ID Peter Maydell
@ 2026-12-04 12:20 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-12-04 12:20 UTC (permalink / raw)
To: Peter Maydell, qemu-devel; +Cc: Gonglei (Arei), zhenwei pi, Michael S. Tsirkin
On 4/12/26 12:39, Peter Maydell wrote:
> The virtio-crypto device processes control requests which include
> a queue ID from the guest. We weren't validating this to be in
> range, but simply passing it down to the backend, which might
> crash or assert. Check the queue ID is in range, and fail the
> operation if it is not.
>
> Cc: qemu-stable@nongnu.org
> Fixes: 59c360ca42121e6f ("virtio-crypto: add control queue handler")
> Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3625
> Reported-by: huntr bubble <https://gitlab.com/bubblehuntr>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> hw/virtio/virtio-crypto.c | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/2] virtio-crypto: two easy fixes
2026-12-04 11:39 [PATCH 0/2] virtio-crypto: two easy fixes Peter Maydell
2026-12-04 11:39 ` [PATCH 1/2] hw/virtio/virtio-crypto: Validate control request queue ID Peter Maydell
2026-12-04 11:39 ` [PATCH 2/2] backends/cryptodev-lkcf: Return error for close of invalid session Peter Maydell
@ 2026-12-04 15:44 ` Michael S. Tsirkin
2026-12-04 16:04 ` Peter Maydell
2 siblings, 1 reply; 6+ messages in thread
From: Michael S. Tsirkin @ 2026-12-04 15:44 UTC (permalink / raw)
To: Peter Maydell; +Cc: qemu-devel, Gonglei (Arei), zhenwei pi
On Fri, Dec 04, 2026 at 11:39:22AM +0000, Peter Maydell wrote:
> We've decided to mark virtio-crypto as outside the security support
> umbrella, but before I realized that I did two fixes for easy issues
> that have been in the bug tracking system for several months,
> so I figured I might as well send them. These are both "virtio-crypto
> doesn't sanity check arguments from the guest and so a bogus value
> can make it crash or assert".
>
> thanks
> -- PMM
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
do you want to merge them now? or after release through
my tree? I didn't plan another pull.
> Peter Maydell (2):
> hw/virtio/virtio-crypto: Validate control request queue ID
> backends/cryptodev-lkcf: Return error for close of invalid session
>
> backends/cryptodev-lkcf.c | 5 ++++-
> hw/virtio/virtio-crypto.c | 16 ++++++++++++++++
> 2 files changed, 20 insertions(+), 1 deletion(-)
>
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/2] virtio-crypto: two easy fixes
2026-12-04 15:44 ` [PATCH 0/2] virtio-crypto: two easy fixes Michael S. Tsirkin
@ 2026-12-04 16:04 ` Peter Maydell
0 siblings, 0 replies; 6+ messages in thread
From: Peter Maydell @ 2026-12-04 16:04 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: qemu-devel, Gonglei (Arei), zhenwei pi
On Fri, 4 Dec 2026 at 15:44, Michael S. Tsirkin <mst@redhat.com> wrote:
>
> On Fri, Dec 04, 2026 at 11:39:22AM +0000, Peter Maydell wrote:
> > We've decided to mark virtio-crypto as outside the security support
> > umbrella, but before I realized that I did two fixes for easy issues
> > that have been in the bug tracking system for several months,
> > so I figured I might as well send them. These are both "virtio-crypto
> > doesn't sanity check arguments from the guest and so a bogus value
> > can make it crash or assert".
> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
>
>
> do you want to merge them now? or after release through
> my tree? I didn't plan another pull.
I don't think there's a huge hurry here, and these aren't
so important that we need to rush them into 11.2, so let's
just wait for 12.0.
thanks
-- PMM
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-12-04 16:05 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 11:39 [PATCH 0/2] virtio-crypto: two easy fixes Peter Maydell
2026-12-04 11:39 ` [PATCH 1/2] hw/virtio/virtio-crypto: Validate control request queue ID Peter Maydell
2026-12-04 12:20 ` Philippe Mathieu-Daudé
2026-12-04 11:39 ` [PATCH 2/2] backends/cryptodev-lkcf: Return error for close of invalid session Peter Maydell
2026-12-04 15:44 ` [PATCH 0/2] virtio-crypto: two easy fixes Michael S. Tsirkin
2026-12-04 16:04 ` Peter Maydell
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.