[PATCH] device/virtio-nsm: Support string data for extendPCR

Dorjoy Chowdhury posted 1 patch 1 year, 3 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20241109123208.24281-1-dorjoychy111@gmail.com
Maintainers: "Michael S. Tsirkin" <mst@redhat.com>, Alexander Graf <graf@amazon.com>, Dorjoy Chowdhury <dorjoychy111@gmail.com>
hw/virtio/virtio-nsm.c | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
[PATCH] device/virtio-nsm: Support string data for extendPCR
Posted by Dorjoy Chowdhury 1 year, 3 months ago
NSM device in AWS Nitro Enclaves supports extending with both
bytestring and string data.

Signed-off-by: Dorjoy Chowdhury <dorjoychy111@gmail.com>
---
 hw/virtio/virtio-nsm.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/hw/virtio/virtio-nsm.c b/hw/virtio/virtio-nsm.c
index a3db8eef3e..6830fcfe17 100644
--- a/hw/virtio/virtio-nsm.c
+++ b/hw/virtio/virtio-nsm.c
@@ -444,7 +444,7 @@ static bool handle_describe_pcr(VirtIONSM *vnsm, struct iovec *request,
  *       key = String("index"),
  *       value = Uint8(pcr),
  *       key = String("data"),
- *       value = Byte_String(data),
+ *       value = Byte_String(data) || String(data),
  *     }
  *   }
  * }
