|
|
3888c9 |
From 3aca4acaea9569573d3d0e83c3c7998b56ea74c4 Mon Sep 17 00:00:00 2001
|
|
|
3888c9 |
From: Hari Bathini <hbathini@linux.ibm.com>
|
|
|
3888c9 |
Date: Tue, 12 Jul 2022 13:55:47 +0530
|
|
|
3888c9 |
Subject: [PATCH] fix(squash): build ld cache for squash loader
|
|
|
3888c9 |
|
|
|
3888c9 |
Commit dc21638c3f0a fixes kdump kernel crash, due to non-conventional
|
|
|
3888c9 |
library path in powerpc, by copying /etc/ld.so.cache under initdir.
|
|
|
3888c9 |
While that works in general, it is vulnerable to failure because of
|
|
|
3888c9 |
missing links, when the CPU is reconfigured to run in compatibility
|
|
|
3888c9 |
mode of older CPU version. Avoid this by running ldconfig for squash
|
|
|
3888c9 |
loader to create the necessary links & ld cache for it. Doing this
|
|
|
3888c9 |
also saves a few kilobyes of space as the copied ld cache is bigger
|
|
|
3888c9 |
in size than the one needed for squash loader environment.
|
|
|
3888c9 |
|
|
|
3888c9 |
Fixes: dc21638c3f0a ("fix(squash): keep ld cache under initdir")
|
|
|
3888c9 |
Cc: Pingfan Liu <piliu@redhat.com>
|
|
|
3888c9 |
Signed-off-by: Hari Bathini <hbathini@linux.ibm.com>
|
|
|
3888c9 |
|
|
|
3888c9 |
(Cherry-picked from f5e8250a06b5a53f6fd8e47ec976db933c91b3cd)
|
|
|
3888c9 |
|
|
|
3888c9 |
Resolves: #2055026
|
|
|
3888c9 |
---
|
|
|
3888c9 |
dracut-init.sh | 14 ++++++++++++++
|
|
|
3888c9 |
dracut.sh | 11 +----------
|
|
|
3888c9 |
modules.d/99squash/module-setup.sh | 8 +++-----
|
|
|
3888c9 |
3 files changed, 18 insertions(+), 15 deletions(-)
|
|
|
3888c9 |
|
|
|
3888c9 |
diff --git a/dracut-init.sh b/dracut-init.sh
|
|
|
3888c9 |
index 032c38c2..5df2e583 100644
|
|
|
3888c9 |
--- a/dracut-init.sh
|
|
|
3888c9 |
+++ b/dracut-init.sh
|
|
|
3888c9 |
@@ -443,6 +443,20 @@ inst_rules_wildcard() {
|
|
|
3888c9 |
[[ $_found ]] || dinfo "Skipping udev rule: $_rule"
|
|
|
3888c9 |
}
|
|
|
3888c9 |
|
|
|
3888c9 |
+# make sure that library links are correct and up to date
|
|
|
3888c9 |
+build_ld_cache() {
|
|
|
3888c9 |
+ for f in "$dracutsysrootdir"/etc/ld.so.conf "$dracutsysrootdir"/etc/ld.so.conf.d/*; do
|
|
|
3888c9 |
+ [[ -f $f ]] && inst_simple "${f#$dracutsysrootdir}"
|
|
|
3888c9 |
+ done
|
|
|
3888c9 |
+ if ! $DRACUT_LDCONFIG -r "$initdir" -f /etc/ld.so.conf; then
|
|
|
3888c9 |
+ if [[ $EUID == 0 ]]; then
|
|
|
3888c9 |
+ derror "ldconfig exited ungracefully"
|
|
|
3888c9 |
+ else
|
|
|
3888c9 |
+ derror "ldconfig might need uid=0 (root) for chroot()"
|
|
|
3888c9 |
+ fi
|
|
|
3888c9 |
+ fi
|
|
|
3888c9 |
+}
|
|
|
3888c9 |
+
|
|
|
3888c9 |
prepare_udev_rules() {
|
|
|
3888c9 |
[ -z "$UDEVVERSION" ] && export UDEVVERSION=$(udevadm --version | { read v _ ; echo $v ; })
|
|
|
3888c9 |
|
|
|
3888c9 |
diff --git a/dracut.sh b/dracut.sh
|
|
|
3888c9 |
index 702b2f78..57f51e91 100755
|
|
|
3888c9 |
--- a/dracut.sh
|
|
|
3888c9 |
+++ b/dracut.sh
|
|
|
3888c9 |
@@ -1601,16 +1601,7 @@ done
|
|
|
3888c9 |
|
|
|
3888c9 |
if [[ $kernel_only != yes ]]; then
|
|
|
3888c9 |
# make sure that library links are correct and up to date
|
|
|
3888c9 |
- for f in /etc/ld.so.conf /etc/ld.so.conf.d/*; do
|
|
|
3888c9 |
- [[ -f $f ]] && inst_simple "$f"
|
|
|
3888c9 |
- done
|
|
|
3888c9 |
- if ! ldconfig -r "$initdir"; then
|
|
|
3888c9 |
- if [[ $EUID = 0 ]]; then
|
|
|
3888c9 |
- derror "ldconfig exited ungracefully"
|
|
|
3888c9 |
- else
|
|
|
3888c9 |
- derror "ldconfig might need uid=0 (root) for chroot()"
|
|
|
3888c9 |
- fi
|
|
|
3888c9 |
- fi
|
|
|
3888c9 |
+ build_ld_cache
|
|
|
3888c9 |
fi
|
|
|
3888c9 |
|
|
|
3888c9 |
if [[ $do_hardlink = yes ]] && command -v hardlink >/dev/null; then
|
|
|
3888c9 |
diff --git a/modules.d/99squash/module-setup.sh b/modules.d/99squash/module-setup.sh
|
|
|
3888c9 |
index e73d3184..8a0923fb 100644
|
|
|
3888c9 |
--- a/modules.d/99squash/module-setup.sh
|
|
|
3888c9 |
+++ b/modules.d/99squash/module-setup.sh
|
|
|
3888c9 |
@@ -28,11 +28,6 @@ installpost() {
|
|
|
3888c9 |
[[ "$squash_dir" == "$i"/* ]] || mv "$i" "$squash_dir"/
|
|
|
3888c9 |
done
|
|
|
3888c9 |
|
|
|
3888c9 |
- # initdir also needs ld.so.* to make ld.so work
|
|
|
3888c9 |
- inst /etc/ld.so.cache
|
|
|
3888c9 |
- inst /etc/ld.so.conf
|
|
|
3888c9 |
- inst_dir /etc/ld.so.conf.d
|
|
|
3888c9 |
-
|
|
|
3888c9 |
# Create mount points for squash loader
|
|
|
3888c9 |
mkdir -p "$initdir"/squash/
|
|
|
3888c9 |
mkdir -p "$squash_dir"/squash/
|
|
|
3888c9 |
@@ -68,6 +63,9 @@ installpost() {
|
|
|
3888c9 |
ln_r /usr/bin /bin
|
|
|
3888c9 |
ln_r /usr/sbin /sbin
|
|
|
3888c9 |
inst_simple "$moddir"/init-squash.sh /init
|
|
|
3888c9 |
+
|
|
|
3888c9 |
+ # make sure that library links are correct and up to date for squash loader
|
|
|
3888c9 |
+ build_ld_cache
|
|
|
3888c9 |
}
|
|
|
3888c9 |
|
|
|
3888c9 |
install() {
|
|
|
3888c9 |
|