qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hw/virtio/virtio-nsm: Respond with correct length
@ 2025-02-13 11:45 Alexander Graf
  2025-02-13 11:50 ` Dorjoy Chowdhury
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Alexander Graf @ 2025-02-13 11:45 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, Dorjoy Chowdhury, Vikrant Garg, qemu-stable

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 <vikrant1garg@gmail.com>
Signed-off-by: Alexander Graf <graf@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;
 
-- 
2.47.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] hw/virtio/virtio-nsm: Respond with correct length
  2025-02-13 11:45 [PATCH] hw/virtio/virtio-nsm: Respond with correct length Alexander Graf
@ 2025-02-13 11:50 ` Dorjoy Chowdhury
  2025-02-13 15:24 ` Philippe Mathieu-Daudé
  2025-02-25  9:32 ` Michael Tokarev
  2 siblings, 0 replies; 5+ messages in thread
From: Dorjoy Chowdhury @ 2025-02-13 11:50 UTC (permalink / raw)
  To: Alexander Graf; +Cc: qemu-devel, Michael S. Tsirkin, Vikrant Garg, qemu-stable

[-- Attachment #1: Type: text/plain, Size: 760 bytes --]

On Thu, Feb 13, 2025, 5:45 PM Alexander Graf <graf@amazon.com> 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 <vikrant1garg@gmail.com>
> Signed-off-by: Alexander Graf <graf@amazon.com>
> ---
>  hw/virtio/virtio-nsm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>


Reviewed-by: Dorjoy Chowdhury <dorjoychy111@gmail.com>

Thanks for fixing!

Regards,
dorjoy

[-- Attachment #2: Type: text/html, Size: 1498 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] hw/virtio/virtio-nsm: Respond with correct length
  2025-02-13 11:45 [PATCH] hw/virtio/virtio-nsm: Respond with correct length Alexander Graf
  2025-02-13 11:50 ` Dorjoy Chowdhury
@ 2025-02-13 15:24 ` Philippe Mathieu-Daudé
  2025-02-25  9:32 ` Michael Tokarev
  2 siblings, 0 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-02-13 15:24 UTC (permalink / raw)
  To: Alexander Graf, qemu-devel
  Cc: mst, Dorjoy Chowdhury, Vikrant Garg, qemu-stable

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 <vikrant1garg@gmail.com>
> Signed-off-by: Alexander Graf <graf@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é <philmd@linaro.org>

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] hw/virtio/virtio-nsm: Respond with correct length
  2025-02-13 11:45 [PATCH] hw/virtio/virtio-nsm: Respond with correct length Alexander Graf
  2025-02-13 11:50 ` Dorjoy Chowdhury
  2025-02-13 15:24 ` Philippe Mathieu-Daudé
@ 2025-02-25  9:32 ` Michael Tokarev
  2025-02-25  9:34   ` Michael Tokarev
  2 siblings, 1 reply; 5+ messages in thread
From: Michael Tokarev @ 2025-02-25  9:32 UTC (permalink / raw)
  To: Alexander Graf, qemu-devel
  Cc: mst, Dorjoy Chowdhury, Vikrant Garg, qemu-stable

13.02.2025 14: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 <vikrant1garg@gmail.com>
> Signed-off-by: Alexander Graf <graf@amazon.com>

This looks like qemu-stable material (9.2.x).
Please let me know if it is not.

Thanks,

/mjt


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] hw/virtio/virtio-nsm: Respond with correct length
  2025-02-25  9:32 ` Michael Tokarev
@ 2025-02-25  9:34   ` Michael Tokarev
  0 siblings, 0 replies; 5+ messages in thread
From: Michael Tokarev @ 2025-02-25  9:34 UTC (permalink / raw)
  To: Alexander Graf, qemu-devel
  Cc: mst, Dorjoy Chowdhury, Vikrant Garg, qemu-stable

25.02.2025 12:32, Michael Tokarev wrote:

> This looks like qemu-stable material (9.2.x).

Ah, it is already Cc'd to qemu-stable@, -- n/m.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-02-25  9:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-13 11:45 [PATCH] hw/virtio/virtio-nsm: Respond with correct length Alexander Graf
2025-02-13 11:50 ` Dorjoy Chowdhury
2025-02-13 15:24 ` Philippe Mathieu-Daudé
2025-02-25  9:32 ` Michael Tokarev
2025-02-25  9:34   ` Michael Tokarev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).