diff --git a/SOURCES/dracut-module-setup.sh b/SOURCES/dracut-module-setup.sh index df08fd7..0d18f78 100755 --- a/SOURCES/dracut-module-setup.sh +++ b/SOURCES/dracut-module-setup.sh @@ -396,27 +396,29 @@ kdump_setup_vlan() { # code reaped from the list_configured function of # https://github.com/hreinecke/s390-tools/blob/master/zconf/znetconf find_online_znet_device() { - local CCWGROUPBUS_DEVICEDIR="/sys/bus/ccwgroup/devices" - local NETWORK_DEVICES d ifname ONLINE - NETWORK_DEVICES=$(find $CCWGROUPBUS_DEVICEDIR -type l) + local CCWGROUPBUS_DEVICEDIR="/sys/bus/ccwgroup/devices" + local NETWORK_DEVICES d ifname ONLINE + + [ ! -d "$CCWGROUPBUS_DEVICEDIR" ] && return + NETWORK_DEVICES=$(find $CCWGROUPBUS_DEVICEDIR) for d in $NETWORK_DEVICES do - read ONLINE < $d/online - if [ $ONLINE -ne 1 ]; then - continue - fi - # determine interface name, if there (only for qeth and if - # device is online) - if [ -f $d/if_name ] - then - read ifname < $d/if_name - elif [ -d $d/net ] - then - ifname=$(ls $d/net/) - fi - [ -n "$ifname" ] && break - done - echo -n "$ifname" + read ONLINE < $d/online + if [ $ONLINE -ne 1 ]; then + continue + fi + # determine interface name, if there (only for qeth and if + # device is online) + if [ -f $d/if_name ] + then + read ifname < $d/if_name + elif [ -d $d/net ] + then + ifname=$(ls $d/net/) + fi + [ -n "$ifname" ] && break + done + echo -n "$ifname" } # setup s390 znet cmdline diff --git a/SOURCES/kdump-lib.sh b/SOURCES/kdump-lib.sh index 97b91c6..dd6156b 100755 --- a/SOURCES/kdump-lib.sh +++ b/SOURCES/kdump-lib.sh @@ -689,7 +689,7 @@ prepare_kdump_bootinfo() local boot_imglist boot_dirlist boot_initrdlist curr_kver="$(uname -r)" local machine_id - if [ -z "$KDUMP_KERNELVER"]; then + if [ -z "$KDUMP_KERNELVER" ]; then KDUMP_KERNELVER="$(uname -r)" fi diff --git a/SOURCES/kexec-tools-2.0.22-makedumpfile-check-for-invalid-physical-address-proc-kcore-when-finding-max_paddr.patch b/SOURCES/kexec-tools-2.0.22-makedumpfile-check-for-invalid-physical-address-proc-kcore-when-finding-max_paddr.patch new file mode 100644 index 0000000..c6eb40f --- /dev/null +++ b/SOURCES/kexec-tools-2.0.22-makedumpfile-check-for-invalid-physical-address-proc-kcore-when-finding-max_paddr.patch @@ -0,0 +1,60 @@ +From 38d921a2ef50ebd36258097553626443ffe27496 Mon Sep 17 00:00:00 2001 +From: Coiby Xu +Date: Tue, 15 Jun 2021 18:26:31 +0800 +Subject: [PATCH] check for invalid physical address of /proc/kcore + when finding max_paddr + +Kernel commit 464920104bf7adac12722035bfefb3d772eb04d8 ("/proc/kcore: +update physical address for kcore ram and text") sets an invalid paddr +(0xffffffffffffffff = -1) for PT_LOAD segments of not direct mapped +regions: + + $ readelf -l /proc/kcore + ... + Program Headers: + Type Offset VirtAddr PhysAddr + FileSiz MemSiz Flags Align + NOTE 0x0000000000000120 0x0000000000000000 0x0000000000000000 + 0x0000000000002320 0x0000000000000000 0x0 + LOAD 0x1000000000010000 0xd000000000000000 0xffffffffffffffff + ^^^^^^^^^^^^^^^^^^ + 0x0001f80000000000 0x0001f80000000000 RWE 0x10000 + +makedumpfile uses max_paddr to calculate the number of sections for +sparse memory model thus wrong number is obtained based on max_paddr +(-1). This error could lead to the failure of copying /proc/kcore +for RHEL-8.5 on ppc64le machine [1]: + + $ makedumpfile /proc/kcore vmcore1 + get_mem_section: Could not validate mem_section. + get_mm_sparsemem: Can't get the address of mem_section. + + makedumpfile Failed. + +Let's check if the phys_start of the segment is a valid physical +address to fix this problem. + +[1] https://bugzilla.redhat.com/show_bug.cgi?id=1965267 + +Reported-by: Xiaoying Yan +Signed-off-by: Coiby Xu +--- + elf_info.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/makedumpfile-1.6.8/elf_info.c b/makedumpfile-1.6.8/elf_info.c +index e8affb7..bc24083 100644 +--- a/makedumpfile-1.6.8/elf_info.c ++++ b/makedumpfile-1.6.8/elf_info.c +@@ -628,7 +628,7 @@ get_max_paddr(void) + + for (i = 0; i < num_pt_loads; i++) { + pls = &pt_loads[i]; +- if (max_paddr < pls->phys_end) ++ if (pls->phys_start != NOT_PADDR && max_paddr < pls->phys_end) + max_paddr = pls->phys_end; + } + return max_paddr; +-- +2.29.2 + diff --git a/SOURCES/kexec-tools-2.0.22-makedumpfile-check-for-invalid-physical-address-proc-kcore-when-making-ELF-dumpfile.patch b/SOURCES/kexec-tools-2.0.22-makedumpfile-check-for-invalid-physical-address-proc-kcore-when-making-ELF-dumpfile.patch new file mode 100644 index 0000000..9180dc6 --- /dev/null +++ b/SOURCES/kexec-tools-2.0.22-makedumpfile-check-for-invalid-physical-address-proc-kcore-when-making-ELF-dumpfile.patch @@ -0,0 +1,43 @@ +From 9a6f589d99dcef114c89fde992157f5467028c8f Mon Sep 17 00:00:00 2001 +From: Tao Liu +Date: Fri, 18 Jun 2021 18:28:04 +0800 +Subject: [PATCH] check for invalid physical address of /proc/kcore + when making ELF dumpfile + +Previously when executing makedumpfile with -E option against +/proc/kcore, makedumpfile will fail: + + # makedumpfile -E -d 31 /proc/kcore kcore.dump + ... + write_elf_load_segment: Can't convert physaddr(ffffffffffffffff) to an offset. + + makedumpfile Failed. + +It's because /proc/kcore contains PT_LOAD program headers which have +physaddr (0xffffffffffffffff). With -E option, makedumpfile will +try to convert the physaddr to an offset and fails. + +Skip the PT_LOAD program headers which have such physaddr. + +Signed-off-by: Tao Liu +Signed-off-by: Kazuhito Hagio +--- + makedumpfile.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/makedumpfile-1.6.8/makedumpfile.c b/makedumpfile-1.6.8/makedumpfile.c +index 894c88e..fcb571f 100644 +--- a/makedumpfile-1.6.8/makedumpfile.c ++++ b/makedumpfile-1.6.8/makedumpfile.c +@@ -7764,7 +7764,7 @@ write_elf_pages_cyclic(struct cache_data *cd_header, struct cache_data *cd_page) + if (!get_phdr_memory(i, &load)) + return FALSE; + +- if (load.p_type != PT_LOAD) ++ if (load.p_type != PT_LOAD || load.p_paddr == NOT_PADDR) + continue; + + off_memory= load.p_offset; +-- +2.29.2 + diff --git a/SPECS/kexec-tools.spec b/SPECS/kexec-tools.spec index 48fc9dd..ba32b7b 100644 --- a/SPECS/kexec-tools.spec +++ b/SPECS/kexec-tools.spec @@ -1,6 +1,6 @@ Name: kexec-tools Version: 2.0.20 -Release: 52%{?dist} +Release: 53%{?dist} License: GPLv2 Group: Applications/System Summary: The kexec/kdump userspace component @@ -114,6 +114,8 @@ Patch701: rhelonly-kexec-tools-2.0.20-makedumpfile-arm64-Add-support-for-ARMv8.2 Patch702: kexec-tools-2.0.20-makedumpfile-Add-dry-run-option-to-prevent-writing.patch Patch703: kexec-tools-2.0.20-makedumpfile-Add-shorthand-show-stats-option-to-show.patch Patch704: kexec-tools-2.0.20-makedumpfile-Show-write-byte-size-in-report-messages.patch +Patch705: kexec-tools-2.0.22-makedumpfile-check-for-invalid-physical-address-proc-kcore-when-finding-max_paddr.patch +Patch706: kexec-tools-2.0.22-makedumpfile-check-for-invalid-physical-address-proc-kcore-when-making-ELF-dumpfile.patch %description kexec-tools provides /usr/sbin/kexec binary that facilitates a new @@ -146,6 +148,8 @@ tar -z -x -v -f %{SOURCE19} %patch702 -p1 %patch703 -p1 %patch704 -p1 +%patch705 -p1 +%patch706 -p1 %ifarch ppc %define archdef ARCH=ppc @@ -385,6 +389,13 @@ done %endif %changelog +* Fri Jul 2 2021 Pingfan Liu - 2.0.20-53 +- check for invalid physical address of /proc/kcore when making ELF dumpfile +- check for invalid physical address of /proc/kcore when finding max_paddr +- fix format issue in find_online_znet_device +- check the existence of /sys/bus/ccwgroup/devices before trying to find online network device +- kdump-lib.sh: fix a warning in prepare_kdump_bootinfo() + * Thu Jun 17 2021 Pingfan Liu - 2.0.20-52 - Write to `/var/lib/kdump` if $KDUMP_BOOTDIR not writable - Iterate /sys/bus/ccwgroup/devices to tell if we should set up rd.znet