From 7fa73ec70fa36112eb7019acd4cfb027c5b8daca Mon Sep 17 00:00:00 2001 From: Baoquan He Date: Wed, 5 Mar 2014 11:17:57 +0800 Subject: [PATCH] kdump fails loading if target is root fs by default while disk is mounted on save path kdump now dumps vmcore to root partition by default in SAVE_PATCH directory, e.g /var/crash defaultly. This is problematic when another disk is mounted on /var or /var/crash, because the saved vmcore will he hidden after dump in 1st kernel. This also has the potential of blindly filling the root file system without a clue as to why. Now fix this by failing the loading of kdump kernel if dump target is root fs by default while different disk is mounted on save path. Signed-off-by: Baoquan He Acked-by: Vivek Goyal --- mkdumprd | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/mkdumprd b/mkdumprd index f7d2f4d..fe2c86b 100644 --- a/mkdumprd +++ b/mkdumprd @@ -355,6 +355,28 @@ get_block_dump_target() [ -b "$_target" ] && echo $(to_dev_name $_target) } +# If no dump disk is specified make sure /var/crash is not mounted on a +# separate disk. +check_block_dump_target() +{ + local _target + local _mntpoint + + _target=$(get_user_configured_dump_disk) + [ -n "$_target" ] && return + + _target=$(get_root_fs_device) + if [ -b "$_target" ]; then + mkdir -p $SAVE_PATH + _mntpoint=`df $SAVE_PATH | tail -1 | awk '{print $NF}'` + if [ "$_mntpoint" != "/" ]; then + perror "No dump target specified. Default dump target is rootfs block device." + perror "But dump path $SAVE_PATH is not backed by rootfs block device. " + perror_exit "Either explicitly specify a dump target or specify a dump path backed by rootfs block device" + fi + fi +} + get_default_action_target() { local _target @@ -478,6 +500,8 @@ check_crypt() return 1 } +check_block_dump_target + if ! check_resettable; then exit 1 fi