fadump-init: clean up mount points properly

Resolves: bz1924115
Conflict: None
Upstream: Fedora

commit 97930d3cca
Author: Kairui Song <kasong@redhat.com>
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 <kasong@redhat.com>
    Acked-by: Hari Bathini <hbathini@linux.ibm.com>

Signed-off-by: Kairui Song <kasong@redhat.com>
This commit is contained in:
Kairui Song 2021-06-28 13:57:27 +08:00 committed by Tao Liu
parent 8e51ebe6fb
commit 2b7f081a06

View File

@ -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 </proc/mounts
done
umount -l oldroot
umount -d -l oldroot
exec /init
fi