From 2b7f081a0676e594a7a71e56bc69d62bdfe5405f Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Jul 20 2021 07:43:43 +0000 Subject: fadump-init: clean up mount points properly Resolves: bz1924115 Conflict: None Upstream: Fedora commit 97930d3ccad5ce090d3160a5781549b081467655 Author: Kairui Song Date: Mon Jun 28 13:57:27 2021 +0800 fadump-init: clean up mount points properly When running with squash module enabled for both initramfs, /dev and /run are also mounted by squash-init, so move them to newroot as well, else they might leak. Also pass `-d` to umount so loop devices (if used) will be force freed. Signed-off-by: Kairui Song Acked-by: Hari Bathini Signed-off-by: Kairui Song --- diff --git a/dracut-fadump-init-fadump.sh b/dracut-fadump-init-fadump.sh index 5468d99..94a3751 100755 --- a/dracut-fadump-init-fadump.sh +++ b/dracut-fadump-init-fadump.sh @@ -20,9 +20,13 @@ if [ -f /proc/device-tree/rtas/ibm,kernel-dump ] || [ -f /proc/device-tree/ibm,o done exec switch_root /newroot /init else - mkdir /newroot/sys /newroot/proc /newroot/oldroot - mount --move /proc /newroot/proc + mkdir /newroot/sys /newroot/proc /newroot/dev /newroot/run /newroot/oldroot + + grep -q '^devtmpfs /dev devtmpfs' /proc/mounts && mount --move /dev /newroot/dev + grep -q '^tmpfs /run tmpfs' /proc/mounts && mount --move /run /newroot/run mount --move /sys /newroot/sys + mount --move /proc /newroot/proc + cp --reflink=auto --sparse=auto --preserve=mode,timestamps,links -dfr /fadumproot/. /newroot/ cd /newroot && pivot_root . oldroot @@ -31,11 +35,11 @@ if [ -f /proc/device-tree/rtas/ibm,kernel-dump ] || [ -f /proc/device-tree/ibm,o unset loop while read -r _ mp _; do case $mp in - /oldroot/*) umount "$mp" && loop=1 ;; + /oldroot/*) umount -d "$mp" && loop=1 ;; esac done