Patchwork of: Feed entire flattened device tree into the random pool

login
register
mail settings
Submitter Anton Blanchard
Date July 29, 2013, 3:11 a.m.
Message ID <20130729131150.591926c3@kryten>
Download mbox | patch
Permalink /patch/262650/
State Not Applicable
Headers show

Comments

Anton Blanchard - July 29, 2013, 3:11 a.m.
Hi,

> be32_to_cpu(initial_boot_params->totalsize);

Ouch, thanks Grant.

Anton
--

We feed the entire DMI table into the random pool to provide
better random data during early boot, so do the same with the
flattened device tree.

Signed-off-by: Anton Blanchard <anton@samba.org>
---

v3: Fix endian issues as noted by Grant
Grant Likely - Aug. 29, 2013, 8:47 p.m.
On Mon, 29 Jul 2013 13:11:50 +1000, Anton Blanchard <anton@samba.org> wrote:
> 
> Hi,
> 
> > be32_to_cpu(initial_boot_params->totalsize);
> 
> Ouch, thanks Grant.
> 
> Anton
> --
> 
> We feed the entire DMI table into the random pool to provide
> better random data during early boot, so do the same with the
> flattened device tree.
> 
> Signed-off-by: Anton Blanchard <anton@samba.org>

Applied, thanks

g.

Patch

Index: b/drivers/of/fdt.c
===================================================================
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -17,6 +17,7 @@ 
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/slab.h>
+#include <linux/random.h>
 
 #include <asm/setup.h>  /* for COMMAND_LINE_SIZE */
 #ifdef CONFIG_PPC
@@ -714,3 +715,14 @@  void __init unflatten_device_tree(void)
 }
 
 #endif /* CONFIG_OF_EARLY_FLATTREE */
+
+/* Feed entire flattened device tree into the random pool */
+static int __init add_fdt_randomness(void)
+{
+	if (initial_boot_params)
+		add_device_randomness(initial_boot_params,
+				be32_to_cpu(initial_boot_params->totalsize));
+
+	return 0;
+}
+core_initcall(add_fdt_randomness);