xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [XEN PATCH v2] libxl/arm: provide guests with random seed
@ 2021-05-27  8:52 Sergiy Kibrik
  2021-06-03 13:08 ` Julien Grall
  0 siblings, 1 reply; 4+ messages in thread
From: Sergiy Kibrik @ 2021-05-27  8:52 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Wei Liu, Sergiy Kibrik, Julien Grall

Pass 128 bytes of random seed via FDT, so that guests' CRNGs are better seeded
early at boot. This is larger than ChaCha20 key size of 32, so each byte of
CRNG state will be mixed 4 times using this seed. There does not seem to be
advantage in larger seed though.

Depending on its configuration Linux can use the seed as device randomness
or to just quickly initialize CRNG.
In either case this will provide extra randomness to further harden CRNG.

CC: Julien Grall <julien@xen.org>
Signed-off-by: Sergiy Kibrik <Sergiy_Kibrik@epam.com>
---
 tools/libxl/libxl_arm.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c
index 34f8a29056..d3a4a72fb7 100644
--- a/tools/libxl/libxl_arm.c
+++ b/tools/libxl/libxl_arm.c
@@ -304,6 +304,9 @@ static int make_chosen_node(libxl__gc *gc, void *fdt, bool ramdisk,
 {
     int res;
 
+    /* 1024 bit enough to mix Linux CRNG state several times */
+    uint8_t seed[128];
+
     /* See linux Documentation/devicetree/... */
     res = fdt_begin_node(fdt, "chosen");
     if (res) return res;
@@ -342,6 +345,11 @@ static int make_chosen_node(libxl__gc *gc, void *fdt, bool ramdisk,
         if (res) return res;
     }
 
+    res = libxl__random_bytes(gc, seed, sizeof(seed));
+    if (res) return res;
+    res = fdt_property(fdt, "rng-seed", seed, sizeof(seed));
+    if (res) return res;
+
     res = fdt_end_node(fdt);
     if (res) return res;
 
-- 
2.25.1



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

* Re: [XEN PATCH v2] libxl/arm: provide guests with random seed
  2021-05-27  8:52 [XEN PATCH v2] libxl/arm: provide guests with random seed Sergiy Kibrik
@ 2021-06-03 13:08 ` Julien Grall
  2021-06-30 10:12   ` Julien Grall
  0 siblings, 1 reply; 4+ messages in thread
From: Julien Grall @ 2021-06-03 13:08 UTC (permalink / raw)
  To: Sergiy Kibrik, xen-devel; +Cc: Ian Jackson, Wei Liu

Hi,

On 27/05/2021 09:52, Sergiy Kibrik wrote:
> Pass 128 bytes of random seed via FDT, so that guests' CRNGs are better seeded
> early at boot. This is larger than ChaCha20 key size of 32, so each byte of
> CRNG state will be mixed 4 times using this seed. There does not seem to be
> advantage in larger seed though.
> 
> Depending on its configuration Linux can use the seed as device randomness
> or to just quickly initialize CRNG.
> In either case this will provide extra randomness to further harden CRNG.
> 
> CC: Julien Grall <julien@xen.org>
> Signed-off-by: Sergiy Kibrik <Sergiy_Kibrik@epam.com>

Reviewed-by: Julien Grall <jgrall@amazon.com>

Ian, Wei, can we get an ack for this patch?

Cheers,

-- 
Julien Grall


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

* Re: [XEN PATCH v2] libxl/arm: provide guests with random seed
  2021-06-03 13:08 ` Julien Grall
@ 2021-06-30 10:12   ` Julien Grall
  2021-06-30 11:52     ` Sergiy Kibrik
  0 siblings, 1 reply; 4+ messages in thread
From: Julien Grall @ 2021-06-30 10:12 UTC (permalink / raw)
  To: Sergiy Kibrik, xen-devel; +Cc: Ian Jackson, Wei Liu

On 03/06/2021 14:08, Julien Grall wrote:
> Hi,
> 
> On 27/05/2021 09:52, Sergiy Kibrik wrote:
>> Pass 128 bytes of random seed via FDT, so that guests' CRNGs are 
>> better seeded
>> early at boot. This is larger than ChaCha20 key size of 32, so each 
>> byte of
>> CRNG state will be mixed 4 times using this seed. There does not seem 
>> to be
>> advantage in larger seed though.
>>
>> Depending on its configuration Linux can use the seed as device 
>> randomness
>> or to just quickly initialize CRNG.
>> In either case this will provide extra randomness to further harden CRNG.
>>
>> CC: Julien Grall <julien@xen.org>
>> Signed-off-by: Sergiy Kibrik <Sergiy_Kibrik@epam.com>
> 
> Reviewed-by: Julien Grall <jgrall@amazon.com>
> 
> Ian, Wei, can we get an ack for this patch?

This has been sitting on the ML for quite a while. I was going to commit 
it as this looks uncontroversial but the patch doesn't apply on the 
lastest Xen (tools/libxl was moved in tools/libs/light).

@Sergiy, would you be able to rebase the patch?

Cheers,

-- 
Julien Grall


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

* RE: [XEN PATCH v2] libxl/arm: provide guests with random seed
  2021-06-30 10:12   ` Julien Grall
@ 2021-06-30 11:52     ` Sergiy Kibrik
  0 siblings, 0 replies; 4+ messages in thread
From: Sergiy Kibrik @ 2021-06-30 11:52 UTC (permalink / raw)
  To: Julien Grall, xen-devel; +Cc: Ian Jackson, Wei Liu

> On 03/06/2021 14:08, Julien Grall wrote:
[..]
> 
> This has been sitting on the ML for quite a while. I was going to commit it as
> this looks uncontroversial but the patch doesn't apply on the lastest Xen
> (tools/libxl was moved in tools/libs/light).
> 
> @Sergiy, would you be able to rebase the patch?
> 

Sure, I'll post rebased version.

--
Regards,
  Sergiy

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

end of thread, other threads:[~2021-06-30 11:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-27  8:52 [XEN PATCH v2] libxl/arm: provide guests with random seed Sergiy Kibrik
2021-06-03 13:08 ` Julien Grall
2021-06-30 10:12   ` Julien Grall
2021-06-30 11:52     ` Sergiy Kibrik

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).