[Buildroot] [git commit] utils/genrandconfig: use high quality random for KCONFIG_SEED

Arnout Vandecappelle (Essensium/Mind) arnout at mind.be
Tue May 3 20:20:18 UTC 2022


commit: https://git.buildroot.net/buildroot/commit/?id=fe740dcac8b065e4d52674b84cd3ff4e65959442
branch: https://git.buildroot.net/buildroot/commit/?id=refs/heads/master

Internally genrandconfig will use gettimeofday when generating a
KCONFIG_SEED, since autobuild-run executes genrandconfig at the same
time for multiple autobuilder runners this could potentially result
in the same KCONFIG_SEED being generated for those test runs started
at the same time.

To ensure this doesn't happen set the KCONFIG_SEED using the urandom
entropy source.

Signed-off-by: James Hilliard <james.hilliard1 at gmail.com>
Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout at mind.be>
---
 utils/genrandconfig | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/utils/genrandconfig b/utils/genrandconfig
index 70af84f002..8ed2783a6d 100755
--- a/utils/genrandconfig
+++ b/utils/genrandconfig
@@ -18,6 +18,7 @@
 
 # This script generates a random configuration for testing Buildroot.
 
+from binascii import hexlify
 import contextlib
 import csv
 import os
@@ -605,9 +606,13 @@ def gen_config(args):
                   file=sys.stderr)
             return 1
         bounded_loop -= 1
-        subprocess.check_call(["make", "O=%s" % args.outputdir, "-C", args.buildrootdir,
-                               "KCONFIG_PROBABILITY=%d" % randint(1, 20),
-                               "randpackageconfig" if args.toolchains_csv else "randconfig"])
+        make_rand = [
+            "make", "O=%s" % args.outputdir, "-C", args.buildrootdir,
+            "KCONFIG_SEED=0x%s" % hexlify(os.urandom(4)).decode("ascii").upper(),
+            "KCONFIG_PROBABILITY=%d" % randint(1, 20),
+            "randpackageconfig" if args.toolchains_csv else "randconfig"
+        ]
+        subprocess.check_call(make_rand)
 
         if fixup_config(sysinfo, configfile):
             break



More information about the buildroot mailing list