Skip to contentSkip to conversation

systemd: Ensure uid/gid ranges are set deterministically

PATCH New Richard Purdie 1 participant 3 messages Dec 19, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 systemd: Ensure uid/gid ranges are set deterministically

meson.build will fall back to greping /etc/login.defs for values of these if they're not set. Different distros set them (Centos 7/8 does, Ubuntu does not) so output was not deterministic. Avoid this by setting to the default values. We now match the vaules from login.defs from shadow.

---
 meta/recipes-core/systemd/systemd_247.2.bb | 4 ++++
 1 file changed, 4 insertions(+)
meta/recipes-core/systemd/systemd_247.2.bb +4 -0
index 15f8cb3d718..5eea78eff35 100644
@@ -213,6 +213,10 @@ EXTRA_OEMESON += "-Dnobody-user=nobody \
                   -Drootprefix=${rootprefix} \
                   -Ddefault-locale=C \
                   -Dmode=release \
+                  -Dsystem-alloc-uid-min=101 \
+                  -Dsystem-uid-max=999 \
+                  -Dsystem-alloc-gid-min=101 \
+                  -Dsystem-gid-max=999 \
                   "
 
 # Hardcode target binary paths to avoid using paths from sysroot
Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/3 linuxloader: Avoid confusing string concat errors

None is a bad choice of return value for functions used in variables (strings) as a failure results in concatination errors. Use a string with a clear meaning that can be searched for instead.

---
 meta/classes/linuxloader.bbclass | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
meta/classes/linuxloader.bbclass +3 -3
index 720e5dfad4c..b161c51a50d 100644
@@ -1,6 +1,6 @@
 def get_musl_loader_arch(d):
     import re
-    ldso_arch = None
+    ldso_arch = "NotSupported"
 
     targetarch = d.getVar("TARGET_ARCH")
     if targetarch.startswith("microblaze"):
@@ -32,7 +32,7 @@ def get_musl_loader(d):
 def get_glibc_loader(d):
     import re
 
-    dynamic_loader = None
+    dynamic_loader = "NotSupported"
     targetarch = d.getVar("TARGET_ARCH")
     if targetarch in ["powerpc", "microblaze"]:
         dynamic_loader = "${base_libdir}/ld.so.1"
@@ -58,7 +58,7 @@ def get_linuxloader(d):
     overrides = d.getVar("OVERRIDES").split(":")
 
     if "libc-baremetal" in overrides:
-        return None
+        return "NotSupported"
 
     if "libc-musl" in overrides:
         dynamic_loader = get_musl_loader(d)
Signature · 1 line
2.25.1
#2 lore raw

PATCH 3/3 grub: Fix build reproducibility issue

In reply to Richard Purdie

We're seeing reproducibility issue on the autobuilder due to changing module dependency ordering. Add some sorting to an awk script to fix this.

---
 meta/recipes-bsp/grub/files/determinism.patch | 24 +++++++++++++++++++
 meta/recipes-bsp/grub/grub2.inc               |  1 +
 2 files changed, 25 insertions(+)
 create mode 100644 meta/recipes-bsp/grub/files/determinism.patch
meta/recipes-bsp/grub/files/determinism.patch new file +24 -0
new file mode 100644
index 00000000000..c4b1d3a2a8d
@@ -0,0 +1,24 @@
+The output in moddep.lst generated from syminfo.lst using genmoddep.awk is
+not deterministic since the order of the dependencies on each line can vary
+depending on how awk sorts the values in the array.
+
+Be deterministic in the output by sorting the dependencies on each line.
+
+Upstream-Status: Pending
+Richard Purdie <[email protected]>
+
+Index: grub-2.04/grub-core/genmoddep.awk
+===================================================================
+--- grub-2.04.orig/grub-core/genmoddep.awk
++++ grub-2.04/grub-core/genmoddep.awk
+@@ -59,7 +59,9 @@ END {
+     }
+     modlist = ""
+     depcount[mod] = 0
+-    for (depmod in uniqmods) {
++    n = asorti(uniqmods, w)
++    for (i = 1; i <= n; i++) {
++      depmod = w[i]
+       modlist = modlist " " depmod;
+       inverse_dependencies[depmod] = inverse_dependencies[depmod] " " mod
+       depcount[mod]++
meta/recipes-bsp/grub/grub2.inc +1 -0
index d0201036058..49c869b5dc5 100644
@@ -27,6 +27,7 @@ SRC_URI = "${GNU_MIRROR}/grub/grub-${PV}.tar.gz \
            file://script-Remove-unused-fields-from-grub_script_functio.patch \
            file://CVE-2020-15706-script-Avoid-a-use-after-free-when-redefining-a-func.patch \
            file://CVE-2020-15707-linux-Fix-integer-overflows-in-initrd-size-handling.patch \
+           file://determinism.patch \
 "
 SRC_URI[md5sum] = "5ce674ca6b2612d8939b9e6abed32934"
 SRC_URI[sha256sum] = "f10c85ae3e204dbaec39ae22fa3c5e99f0665417e91c2cb49b7e5031658ba6ea"
Signature · 1 line
2.25.1