tl;dr: fontconfig tries to regenerate .uuid files with getrandom (via
libuuid) in early boot, which hangs because of low pool entropy; the
plymouth fix is to copy the .uuid files into the initramfs with the
DejaVu fonts.
Patch attached for "git am" convenience (and emailed directly for
discussion).
Until plymouth is fixed, users can manually apply these changes to
/usr/share/initramfs-tools/hooks/plymouth and then run "update-initramfs
-u" to fix plymouth with a 4.16 kernel.
Epic version:
This investigation required installing ltrace and libelf in the
initramfs (by modifying the plymouth hook), modifying init-premount to
run "ltrace -n4 -tt -S -f" (in the background) on plymouthd, and booting
with debug on the command line to get /run/initramfs/initramsfs.log.
genrandom is a syscall so appears as SYS_318 on amd64. The hang occurs
with the first call of SYS_318 with flags=0. Context implicates
fontconfig generation of .uuid files.
The dependency is not in plymouth itself but in plymouth-label:
/usr/lib/x86_64-linux-gnu/plymouth/label.so
One dependency is:
/lib/x86_64-linux-gnu/libuuid.so.1
The only thing to use uuid_* symbols is:
/usr/lib/x86_64-linux-gnu/libfontconfig.so.1
The use of uuid_generate_random can be found in the fontconfig and
libuuid/util-linux sources.
fontconfig tries to regenerate .uuid files here:
https://cgit.freedesktop.org/fontconfig/tree/src/fccache.c?h=2.13.0#n94
libuuid uuid_generate_random calls util-linux random_get_bytes:
https://salsa.debian.org/debian/util-linux/blob/master/libuuid/src/gen_uuid.c#L430
util-linux randutils random_get_bytes calls getrandom with flags=0
(blocking), which hangs when pool entropy is low:
https://salsa.debian.org/debian/util-linux/blob/master/lib/randutils.c#L89
The fix for plymouth is to avoid ".uuid" file regeneration by copying
them into the initramfs with the DejaVu fonts. There are two notable
consequences beyond plymouth:
- Anything else triggering fontconfig .uuid file regeneration in early
boot will also hang.
- Anything else calling libuuid uuid_generate_random or util-linux
randutils random_get_bytes in early boot will also hang.
Kind regards,
--
Ben Caradoc-Davies <b...@transient.nz>
Director
Transient Software Limited <https://transient.nz/>
New Zealand
>From ce0fae223c422f343744b47bc189c69abfb97bbf Mon Sep 17 00:00:00 2001
From: Ben Caradoc-Davies <b...@transient.nz>
Date: Thu, 10 May 2018 11:32:03 +1200
Subject: [PATCH] Copy fontconfig .uuid files to avoid getrandom hang in early
boot
Fixes:
Bug#897572: getrandom hang in early boot prevents plymouth passphrase entry
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=897572
Signed-off-by: Ben Caradoc-Davies <b...@transient.nz>
---
debian/local/plymouth.hook | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/debian/local/plymouth.hook b/debian/local/plymouth.hook
index fe44511..bde2d2c 100644
--- a/debian/local/plymouth.hook
+++ b/debian/local/plymouth.hook
@@ -99,12 +99,16 @@ case "${THEME_NAME}" in
mkdir -p "${DESTDIR}/usr/share/fonts/truetype/dejavu"
cp -a /usr/share/fonts/truetype/dejavu/DejaVuSerif.ttf "${DESTDIR}/usr/share/fonts/truetype/dejavu"
cp -a /usr/share/fonts/truetype/dejavu/DejaVuSans.ttf "${DESTDIR}/usr/share/fonts/truetype/dejavu"
+ cp -a /usr/share/fonts/truetype/dejavu/.uuid "${DESTDIR}/usr/share/fonts/truetype/dejavu"
else
# wheezy
mkdir -p "${DESTDIR}/usr/share/fonts/truetype/ttf-dejavu"
cp -a /usr/share/fonts/truetype/ttf-dejavu/DejaVuSerif.ttf "${DESTDIR}/usr/share/fonts/truetype/ttf-dejavu"
cp -a /usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf "${DESTDIR}/usr/share/fonts/truetype/ttf-dejavu"
+ cp -a /usr/share/fonts/truetype/ttf-dejavu/.uuid "${DESTDIR}/usr/share/fonts/truetype/ttf-dejavu"
fi
+ cp -a /usr/share/fonts/truetype/.uuid "${DESTDIR}/usr/share/fonts/truetype"
+ cp -a /usr/share/fonts/.uuid "${DESTDIR}/usr/share/fonts"
# pango
if ls /usr/lib/@DEB_HOST_MULTIARCH@/pango/1* > /dev/null 2>&1
--
Ben Caradoc-Davies <b...@transient.nz>
Director
Transient Software Limited <https://transient.nz/>
New Zealand