On 13/2/25 12:45, Alexander Graf wrote:
When we return a response packet from NSM, we need to indicate its
length according to the content of the response. Prior to this patch, we
returned the length of the source buffer, which may confuse guest code
that relies on the response size.

Fix it by returning the response payload size instead.

Fixes: bb154e3e0cc715 ("device/virtio-nsm: Support for Nitro Secure Module 
device")
Reported-by: Vikrant Garg <vikrant1g...@gmail.com>
Signed-off-by: Alexander Graf <g...@amazon.com>
---
  hw/virtio/virtio-nsm.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/virtio/virtio-nsm.c b/hw/virtio/virtio-nsm.c
index 098e1aeac6..b22aa74e34 100644
--- a/hw/virtio/virtio-nsm.c
+++ b/hw/virtio/virtio-nsm.c
@@ -1596,7 +1596,7 @@ static void handle_input(VirtIODevice *vdev, VirtQueue 
*vq)
      g_free(req.iov_base);
      g_free(res.iov_base);
      virtqueue_push(vq, out_elem, 0);
-    virtqueue_push(vq, in_elem, in_elem->in_sg->iov_len);
+    virtqueue_push(vq, in_elem, sz);
      virtio_notify(vdev, vq);
      return;

Reviewed-by: Philippe Mathieu-Daudé <phi...@linaro.org>

and per https://lore.kernel.org/qemu-devel/CAKXOwk2Eba8qnqKQqCN+=2+N=wrpzawx3lkoccewr-3xgt3...@mail.gmail.com/:
Tested-by: Vikrant Garg <vikrant1g...@gmail.com>

Reply via email to