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 <bhe@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
This commit is contained in:
Baoquan He 2014-03-05 11:17:57 +08:00 committed by WANG Chao
parent 2afbb51946
commit 7fa73ec70f

View File

@ -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