@@ -504,14 +504,21 @@ static enum NSMResponseTypes get_nsm_extend_pcr_req(uint8_t *req, size_t len,
 
         if (cbor_string_length(pair[i].key) == 4 &&
             memcmp(str, "data", 4) == 0) {
-            if (!cbor_isa_bytestring(pair[i].value)) {
+            if (cbor_isa_bytestring(pair[i].value)) {
+                str = cbor_bytestring_handle(pair[i].value);
+                if (!str) {
+                    goto cleanup;
+                }
+                nsm_req->data_len = cbor_bytestring_length(pair[i].value);
+            } else if (cbor_isa_string(pair[i].value)) {
+                str = cbor_string_handle(pair[i].value);
+                if (!str) {
+                    goto cleanup;
+                }
+                nsm_req->data_len = cbor_string_length(pair[i].value);
+            } else {
                 goto cleanup;
             }
-            str = cbor_bytestring_handle(pair[i].value);
-            if (!str) {
-                goto cleanup;
-            }
-            nsm_req->data_len = cbor_bytestring_length(pair[i].value);
             /*
              * nsm_req->data_len will be smaller than NSM_REQUEST_MAX_SIZE as
              * we already check for the max request size before processing
-- 
2.39.5
Re: [PATCH] device/virtio-nsm: Support string data for extendPCR
Posted by Philippe Mathieu-Daudé 1 year, 1 month ago
On 9/11/24 13:32, Dorjoy Chowdhury wrote:
> NSM device in AWS Nitro Enclaves supports extending with both
> bytestring and string data.
> 
> Signed-off-by: Dorjoy Chowdhury <dorjoychy111@gmail.com>
> ---
>   hw/virtio/virtio-nsm.c | 21 ++++++++++++++-------
>   1 file changed, 14 insertions(+), 7 deletions(-)

Queued, thanks!
Re: [PATCH] device/virtio-nsm: Support string data for extendPCR
Posted by Alexander Graf 1 year, 2 months ago
On 09.11.24 13:32, Dorjoy Chowdhury wrote:
> NSM device in AWS Nitro Enclaves supports extending with both
> bytestring and string data.
>
> Signed-off-by: Dorjoy Chowdhury <dorjoychy111@gmail.com>


Reviewed-by: Alexander Graf <graf@amazon.com>

Alex


> ---
>   hw/virtio/virtio-nsm.c | 21 ++++++++++++++-------
>   1 file changed, 14 insertions(+), 7 deletions(-)
>
> diff --git a/hw/virtio/virtio-nsm.c b/hw/virtio/virtio-nsm.c
> index a3db8eef3e..6830fcfe17 100644
> --- a/hw/virtio/virtio-nsm.c
> +++ b/hw/virtio/virtio-nsm.c
> @@ -444,7 +444,7 @@ static bool handle_describe_pcr(VirtIONSM *vnsm, struct iovec *request,
>    *       key = String("index"),
>    *       value = Uint8(pcr),
>    *       key = String("data"),
> - *       value = Byte_String(data),
> + *       value = Byte_String(data) || String(data),
>    *     }
>    *   }
>    * }
> @@ -504,14 +504,21 @@ static enum NSMResponseTypes get_nsm_extend_pcr_req(uint8_t *req, size_t len,
>
>           if (cbor_string_length(pair[i].key) == 4 &&
>               memcmp(str, "data", 4) == 0) {
> -            if (!cbor_isa_bytestring(pair[i].value)) {
> +            if (cbor_isa_bytestring(pair[i].value)) {
> +                str = cbor_bytestring_handle(pair[i].value);
> +                if (!str) {
> +                    goto cleanup;
> +                }
> +                nsm_req->data_len = cbor_bytestring_length(pair[i].value);
> +            } else if (cbor_isa_string(pair[i].value)) {
> +                str = cbor_string_handle(pair[i].value);
> +                if (!str) {
> +                    goto cleanup;
> +                }
> +                nsm_req->data_len = cbor_string_length(pair[i].value);
> +            } else {
>                   goto cleanup;
>               }
> -            str = cbor_bytestring_handle(pair[i].value);
> -            if (!str) {
> -                goto cleanup;
> -            }
> -            nsm_req->data_len = cbor_bytestring_length(pair[i].value);
>               /*
>                * nsm_req->data_len will be smaller than NSM_REQUEST_MAX_SIZE as
>                * we already check for the max request size before processing
> --
> 2.39.5
>



Amazon Web Services Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss
Eingetragen am Amtsgericht Charlottenburg unter HRB 257764 B
Sitz: Berlin
Ust-ID: DE 365 538 597
Re: [PATCH] device/virtio-nsm: Support string data for extendPCR
Posted by Dorjoy Chowdhury 1 year, 2 months ago
On Mon, Dec 2, 2024 at 9:37 PM Alexander Graf <graf@amazon.com> wrote:
>
>
> On 09.11.24 13:32, Dorjoy Chowdhury wrote:
> > NSM device in AWS Nitro Enclaves supports extending with both
> > bytestring and string data.
> >
> > Signed-off-by: Dorjoy Chowdhury <dorjoychy111@gmail.com>
>
>
> Reviewed-by: Alexander Graf <graf@amazon.com>
>

cc Paolo. This has been reviewed as well so can be picked up for
merging. Thanks!

Regards,
Dorjoy
Re: [PATCH] device/virtio-nsm: Support string data for extendPCR
Posted by Alexander Graf 1 year, 2 months ago
Hey Dorjoy,

Thanks a lot for the patch! Would you mind to send to the ML so it can 
go through the normal review + apply cycle? :)

Same comment for the other patches.

Alex

On 09.11.24 13:32, Dorjoy Chowdhury wrote:
>
> NSM device in AWS Nitro Enclaves supports extending with both
> bytestring and string data.
>
> Signed-off-by: Dorjoy Chowdhury <dorjoychy111@gmail.com>
> ---
>   hw/virtio/virtio-nsm.c | 21 ++++++++++++++-------
>   1 file changed, 14 insertions(+), 7 deletions(-)
>
> diff --git a/hw/virtio/virtio-nsm.c b/hw/virtio/virtio-nsm.c
> index a3db8eef3e..6830fcfe17 100644
> --- a/hw/virtio/virtio-nsm.c
> +++ b/hw/virtio/virtio-nsm.c
> @@ -444,7 +444,7 @@ static bool handle_describe_pcr(VirtIONSM *vnsm, struct iovec *request,
>    *       key = String("index"),
>    *       value = Uint8(pcr),
>    *       key = String("data"),
> - *       value = Byte_String(data),
> + *       value = Byte_String(data) || String(data),
>    *     }
>    *   }
>    * }
> @@ -504,14 +504,21 @@ static enum NSMResponseTypes get_nsm_extend_pcr_req(uint8_t *req, size_t len,
>
>           if (cbor_string_length(pair[i].key) == 4 &&
>               memcmp(str, "data", 4) == 0) {
> -            if (!cbor_isa_bytestring(pair[i].value)) {
> +            if (cbor_isa_bytestring(pair[i].value)) {
> +                str = cbor_bytestring_handle(pair[i].value);
> +                if (!str) {
> +                    goto cleanup;
> +                }
> +                nsm_req->data_len = cbor_bytestring_length(pair[i].value);
> +            } else if (cbor_isa_string(pair[i].value)) {
> +                str = cbor_string_handle(pair[i].value);
> +                if (!str) {
> +                    goto cleanup;
> +                }
> +                nsm_req->data_len = cbor_string_length(pair[i].value);
> +            } else {
>                   goto cleanup;
>               }
> -            str = cbor_bytestring_handle(pair[i].value);
> -            if (!str) {
> -                goto cleanup;
> -            }
> -            nsm_req->data_len = cbor_bytestring_length(pair[i].value);
>               /*
>                * nsm_req->data_len will be smaller than NSM_REQUEST_MAX_SIZE as
>                * we already check for the max request size before processing
> --
> 2.39.5
>



Amazon Web Services Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss
Eingetragen am Amtsgericht Charlottenburg unter HRB 257764 B
Sitz: Berlin
Ust-ID: DE 365 538 597
Re: [PATCH] device/virtio-nsm: Support string data for extendPCR
Posted by Dorjoy Chowdhury 1 year, 2 months ago
Hey Alex,


On Tue, Nov 12, 2024, 6:14 PM Alexander Graf <graf@amazon.com> wrote:

> Hey Dorjoy,
>
> Thanks a lot for the patch! Would you mind to send to the ML so it can
> go through the normal review + apply cycle? :)
>
> Same comment for the other patches.
>


I don't understand. I sent them to the mailing list too, no? I see the cc's
on the patches.

Regards,
Dorjoy

>
Re: [PATCH] device/virtio-nsm: Support string data for extendPCR
Posted by Alexander Graf 1 year, 2 months ago
Hey Dorjoy,

On 12.11.24 13:32, Dorjoy Chowdhury wrote:

> Hey Alex,
>
>
> On Tue, Nov 12, 2024, 6:14 PM Alexander Graf <graf@amazon.com> wrote:
>
>     Hey Dorjoy,
>
>     Thanks a lot for the patch! Would you mind to send to the ML so it
>     can
>     go through the normal review + apply cycle? :)
>
>     Same comment for the other patches.
>
>
>
> I don't understand. I sent them to the mailing list too, no? I see the 
> cc's on the patches.


You did indeed - I'm just blind :). Let me have another look at the 
actual contents of the patches!


Alex



Amazon Web Services Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss
Eingetragen am Amtsgericht Charlottenburg unter HRB 257764 B
Sitz: Berlin
Ust-ID: DE 365 538 597
Re: [PATCH] device/virtio-nsm: Support string data for extendPCR
Posted by Dorjoy Chowdhury 1 year, 2 months ago
Ping.

This is a small one that needs review.

Regards,
Dorjoy
Re: [PATCH] device/virtio-nsm: Support string data for extendPCR
Posted by Dorjoy Chowdhury 1 year, 2 months ago
On Mon, Nov 18, 2024 at 7:12 PM Dorjoy Chowdhury <dorjoychy111@gmail.com> wrote:
>
> Ping.
>

Ping...
This is a small one that can be reviewed and picked up for merging. Thanks!

Regards,
Dorjoy
Re: [PATCH] device/virtio-nsm: Support string data for extendPCR
Posted by Dorjoy Chowdhury 1 year, 2 months ago
On Mon, Nov 25, 2024 at 9:00 PM Dorjoy Chowdhury <dorjoychy111@gmail.com> wrote:
>
> On Mon, Nov 18, 2024 at 7:12 PM Dorjoy Chowdhury <dorjoychy111@gmail.com> wrote:
> >
> > Ping.
> >
>
> Ping...
> This is a small one that can be reviewed and picked up for merging. Thanks!
>

Gentle ping.

Regards,
Dorjoy