diff --git a/.gitignore b/.gitignore index abb4bc8..e7cea8f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ SOURCES/eppic_050615.tar.gz SOURCES/kexec-tools-2.0.20.tar.xz -SOURCES/makedumpfile-1.6.6.tar.gz +SOURCES/makedumpfile-1.6.7.tar.gz diff --git a/.kexec-tools.metadata b/.kexec-tools.metadata index 11cef96..431b034 100644 --- a/.kexec-tools.metadata +++ b/.kexec-tools.metadata @@ -1,3 +1,3 @@ a096c8e0892b559f40b01916aae240652f75b68a SOURCES/eppic_050615.tar.gz 5d9acd2e741d356d4a48fe4f2d63f66ba431051d SOURCES/kexec-tools-2.0.20.tar.xz -68f5276d82091b54452f754aa41e2e8746f47814 SOURCES/makedumpfile-1.6.6.tar.gz +42941a0219d57d99909616778835e5d9ba890711 SOURCES/makedumpfile-1.6.7.tar.gz diff --git a/SOURCES/kexec-tools-2.0.20-makedumpfile-Fix-off-by-one-issue-in-exclude_nodata_pages.patch b/SOURCES/kexec-tools-2.0.20-makedumpfile-Fix-off-by-one-issue-in-exclude_nodata_pages.patch deleted file mode 100644 index 454b3a3..0000000 --- a/SOURCES/kexec-tools-2.0.20-makedumpfile-Fix-off-by-one-issue-in-exclude_nodata_pages.patch +++ /dev/null @@ -1,42 +0,0 @@ -From 56511628fa6714b189509b2842eadce0842bfeb5 Mon Sep 17 00:00:00 2001 -From: Mikhail Zaslonko -Date: Mon, 4 Nov 2019 14:05:15 +0100 -Subject: [PATCH] [PATCH] Fix off-by-one issue in exclude_nodata_pages() - -When building a dump bitmap (2nd bitmap) for the ELF dump, the last pfn -of the cycle is always ignored in exclude_nodata_pages() function due to -off-by-one error on cycle boundary check. Thus, the respective bit of -the bitmap is never cleared. - -That can lead to the error when such a pfn should not be dumpable (e.g. -the last pfn of the ELF-load of zero filesize). Based on the bit in the -bitmap the page is treated as dumpable in write_elf_pages_cyclic() function -and the follow on error is triggered in write_elf_load_segment() function -due to the failing sanity check of paddr_to_offset2(): - - $ makedumpfile -E dump.elf dump.elf.E - Checking for memory holes : [100.0 %] | - write_elf_load_segment: Can't convert physaddr(7ffff000) to an offset. - makedumpfile Failed. - -Signed-off-by: Mikhail Zaslonko ---- - makedumpfile.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/makedumpfile-1.6.6/makedumpfile.c b/makedumpfile-1.6.6/makedumpfile.c -index de0973f9e763..4a000112ba59 100644 ---- a/makedumpfile-1.6.6/makedumpfile.c -+++ b/makedumpfile-1.6.6/makedumpfile.c -@@ -4740,7 +4740,7 @@ exclude_nodata_pages(struct cycle *cycle) - if (pfn < cycle->start_pfn) - pfn = cycle->start_pfn; - if (pfn_end >= cycle->end_pfn) -- pfn_end = cycle->end_pfn - 1; -+ pfn_end = cycle->end_pfn; - while (pfn < pfn_end) { - clear_bit_on_2nd_bitmap(pfn, cycle); - ++pfn; --- -2.17.1 - diff --git a/SOURCES/kexec-tools-2.0.20-makedumpfile-Generalize-get_kaslr_offset_arm64-for-other-ar.patch b/SOURCES/kexec-tools-2.0.20-makedumpfile-Generalize-get_kaslr_offset_arm64-for-other-ar.patch deleted file mode 100644 index 3fc9d83..0000000 --- a/SOURCES/kexec-tools-2.0.20-makedumpfile-Generalize-get_kaslr_offset_arm64-for-other-ar.patch +++ /dev/null @@ -1,219 +0,0 @@ -From c6992684b51ba9604d50016f36c9139bf54ae03b Mon Sep 17 00:00:00 2001 -From: Kazuhito Hagio -Date: Tue, 17 Dec 2019 11:12:50 -0500 -Subject: [PATCH 1/3] [PATCH] Generalize get_kaslr_offset_arm64() for other - architectures - -Generalize the get_kaslr_offset_arm64() and rename it to -get_kaslr_offset_general() for use by other architectures -supporting KASLR. - -Also, modify the confusing comment in the function and its -x86_64 version. - -Signed-off-by: Kazuhito Hagio ---- - arch/arm64.c | 61 -------------------------------------------------- - arch/x86_64.c | 8 +++---- - makedumpfile.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++ - makedumpfile.h | 4 ++-- - 4 files changed, 66 insertions(+), 67 deletions(-) - -diff --git a/makedumpfile-1.6.6/arch/arm64.c b/makedumpfile-1.6.6/arch/arm64.c -index 3516b340adfd..43164ccc32d4 100644 ---- a/makedumpfile-1.6.6/arch/arm64.c -+++ b/makedumpfile-1.6.6/arch/arm64.c -@@ -205,67 +205,6 @@ get_phys_base_arm64(void) - return FALSE; - } - --unsigned long --get_kaslr_offset_arm64(unsigned long vaddr) --{ -- unsigned int i; -- char buf[BUFSIZE_FGETS], *endp; -- static unsigned long _text = NOT_FOUND_SYMBOL; -- static unsigned long _end = NOT_FOUND_SYMBOL; -- -- if (!info->kaslr_offset && info->file_vmcoreinfo) { -- if (fseek(info->file_vmcoreinfo, 0, SEEK_SET) < 0) { -- ERRMSG("Can't seek the vmcoreinfo file(%s). %s\n", -- info->name_vmcoreinfo, strerror(errno)); -- return FALSE; -- } -- -- while (fgets(buf, BUFSIZE_FGETS, info->file_vmcoreinfo)) { -- i = strlen(buf); -- if (!i) -- break; -- if (buf[i - 1] == '\n') -- buf[i - 1] = '\0'; -- if (strncmp(buf, STR_KERNELOFFSET, -- strlen(STR_KERNELOFFSET)) == 0) { -- info->kaslr_offset = -- strtoul(buf+strlen(STR_KERNELOFFSET),&endp,16); -- DEBUG_MSG("info->kaslr_offset: %lx\n", info->kaslr_offset); -- } -- } -- } -- if (!info->kaslr_offset) -- return 0; -- -- if (_text == NOT_FOUND_SYMBOL) { -- /* -- * Currently, the return value of this function is used in -- * resolve_config_entry() only, and in that case, we must -- * have a vmlinux. -- */ -- if (info->name_vmlinux) { -- _text = get_symbol_addr("_text"); -- _end = get_symbol_addr("_end"); -- } -- DEBUG_MSG("_text: %lx, _end: %lx\n", _text, _end); -- if (_text == NOT_FOUND_SYMBOL || _end == NOT_FOUND_SYMBOL) { -- ERRMSG("Cannot determine _text and _end address\n"); -- return FALSE; -- } -- } -- -- if (_text <= vaddr && vaddr <= _end) { -- DEBUG_MSG("info->kaslr_offset: %lx\n", info->kaslr_offset); -- return info->kaslr_offset; -- } else { -- /* -- * TODO: we need to check if it is vmalloc/vmmemmap/module -- * address, we will have different offset -- */ -- return 0; -- } --} -- - ulong - get_stext_symbol(void) - { -diff --git a/makedumpfile-1.6.6/arch/x86_64.c b/makedumpfile-1.6.6/arch/x86_64.c -index 876644f932be..7a2c05c36809 100644 ---- a/makedumpfile-1.6.6/arch/x86_64.c -+++ b/makedumpfile-1.6.6/arch/x86_64.c -@@ -77,14 +77,14 @@ get_kaslr_offset_x86_64(unsigned long vaddr) - else - kernel_image_size = KERNEL_IMAGE_SIZE_KASLR_ORIG; - -+ /* -+ * Returns the kaslr offset only if the vaddr needs it to be added, -+ * i.e. only kernel text address for now. Otherwise returns 0. -+ */ - if (vaddr >= __START_KERNEL_map && - vaddr < __START_KERNEL_map + kernel_image_size) - return info->kaslr_offset; - else -- /* -- * TODO: we need to check if it is vmalloc/vmmemmap/module -- * address, we will have different offset -- */ - return 0; - } - -diff --git a/makedumpfile-1.6.6/makedumpfile.c b/makedumpfile-1.6.6/makedumpfile.c -index 7586d7c001d4..332b804cd756 100644 ---- a/makedumpfile-1.6.6/makedumpfile.c -+++ b/makedumpfile-1.6.6/makedumpfile.c -@@ -3945,6 +3945,66 @@ free_for_parallel() - } - } - -+unsigned long -+get_kaslr_offset_general(unsigned long vaddr) -+{ -+ unsigned int i; -+ char buf[BUFSIZE_FGETS], *endp; -+ static unsigned long _text = NOT_FOUND_SYMBOL; -+ static unsigned long _end = NOT_FOUND_SYMBOL; -+ -+ if (!info->kaslr_offset && info->file_vmcoreinfo) { -+ if (fseek(info->file_vmcoreinfo, 0, SEEK_SET) < 0) { -+ ERRMSG("Can't seek the vmcoreinfo file(%s). %s\n", -+ info->name_vmcoreinfo, strerror(errno)); -+ return FALSE; -+ } -+ -+ while (fgets(buf, BUFSIZE_FGETS, info->file_vmcoreinfo)) { -+ i = strlen(buf); -+ if (!i) -+ break; -+ if (buf[i - 1] == '\n') -+ buf[i - 1] = '\0'; -+ if (strncmp(buf, STR_KERNELOFFSET, -+ strlen(STR_KERNELOFFSET)) == 0) { -+ info->kaslr_offset = strtoul(buf + -+ strlen(STR_KERNELOFFSET), &endp, 16); -+ DEBUG_MSG("info->kaslr_offset: %lx\n", -+ info->kaslr_offset); -+ } -+ } -+ } -+ if (!info->kaslr_offset) -+ return 0; -+ -+ if (_text == NOT_FOUND_SYMBOL) { -+ /* -+ * Currently, the return value of this function is used in -+ * resolve_config_entry() only, and in that case, we must -+ * have a vmlinux. -+ */ -+ if (info->name_vmlinux) { -+ _text = get_symbol_addr("_text"); -+ _end = get_symbol_addr("_end"); -+ } -+ DEBUG_MSG("_text: %lx, _end: %lx\n", _text, _end); -+ if (_text == NOT_FOUND_SYMBOL || _end == NOT_FOUND_SYMBOL) { -+ ERRMSG("Cannot determine _text and _end address\n"); -+ return FALSE; -+ } -+ } -+ -+ /* -+ * Returns the kaslr offset only if the vaddr needs it to be added, -+ * i.e. only kernel text address for now. Otherwise returns 0. -+ */ -+ if (_text <= vaddr && vaddr <= _end) -+ return info->kaslr_offset; -+ else -+ return 0; -+} -+ - int - find_kaslr_offsets() - { -diff --git a/makedumpfile-1.6.6/makedumpfile.h b/makedumpfile-1.6.6/makedumpfile.h -index ac11e906b5b7..067fa483aa01 100644 ---- a/makedumpfile-1.6.6/makedumpfile.h -+++ b/makedumpfile-1.6.6/makedumpfile.h -@@ -964,6 +964,7 @@ typedef unsigned long pgd_t; - static inline int stub_true() { return TRUE; } - static inline int stub_true_ul(unsigned long x) { return TRUE; } - static inline int stub_false() { return FALSE; } -+unsigned long get_kaslr_offset_general(unsigned long vaddr); - #define paddr_to_vaddr_general(X) ((X) + PAGE_OFFSET) - - #ifdef __aarch64__ -@@ -973,7 +974,6 @@ unsigned long long vaddr_to_paddr_arm64(unsigned long vaddr); - int get_versiondep_info_arm64(void); - int get_xen_basic_info_arm64(void); - int get_xen_info_arm64(void); --unsigned long get_kaslr_offset_arm64(unsigned long vaddr); - #define paddr_to_vaddr_arm64(X) (((X) - info->phys_base) | PAGE_OFFSET) - - #define find_vmemmap() stub_false() -@@ -982,7 +982,7 @@ unsigned long get_kaslr_offset_arm64(unsigned long vaddr); - #define get_phys_base() get_phys_base_arm64() - #define get_machdep_info() get_machdep_info_arm64() - #define get_versiondep_info() get_versiondep_info_arm64() --#define get_kaslr_offset(X) get_kaslr_offset_arm64(X) -+#define get_kaslr_offset(X) get_kaslr_offset_general(X) - #define get_xen_basic_info_arch(X) get_xen_basic_info_arm64(X) - #define get_xen_info_arch(X) get_xen_info_arm64(X) - #define is_phys_addr(X) stub_true_ul(X) --- -2.17.1 - diff --git a/SOURCES/kexec-tools-2.0.20-makedumpfile-Increase-SECTION_MAP_LAST_BIT-to-4.patch b/SOURCES/kexec-tools-2.0.20-makedumpfile-Increase-SECTION_MAP_LAST_BIT-to-4.patch deleted file mode 100644 index b9c5eff..0000000 --- a/SOURCES/kexec-tools-2.0.20-makedumpfile-Increase-SECTION_MAP_LAST_BIT-to-4.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 7bdb468c2c99dd780c9a5321f93c79cbfdce2527 Mon Sep 17 00:00:00 2001 -From: Kazuhito Hagio -Date: Tue, 23 Jul 2019 12:24:47 -0400 -Subject: [PATCH] [PATCH] Increase SECTION_MAP_LAST_BIT to 4 - -kernel commit 326e1b8f83a4 ("mm/sparsemem: introduce a SECTION_IS_EARLY -flag") added the flag to mem_section->section_mem_map value, and it caused -makedumpfile an error like the following: - - readmem: Can't convert a virtual address(fffffc97d1000000) to physical address. - readmem: type_addr: 0, addr:fffffc97d1000000, size:32768 - __exclude_unnecessary_pages: Can't read the buffer of struct page. - create_2nd_bitmap: Can't exclude unnecessary pages. - -To fix this, SECTION_MAP_LAST_BIT needs to be updated. The bit has not -been used until the addition, so we can just increase the value. - -Signed-off-by: Kazuhito Hagio ---- - makedumpfile.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/makedumpfile-1.6.6/makedumpfile.h b/makedumpfile-1.6.6/makedumpfile.h -index 24b2f69f400c..df745b9f53e5 100644 ---- a/makedumpfile-1.6.6/makedumpfile.h -+++ b/makedumpfile-1.6.6/makedumpfile.h -@@ -195,7 +195,7 @@ isAnon(unsigned long mapping) - * 2. it has been verified that (1UL<<2) was never set, so it is - * safe to mask that bit off even in old kernels. - */ --#define SECTION_MAP_LAST_BIT (1UL<<3) -+#define SECTION_MAP_LAST_BIT (1UL<<4) - #define SECTION_MAP_MASK (~(SECTION_MAP_LAST_BIT-1)) - #define NR_SECTION_ROOTS() divideup(num_section, SECTIONS_PER_ROOT()) - #define SECTION_NR_TO_PFN(sec) ((sec) << PFN_SECTION_SHIFT()) --- -2.17.2 - diff --git a/SOURCES/kexec-tools-2.0.20-makedumpfile-PATCH-Align-PMD_SECTION_MASK-with-PHYS_MASK.patch b/SOURCES/kexec-tools-2.0.20-makedumpfile-PATCH-Align-PMD_SECTION_MASK-with-PHYS_MASK.patch new file mode 100644 index 0000000..e165b7d --- /dev/null +++ b/SOURCES/kexec-tools-2.0.20-makedumpfile-PATCH-Align-PMD_SECTION_MASK-with-PHYS_MASK.patch @@ -0,0 +1,36 @@ +From 7242ae4cb5288df626f464ced0a8b60fd669100b Mon Sep 17 00:00:00 2001 +From: Michal Suchanek +Date: Mon, 16 Mar 2020 19:39:58 +0100 +Subject: [PATCH 6/7] [PATCH] Align PMD_SECTION_MASK with PHYS_MASK + +Reportedly on some arm64 systems makedumpfile loops forever exhausting +all memory when filtering kernel core. It turns out the reason is it +cannot resolve some addresses because the PMD mask is wrong. When +physical address mask allows up to 48bits pmd mask should allow the +same. +I suppose you would need a system that needs physical addresses over 1TB +to be able to reproduce this. This may be either because you have a lot +of memory or because the firmware mapped some memory above 1TB for some +reason. + +Signed-off-by: Michal Suchanek +--- + arch/arm64.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/makedumpfile-1.6.7/arch/arm64.c b/makedumpfile-1.6.7/arch/arm64.c +index 43164cc..54d60b4 100644 +--- a/makedumpfile-1.6.7/arch/arm64.c ++++ b/makedumpfile-1.6.7/arch/arm64.c +@@ -81,7 +81,7 @@ static unsigned long kimage_voffset; + * Remove the highest order bits that are not a part of the + * physical address in a section + */ +-#define PMD_SECTION_MASK ((1UL << 40) - 1) ++#define PMD_SECTION_MASK ((1UL << PHYS_MASK_SHIFT) - 1) + + #define PMD_TYPE_MASK 3 + #define PMD_TYPE_SECT 1 +-- +2.7.5 + diff --git a/SOURCES/kexec-tools-2.0.20-makedumpfile-PATCH-Fix-cd_header-offset-overflow-with-large-pfn.patch b/SOURCES/kexec-tools-2.0.20-makedumpfile-PATCH-Fix-cd_header-offset-overflow-with-large-pfn.patch new file mode 100644 index 0000000..85b5048 --- /dev/null +++ b/SOURCES/kexec-tools-2.0.20-makedumpfile-PATCH-Fix-cd_header-offset-overflow-with-large-pfn.patch @@ -0,0 +1,42 @@ +From 6e4b2dfaed5e5e5c617e0e45f969c1f571c13e27 Mon Sep 17 00:00:00 2001 +From: Jialong Chen +Date: Mon, 23 Mar 2020 16:42:01 -0400 +Subject: [PATCH 7/7] [PATCH] Fix cd_header offset overflow with large pfn + +In function write_kdump_pages_and_bitmap_cyclic(), cd_header->offset is +calculated by the following formula: + + cd_header->offset + = (DISKDUMP_HEADER_BLOCKS + dh->sub_hdr_size + dh->bitmap_blocks) + * dh->block_size; + +However, the variables of the right side are only int and unsigned int, +so if dh->bitmap_blocks is very large, it causes an interger overflow. + +As a result, makedumpfile created a broken vmcore in a system with a +physical address range from 0x602770ecf000 to 0x6027ffffffff, and the +crash utility failed during session initialization, ending with the +error message "crash: vmlinux and vmcore do not match!". + +Signed-off-by: Jialong Chen +Signed-off-by: Kazuhito Hagio +--- + diskdump_mod.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/makedumpfile-1.6.7/diskdump_mod.h b/makedumpfile-1.6.7/diskdump_mod.h +index 2676817..3733953 100644 +--- a/makedumpfile-1.6.7/diskdump_mod.h ++++ b/makedumpfile-1.6.7/diskdump_mod.h +@@ -22,7 +22,7 @@ + #define DISK_DUMP_SIGNATURE "DISKDUMP" + #define KDUMP_SIGNATURE "KDUMP " + #define SIG_LEN (sizeof(DUMP_PARTITION_SIGNATURE) - 1) +-#define DISKDUMP_HEADER_BLOCKS (1) ++#define DISKDUMP_HEADER_BLOCKS (1UL) + + /* + * These are all remnants of the old "diskdump" facility, +-- +2.7.5 + diff --git a/SOURCES/kexec-tools-2.0.20-makedumpfile-PATCH-Introduce-check-params-option.patch b/SOURCES/kexec-tools-2.0.20-makedumpfile-PATCH-Introduce-check-params-option.patch new file mode 100644 index 0000000..b83d083 --- /dev/null +++ b/SOURCES/kexec-tools-2.0.20-makedumpfile-PATCH-Introduce-check-params-option.patch @@ -0,0 +1,255 @@ +From 989152e113bfcb4fbfbad6f3aed6f43be4455919 Mon Sep 17 00:00:00 2001 +From: Kazuhito Hagio +Date: Tue, 25 Feb 2020 16:04:55 -0500 +Subject: [PATCH 4/7] [PATCH] Introduce --check-params option + +Currently it's difficult to check whether a makedumpfile command-line +is valid or not without an actual panic. This is inefficient and if +a wrong configuration is not tested, you will miss the vmcore when an +actual panic occurs. + +In order for kdump facilities like kexec-tools to be able to check +the specified command-line parameters in advance, introduce the +--check-params option that only checks them and exits immediately. + +Signed-off-by: Kazuhito Hagio +--- + makedumpfile.8 | 5 ++++ + makedumpfile.c | 75 +++++++++++++++++++++++++++++++++++++++++++++------------- + makedumpfile.h | 2 ++ + print_info.c | 4 ++++ + 4 files changed, 69 insertions(+), 17 deletions(-) + +diff --git a/makedumpfile-1.6.7/makedumpfile.8 b/makedumpfile-1.6.7/makedumpfile.8 +index bf156a8..c5d4806 100644 +--- a/makedumpfile-1.6.7/makedumpfile.8 ++++ b/makedumpfile-1.6.7/makedumpfile.8 +@@ -632,6 +632,11 @@ Show help message and LZO/snappy support status (enabled/disabled). + \fB\-v\fR + Show the version of makedumpfile. + ++.TP ++\fB\-\-check-params\fR ++Only check whether the command-line parameters are valid or not, and exit. ++Preferable to be given as the first parameter. ++ + .SH ENVIRONMENT VARIABLES + + .TP 8 +diff --git a/makedumpfile-1.6.7/makedumpfile.c b/makedumpfile-1.6.7/makedumpfile.c +index 607e07f..f5860a1 100644 +--- a/makedumpfile-1.6.7/makedumpfile.c ++++ b/makedumpfile-1.6.7/makedumpfile.c +@@ -10972,12 +10972,6 @@ check_param_for_creating_dumpfile(int argc, char *argv[]) + if (info->flag_generate_vmcoreinfo || info->flag_rearrange) + return FALSE; + +- if ((message_level < MIN_MSG_LEVEL) +- || (MAX_MSG_LEVEL < message_level)) { +- message_level = DEFAULT_MSG_LEVEL; +- MSG("Message_level is invalid.\n"); +- return FALSE; +- } + if ((info->flag_compress && info->flag_elf_dumpfile) + || (info->flag_read_vmcoreinfo && info->name_vmlinux) + || (info->flag_read_vmcoreinfo && info->name_xen_syms)) +@@ -11007,6 +11001,11 @@ check_param_for_creating_dumpfile(int argc, char *argv[]) + if (info->flag_partial_dmesg && !info->flag_dmesg) + return FALSE; + ++ if (info->flag_excludevm && !info->working_dir) { ++ MSG("-%c requires --work-dir\n", OPT_EXCLUDE_UNUSED_VM); ++ return FALSE; ++ } ++ + if ((argc == optind + 2) && !info->flag_flatten + && !info->flag_split + && !info->flag_sadump_diskset) { +@@ -11402,6 +11401,23 @@ int show_mem_usage(void) + return TRUE; + } + ++static int set_message_level(char *str_ml) ++{ ++ int ml; ++ ++ ml = atoi(str_ml); ++ if ((ml < MIN_MSG_LEVEL) || (MAX_MSG_LEVEL < ml)) { ++ message_level = DEFAULT_MSG_LEVEL; ++ MSG("Message_level(%d) is invalid.\n", ml); ++ return FALSE; ++ } ++ ++ if (info->flag_check_params) ++ return TRUE; ++ ++ message_level = ml; ++ return TRUE; ++} + + static struct option longopts[] = { + {"split", no_argument, NULL, OPT_SPLIT}, +@@ -11423,6 +11439,7 @@ static struct option longopts[] = { + {"splitblock-size", required_argument, NULL, OPT_SPLITBLOCK_SIZE}, + {"work-dir", required_argument, NULL, OPT_WORKING_DIR}, + {"num-threads", required_argument, NULL, OPT_NUM_THREADS}, ++ {"check-params", no_argument, NULL, OPT_CHECK_PARAMS}, + {0, 0, 0, 0} + }; + +@@ -11521,7 +11538,8 @@ main(int argc, char *argv[]) + info->flag_compress = DUMP_DH_COMPRESSED_LZO; + break; + case OPT_MESSAGE_LEVEL: +- message_level = atoi(optarg); ++ if (!set_message_level(optarg)) ++ goto out; + break; + case OPT_DUMP_DMESG: + info->flag_dmesg = 1; +@@ -11584,6 +11602,10 @@ main(int argc, char *argv[]) + case OPT_NUM_THREADS: + info->num_threads = MAX(atoi(optarg), 0); + break; ++ case OPT_CHECK_PARAMS: ++ info->flag_check_params = TRUE; ++ message_level = DEFAULT_MSG_LEVEL; ++ break; + case '?': + MSG("Commandline parameter is invalid.\n"); + MSG("Try `makedumpfile --help' for more information.\n"); +@@ -11593,11 +11615,9 @@ main(int argc, char *argv[]) + if (flag_debug) + message_level |= ML_PRINT_DEBUG_MSG; + +- if (info->flag_excludevm && !info->working_dir) { +- ERRMSG("Error: -%c requires --work-dir\n", OPT_EXCLUDE_UNUSED_VM); +- ERRMSG("Try `makedumpfile --help' for more information\n"); +- return COMPLETED; +- } ++ if (info->flag_check_params) ++ /* suppress debugging messages */ ++ message_level = DEFAULT_MSG_LEVEL; + + if (info->flag_show_usage) { + print_usage(); +@@ -11628,6 +11648,9 @@ main(int argc, char *argv[]) + MSG("Try `makedumpfile --help' for more information.\n"); + goto out; + } ++ if (info->flag_check_params) ++ goto check_ok; ++ + if (!open_files_for_generating_vmcoreinfo()) + goto out; + +@@ -11651,6 +11674,9 @@ main(int argc, char *argv[]) + MSG("Try `makedumpfile --help' for more information.\n"); + goto out; + } ++ if (info->flag_check_params) ++ goto check_ok; ++ + if (!check_dump_file(info->name_dumpfile)) + goto out; + +@@ -11671,6 +11697,9 @@ main(int argc, char *argv[]) + MSG("Try `makedumpfile --help' for more information.\n"); + goto out; + } ++ if (info->flag_check_params) ++ goto check_ok; ++ + if (!check_dump_file(info->name_dumpfile)) + goto out; + +@@ -11684,6 +11713,9 @@ main(int argc, char *argv[]) + MSG("Try `makedumpfile --help' for more information.\n"); + goto out; + } ++ if (info->flag_check_params) ++ goto check_ok; ++ + if (!check_dump_file(info->name_dumpfile)) + goto out; + if (!dump_dmesg()) +@@ -11697,6 +11729,9 @@ main(int argc, char *argv[]) + MSG("Try `makedumpfile --help' for more information.\n"); + goto out; + } ++ if (info->flag_check_params) ++ goto check_ok; ++ + if (!populate_kernel_version()) + goto out; + +@@ -11715,6 +11750,9 @@ main(int argc, char *argv[]) + MSG("Try `makedumpfile --help' for more information.\n"); + goto out; + } ++ if (info->flag_check_params) ++ goto check_ok; ++ + if (info->flag_split) { + for (i = 0; i < info->num_dumpfile; i++) { + SPLITTING_FD_BITMAP(i) = -1; +@@ -11742,13 +11780,16 @@ main(int argc, char *argv[]) + MSG("The dumpfile is saved to %s.\n", info->name_dumpfile); + } + } ++check_ok: + retcd = COMPLETED; + out: +- MSG("\n"); +- if (retcd != COMPLETED) +- MSG("makedumpfile Failed.\n"); +- else if (!info->flag_mem_usage) +- MSG("makedumpfile Completed.\n"); ++ if (!info->flag_check_params) { ++ MSG("\n"); ++ if (retcd != COMPLETED) ++ MSG("makedumpfile Failed.\n"); ++ else if (!info->flag_mem_usage) ++ MSG("makedumpfile Completed.\n"); ++ } + + free_for_parallel(); + +diff --git a/makedumpfile-1.6.7/makedumpfile.h b/makedumpfile-1.6.7/makedumpfile.h +index 7217407..03fb4ce 100644 +--- a/makedumpfile-1.6.7/makedumpfile.h ++++ b/makedumpfile-1.6.7/makedumpfile.h +@@ -1301,6 +1301,7 @@ struct DumpInfo { + int flag_read_vmcoreinfo; /* flag of reading vmcoreinfo file */ + int flag_show_usage; /* flag of showing usage */ + int flag_show_version; /* flag of showing version */ ++ int flag_check_params; /* only check parameters */ + int flag_flatten; /* flag of outputting flattened + format to a standard out */ + int flag_rearrange; /* flag of creating dumpfile from +@@ -2362,6 +2363,7 @@ struct elf_prstatus { + #define OPT_WORKING_DIR OPT_START+15 + #define OPT_NUM_THREADS OPT_START+16 + #define OPT_PARTIAL_DMESG OPT_START+17 ++#define OPT_CHECK_PARAMS OPT_START+18 + + /* + * Function Prototype. +diff --git a/makedumpfile-1.6.7/print_info.c b/makedumpfile-1.6.7/print_info.c +index 0be12ea..e0c38b4 100644 +--- a/makedumpfile-1.6.7/print_info.c ++++ b/makedumpfile-1.6.7/print_info.c +@@ -321,6 +321,10 @@ print_usage(void) + MSG(" [-v]:\n"); + MSG(" Show the version of makedumpfile.\n"); + MSG("\n"); ++ MSG(" [--check-params]:\n"); ++ MSG(" Only check whether the command-line parameters are valid or not, and exit.\n"); ++ MSG(" Preferable to be given as the first parameter.\n"); ++ MSG("\n"); + MSG(" VMLINUX:\n"); + MSG(" This is a pathname to the first kernel's vmlinux.\n"); + MSG(" This file must have the debug information of the first kernel to analyze\n"); +-- +2.7.5 + diff --git a/SOURCES/kexec-tools-2.0.20-makedumpfile-PATCH-Makefile-Fix-build-errors-in-static-build.patch b/SOURCES/kexec-tools-2.0.20-makedumpfile-PATCH-Makefile-Fix-build-errors-in-static-build.patch new file mode 100644 index 0000000..f2f2153 --- /dev/null +++ b/SOURCES/kexec-tools-2.0.20-makedumpfile-PATCH-Makefile-Fix-build-errors-in-static-build.patch @@ -0,0 +1,65 @@ +From 12250baa02584dc713cdb1a12fb366f643fdc8b3 Mon Sep 17 00:00:00 2001 +From: Kazuhito Hagio +Date: Mon, 9 Mar 2020 17:17:31 -0400 +Subject: [PATCH 5/7] [PATCH] Makefile: Fix build errors in static build + +When building makedumpfile statically (without LINKTYPE=dynamic), +the following error is observed: + + /usr/bin/ld: /usr/lib/makedumpfile-1.6.7/gcc/x86_64-redhat-linux/9/../../../../lib64/libdw.a(lzma.o): in function `__libdw_unlzma': + (.text+0xbd): undefined reference to `lzma_auto_decoder' + /usr/bin/ld: (.text+0x23a): undefined reference to `lzma_code' + /usr/bin/ld: (.text+0x269): undefined reference to `lzma_end' + /usr/bin/ld: (.text+0x2aa): undefined reference to `lzma_end' + /usr/bin/ld: (.text+0x3ac): undefined reference to `lzma_end' + /usr/bin/ld: (.text+0x427): undefined reference to `lzma_end' + /usr/bin/ld: (.text+0x62b): undefined reference to `lzma_end' + collect2: error: ld returned 1 exit status + make: *** [Makefile:97: makedumpfile] Error 1 + +Also, when doing it with USESNAPPY=on: + + /usr/bin/ld: /usr/local/lib64/libsnappy.a(snappy.cc.o): in function `snappy::internal::WorkingMemory::WorkingMemory(unsigned long)': + snappy.cc:(.text+0x7d4): undefined reference to `std::allocator::allocator()' + /usr/bin/ld: snappy.cc:(.text+0x803): undefined reference to `std::allocator::~allocator()' + /usr/bin/ld: snappy.cc:(.text+0x853): undefined reference to `std::allocator::~allocator()' + /usr/bin/ld: /usr/local/lib64/libsnappy.a(snappy.cc.o): in function `snappy::internal::WorkingMemory::~WorkingMemory()': + snappy.cc:(.text+0x87e): undefined reference to `std::allocator::allocator()' + /usr/bin/ld: snappy.cc:(.text+0x8a8): undefined reference to `std::allocator::~allocator()' + ... + +Fix these errors by adding -llzma and -lstd++ to LIBS respectively +if LINKTYPE=dynamic is not specified. + +Reported-by: Prabhakar Kushwaha +Signed-off-by: Kazuhito Hagio +--- + Makefile | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/makedumpfile-1.6.7/Makefile b/makedumpfile-1.6.7/Makefile +index 868eea6..ef20672 100644 +--- a/makedumpfile-1.6.7/Makefile ++++ b/makedumpfile-1.6.7/Makefile +@@ -52,7 +52,7 @@ OBJ_ARCH=$(patsubst %.c,%.o,$(SRC_ARCH)) + + LIBS = -ldw -lbz2 -ldl -lelf -lz + ifneq ($(LINKTYPE), dynamic) +-LIBS := -static $(LIBS) ++LIBS := -static $(LIBS) -llzma + endif + + ifeq ($(USELZO), on) +@@ -62,6 +62,9 @@ endif + + ifeq ($(USESNAPPY), on) + LIBS := -lsnappy $(LIBS) ++ifneq ($(LINKTYPE), dynamic) ++LIBS := $(LIBS) -lstdc++ ++endif + CFLAGS += -DUSESNAPPY + endif + +-- +2.7.5 + diff --git a/SOURCES/kexec-tools-2.0.20-makedumpfile-PATCH-Remove-duplicated-variable-definitions.patch b/SOURCES/kexec-tools-2.0.20-makedumpfile-PATCH-Remove-duplicated-variable-definitions.patch new file mode 100644 index 0000000..691cd05 --- /dev/null +++ b/SOURCES/kexec-tools-2.0.20-makedumpfile-PATCH-Remove-duplicated-variable-definitions.patch @@ -0,0 +1,103 @@ +From 399f2c9a3acd5bd913e50a4dde52dee6527b297e Mon Sep 17 00:00:00 2001 +From: Kairui Song +Date: Wed, 29 Jan 2020 13:37:13 +0800 +Subject: [PATCH 2/7] [PATCH] Remove duplicated variable definitions + +When building on Fedora 32 (with GCC 10), following error is observed: + +/usr/bin/ld: erase_info.o:/tmp/makedumpfile/makedumpfile.h:2010: multiple definition of + `crash_reserved_mem_nr'; elf_info.o:/tmp/makedumpfile/makedumpfile.h:2010: first defined here +/usr/bin/ld: erase_info.o:/tmp/makedumpfile/makedumpfile.h:2009: multiple definition of + `crash_reserved_mem'; elf_info.o:/tmp/makedumpfile/makedumpfile.h:2009: first defined here +/usr/bin/ld: erase_info.o:/tmp/makedumpfile/makedumpfile.h:1278: multiple definition of + `parallel_info_t'; elf_info.o:/tmp/makedumpfile/makedumpfile.h:1278: first defined here +/usr/bin/ld: erase_info.o:/tmp/makedumpfile/makedumpfile.h:1265: multiple definition of + `splitting_info_t'; elf_info.o:/tmp/makedumpfile/makedumpfile.h:1265: first defined here +... +collect2: error: ld returned 1 exit status +make: *** [Makefile:97: makedumpfile] Error 1 + +These variables are wrongly defined multiple times. So remove the +duplicated definitions. + +Signed-off-by: Kairui Song +Signed-off-by: Kazuhito Hagio +--- + makedumpfile.c | 8 ++++---- + makedumpfile.h | 8 ++++---- + 2 files changed, 8 insertions(+), 8 deletions(-) + +diff --git a/makedumpfile-1.6.7/makedumpfile.c b/makedumpfile-1.6.7/makedumpfile.c +index e290fbd..ae7336a 100644 +--- a/makedumpfile-1.6.7/makedumpfile.c ++++ b/makedumpfile-1.6.7/makedumpfile.c +@@ -10954,7 +10954,7 @@ check_param_for_reassembling_dumpfile(int argc, char *argv[]) + return FALSE; + + if ((info->splitting_info +- = malloc(sizeof(splitting_info_t) * info->num_dumpfile)) ++ = malloc(sizeof(struct splitting_info) * info->num_dumpfile)) + == NULL) { + MSG("Can't allocate memory for splitting_info.\n"); + return FALSE; +@@ -11042,7 +11042,7 @@ check_param_for_creating_dumpfile(int argc, char *argv[]) + return FALSE; + } + if ((info->splitting_info +- = malloc(sizeof(splitting_info_t) * info->num_dumpfile)) ++ = malloc(sizeof(struct splitting_info) * info->num_dumpfile)) + == NULL) { + MSG("Can't allocate memory for splitting_info.\n"); + return FALSE; +@@ -11077,13 +11077,13 @@ check_param_for_creating_dumpfile(int argc, char *argv[]) + + if (info->num_threads) { + if ((info->parallel_info = +- malloc(sizeof(parallel_info_t) * info->num_threads)) ++ malloc(sizeof(struct parallel_info) * info->num_threads)) + == NULL) { + MSG("Can't allocate memory for parallel_info.\n"); + return FALSE; + } + +- memset(info->parallel_info, 0, sizeof(parallel_info_t) ++ memset(info->parallel_info, 0, sizeof(struct parallel_info) + * info->num_threads); + } + +diff --git a/makedumpfile-1.6.7/makedumpfile.h b/makedumpfile-1.6.7/makedumpfile.h +index 68d9691..7217407 100644 +--- a/makedumpfile-1.6.7/makedumpfile.h ++++ b/makedumpfile-1.6.7/makedumpfile.h +@@ -1262,7 +1262,7 @@ struct splitting_info { + mdf_pfn_t end_pfn; + off_t offset_eraseinfo; + unsigned long size_eraseinfo; +-} splitting_info_t; ++}; + + struct parallel_info { + int fd_memory; +@@ -1275,7 +1275,7 @@ struct parallel_info { + #ifdef USELZO + lzo_bytep wrkmem; + #endif +-} parallel_info_t; ++}; + + struct ppc64_vmemmap { + unsigned long phys; +@@ -2006,8 +2006,8 @@ struct memory_range { + }; + + #define CRASH_RESERVED_MEM_NR 8 +-struct memory_range crash_reserved_mem[CRASH_RESERVED_MEM_NR]; +-int crash_reserved_mem_nr; ++extern struct memory_range crash_reserved_mem[CRASH_RESERVED_MEM_NR]; ++extern int crash_reserved_mem_nr; + + unsigned long read_vmcoreinfo_symbol(char *str_symbol); + int readmem(int type_addr, unsigned long long addr, void *bufptr, size_t size); +-- +2.7.5 + diff --git a/SOURCES/kexec-tools-2.0.20-makedumpfile-PATCH-cope-with-not-present-mem-section.patch b/SOURCES/kexec-tools-2.0.20-makedumpfile-PATCH-cope-with-not-present-mem-section.patch new file mode 100644 index 0000000..2e9832c --- /dev/null +++ b/SOURCES/kexec-tools-2.0.20-makedumpfile-PATCH-cope-with-not-present-mem-section.patch @@ -0,0 +1,65 @@ +From e113f1c974c820f9633dc0073eda525d7575f365 Mon Sep 17 00:00:00 2001 +From: Pingfan Liu +Date: Mon, 20 Jan 2020 10:25:24 +0800 +Subject: [PATCH 3/7] [PATCH] cope with not-present mem section + +After kernel commit ba72b4c8cf60 ("mm/sparsemem: support sub-section +hotplug"), when hot-removed, section_mem_map is still encoded with section +start pfn, not NULL. This break the current makedumpfile. + + # makedumpfile -x vmlinux -l -d 31 vmcore vmcore.dump + get_mem_section: Could not validate mem_section. + get_mm_sparsemem: Can't get the address of mem_section. + + makedumpfile Failed. + +Whatever section_mem_map coding info after hot-removed, it is reliable +just to work on SECTION_MARKED_PRESENT bit. Fixing makedumpfile by this +way. + +[ This issue occurs on kernel 5.3 through 5.5, and should be fixed by +commit 1f503443e7df ("mm/sparse.c: reset section's mem_map when fully +deactivated") in 5.6-rc1, 5.5.3 and 5.4.19. ] + +Signed-off-by: Pingfan Liu +To: kexec@lists.infradead.org +Cc: Kazuhito Hagio +Cc: Baoquan He +Cc: David Hildenbrand +Cc: Andrew Morton +Cc: Dan Williams +Cc: Oscar Salvador +Cc: Michal Hocko +Cc: Qian Cai +--- + makedumpfile.c | 6 +----- + 1 file changed, 1 insertion(+), 5 deletions(-) + +diff --git a/makedumpfile-1.6.7/makedumpfile.c b/makedumpfile-1.6.7/makedumpfile.c +index ae7336a..607e07f 100644 +--- a/makedumpfile-1.6.7/makedumpfile.c ++++ b/makedumpfile-1.6.7/makedumpfile.c +@@ -3406,8 +3406,6 @@ section_mem_map_addr(unsigned long addr, unsigned long *map_mask) + map = ULONG(mem_section + OFFSET(mem_section.section_mem_map)); + mask = SECTION_MAP_MASK; + *map_mask = map & ~mask; +- if (map == 0x0) +- *map_mask |= SECTION_MARKED_PRESENT; + map &= mask; + free(mem_section); + +@@ -3453,10 +3451,8 @@ validate_mem_section(unsigned long *mem_sec, + mem_map = NOT_MEMMAP_ADDR; + } else { + mem_map = section_mem_map_addr(section, &map_mask); ++ /* for either no mem_map or hot-removed */ + if (!(map_mask & SECTION_MARKED_PRESENT)) { +- return FALSE; +- } +- if (mem_map == 0) { + mem_map = NOT_MEMMAP_ADDR; + } else { + mem_map = sparse_decode_mem_map(mem_map, +-- +2.7.5 + diff --git a/SOURCES/kexec-tools-2.0.20-makedumpfile-Pass-0-to-get_kaslr_offset-in-find_kaslr_offse.patch b/SOURCES/kexec-tools-2.0.20-makedumpfile-Pass-0-to-get_kaslr_offset-in-find_kaslr_offse.patch deleted file mode 100644 index 3db1f56..0000000 --- a/SOURCES/kexec-tools-2.0.20-makedumpfile-Pass-0-to-get_kaslr_offset-in-find_kaslr_offse.patch +++ /dev/null @@ -1,65 +0,0 @@ -From 60cf280ebfe8b6468bfd1dd592a117e719c56ccf Mon Sep 17 00:00:00 2001 -From: Kazuhito Hagio -Date: Fri, 3 Jan 2020 11:27:41 -0500 -Subject: [PATCH 2/3] [PATCH] Pass 0 to get_kaslr_offset() in - find_kaslr_offsets() - -Currently SYMBOL(_stext) is passed to get_kaslr_offset() in -find_kaslr_offsets(), but it is always zero, because it has not -been set yet at the time. - -On the other hand, the vaddr argument of get_kaslr_offset() is -only used to decide whether to return a KASLR offset or not, but -the return value is not used in find_kaslr_offsets(). - -Therefore, passing SYMBOL(_stext) is meaningless and confusing, -so let's pass it 0 explicitly to avoid confusion. - -Reported-by: Lianbo Jiang -Signed-off-by: Kazuhito Hagio ---- - arch/x86_64.c | 2 +- - makedumpfile.c | 6 ++++-- - 2 files changed, 5 insertions(+), 3 deletions(-) - -diff --git a/makedumpfile-1.6.6/arch/x86_64.c b/makedumpfile-1.6.6/arch/x86_64.c -index 7a2c05c36809..b5e295452964 100644 ---- a/makedumpfile-1.6.6/arch/x86_64.c -+++ b/makedumpfile-1.6.6/arch/x86_64.c -@@ -69,7 +69,7 @@ get_kaslr_offset_x86_64(unsigned long vaddr) - strtoul(buf+strlen(STR_KERNELOFFSET),&endp,16); - } - } -- if (!info->kaslr_offset) -+ if (!info->kaslr_offset || !vaddr) - return 0; - - if (NUMBER(KERNEL_IMAGE_SIZE) != NOT_FOUND_NUMBER) -diff --git a/makedumpfile-1.6.6/makedumpfile.c b/makedumpfile-1.6.6/makedumpfile.c -index 332b804cd756..e290fbdb4f9f 100644 ---- a/makedumpfile-1.6.6/makedumpfile.c -+++ b/makedumpfile-1.6.6/makedumpfile.c -@@ -3975,7 +3975,7 @@ get_kaslr_offset_general(unsigned long vaddr) - } - } - } -- if (!info->kaslr_offset) -+ if (!info->kaslr_offset || !vaddr) - return 0; - - if (_text == NOT_FOUND_SYMBOL) { -@@ -4032,8 +4032,10 @@ find_kaslr_offsets() - * function might need to read from vmcoreinfo, therefore we have - * called this function between open_vmcoreinfo() and - * close_vmcoreinfo() -+ * And the argument is not needed, because we don't use the return -+ * value here. So pass it 0 explicitly. - */ -- get_kaslr_offset(SYMBOL(_stext)); -+ get_kaslr_offset(0); - - close_vmcoreinfo(); - --- -2.17.1 - diff --git a/SOURCES/kexec-tools-2.0.20-makedumpfile-arm64-fix-get_kaslr_offset_arm64-to-return-kas.patch b/SOURCES/kexec-tools-2.0.20-makedumpfile-arm64-fix-get_kaslr_offset_arm64-to-return-kas.patch deleted file mode 100644 index 368996e..0000000 --- a/SOURCES/kexec-tools-2.0.20-makedumpfile-arm64-fix-get_kaslr_offset_arm64-to-return-kas.patch +++ /dev/null @@ -1,85 +0,0 @@ -From 76f9cc0f3de2f4727a1f838ce9f10d848b92e1a4 Mon Sep 17 00:00:00 2001 -From: Kazuhito Hagio -Date: Tue, 4 Jun 2019 15:00:15 -0400 -Subject: [PATCH] [PATCH] arm64: fix get_kaslr_offset_arm64() to return - kaslr_offset correctly - -Currently, the get_kaslr_offset_arm64() function has the following -condition to return info->kaslr_offset, but kernel text mapping is -placed in another range on arm64 by default, so it returns 0 for -kernel text addresses. - - if (vaddr >= __START_KERNEL_map && - vaddr < __START_KERNEL_map + info->kaslr_offset) - -Consequently, kernel text symbols in erase config are resolved wrongly -with KASLR enabled vmcore, and makedumpfile erases unintended data. - -Since the return value of get_kaslr_offset_arm64() is used in -resolve_config_entry() only, and in that case, we must have a vmlinux, -so get the addresses of _text and _end from vmlinux and use them. - -Signed-off-by: Kazuhito Hagio ---- - arch/arm64.c | 24 ++++++++++++++++++++++-- - makedumpfile.h | 1 - - 2 files changed, 22 insertions(+), 3 deletions(-) - -diff --git a/makedumpfile-1.6.6/arch/arm64.c b/makedumpfile-1.6.6/arch/arm64.c -index 053519359cbc..3516b340adfd 100644 ---- a/makedumpfile-1.6.6/arch/arm64.c -+++ b/makedumpfile-1.6.6/arch/arm64.c -@@ -210,6 +210,8 @@ get_kaslr_offset_arm64(unsigned long vaddr) - { - unsigned int i; - char buf[BUFSIZE_FGETS], *endp; -+ static unsigned long _text = NOT_FOUND_SYMBOL; -+ static unsigned long _end = NOT_FOUND_SYMBOL; - - if (!info->kaslr_offset && info->file_vmcoreinfo) { - if (fseek(info->file_vmcoreinfo, 0, SEEK_SET) < 0) { -@@ -232,9 +234,27 @@ get_kaslr_offset_arm64(unsigned long vaddr) - } - } - } -+ if (!info->kaslr_offset) -+ return 0; -+ -+ if (_text == NOT_FOUND_SYMBOL) { -+ /* -+ * Currently, the return value of this function is used in -+ * resolve_config_entry() only, and in that case, we must -+ * have a vmlinux. -+ */ -+ if (info->name_vmlinux) { -+ _text = get_symbol_addr("_text"); -+ _end = get_symbol_addr("_end"); -+ } -+ DEBUG_MSG("_text: %lx, _end: %lx\n", _text, _end); -+ if (_text == NOT_FOUND_SYMBOL || _end == NOT_FOUND_SYMBOL) { -+ ERRMSG("Cannot determine _text and _end address\n"); -+ return FALSE; -+ } -+ } - -- if (vaddr >= __START_KERNEL_map && -- vaddr < __START_KERNEL_map + info->kaslr_offset) { -+ if (_text <= vaddr && vaddr <= _end) { - DEBUG_MSG("info->kaslr_offset: %lx\n", info->kaslr_offset); - return info->kaslr_offset; - } else { -diff --git a/makedumpfile-1.6.6/makedumpfile.h b/makedumpfile-1.6.6/makedumpfile.h -index df745b9f53e5..ac11e906b5b7 100644 ---- a/makedumpfile-1.6.6/makedumpfile.h -+++ b/makedumpfile-1.6.6/makedumpfile.h -@@ -542,7 +542,6 @@ do { \ - #ifdef __aarch64__ - unsigned long get_kvbase_arm64(void); - #define KVBASE get_kvbase_arm64() --#define __START_KERNEL_map (0xffffffff80000000UL) - - #endif /* aarch64 */ - --- -2.17.1 - diff --git a/SOURCES/kexec-tools-2.0.20-makedumpfile-assign-bitmap1-2-fd-for-subprocess-in-non-cycl.patch b/SOURCES/kexec-tools-2.0.20-makedumpfile-assign-bitmap1-2-fd-for-subprocess-in-non-cycl.patch deleted file mode 100644 index 7f347cc..0000000 --- a/SOURCES/kexec-tools-2.0.20-makedumpfile-assign-bitmap1-2-fd-for-subprocess-in-non-cycl.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 5519b3eba68544dc484d85e9540d440d93f8c924 Mon Sep 17 00:00:00 2001 -From: Pingfan Liu -Date: Tue, 3 Dec 2019 15:37:07 +0800 -Subject: [PATCH] [PATCH] assign bitmap1/2 fd for subprocess in non-cyclic mode - -In non-cyclic mode with the --split option, each subprocess inherits -bitmap1/2->fd from parent. Then they lseek()/read() on the same fd, -which means that they interfere with each other. - -This breaks the purpose of SPLITTING_FD_BITMAP(i) for each subprocess. -Without this patch, makedumpfile can fail with error like the following -in refiltering, or can break the dumpfile silently by excluding pages -wrongly. - - readpage_kdump_compressed: pfn(2fc1000) is excluded from vmcore. - readmem: type_addr: 1, addr:2fc1000000, size:4096 - read_pfn: Can't get the page data. - -Fix it by assigning a subprocess dedicated fd to bitmap1/2->fd. - -Signed-off-by: Pingfan Liu -Signed-off-by: Kazuhito Hagio ---- - makedumpfile.c | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/makedumpfile-1.6.6/makedumpfile.c b/makedumpfile-1.6.6/makedumpfile.c -index 43107d9..7586d7c 100644 ---- a/makedumpfile-1.6.6/makedumpfile.c -+++ b/makedumpfile-1.6.6/makedumpfile.c -@@ -10091,6 +10091,10 @@ writeout_multiple_dumpfiles(void) - info->split_start_pfn = SPLITTING_START_PFN(i); - info->split_end_pfn = SPLITTING_END_PFN(i); - -+ if (!info->flag_cyclic) { -+ info->bitmap1->fd = info->fd_bitmap; -+ info->bitmap2->fd = info->fd_bitmap; -+ } - if (!reopen_dump_memory()) - exit(1); - if ((status = writeout_dumpfile()) == FALSE) --- -2.7.5 - diff --git a/SOURCES/kexec-tools-2.0.20-makedumpfile-s390-Use-get_kaslr_offset_general-for-s390x.patch b/SOURCES/kexec-tools-2.0.20-makedumpfile-s390-Use-get_kaslr_offset_general-for-s390x.patch deleted file mode 100644 index 6958ee9..0000000 --- a/SOURCES/kexec-tools-2.0.20-makedumpfile-s390-Use-get_kaslr_offset_general-for-s390x.patch +++ /dev/null @@ -1,30 +0,0 @@ -From 577854dd62a6b22aa2c0dce59f0541ac1c0c7ab5 Mon Sep 17 00:00:00 2001 -From: Mikhail Zaslonko -Date: Tue, 7 Jan 2020 13:38:14 +0100 -Subject: [PATCH 3/3] [PATCH] s390: Use get_kaslr_offset_general() for s390x - -Since kernel v5.2 KASLR is supported on s390. Use recently introduced -get_kaslr_offset_general() for s390x in order to derive kaslr offset -from vmcoreinfo when -x makedumpfile option specified. - -Signed-off-by: Mikhail Zaslonko ---- - makedumpfile.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/makedumpfile-1.6.6/makedumpfile.h b/makedumpfile-1.6.6/makedumpfile.h -index 067fa483aa01..e6c815da6775 100644 ---- a/makedumpfile-1.6.6/makedumpfile.h -+++ b/makedumpfile-1.6.6/makedumpfile.h -@@ -1075,7 +1075,7 @@ int is_iomem_phys_addr_s390x(unsigned long addr); - #define get_phys_base() stub_true() - #define get_machdep_info() get_machdep_info_s390x() - #define get_versiondep_info() stub_true() --#define get_kaslr_offset(X) stub_false() -+#define get_kaslr_offset(X) get_kaslr_offset_general(X) - #define vaddr_to_paddr(X) vaddr_to_paddr_s390x(X) - #define paddr_to_vaddr(X) paddr_to_vaddr_general(X) - #define is_phys_addr(X) is_iomem_phys_addr_s390x(X) --- -2.17.1 - diff --git a/SOURCES/kexec-tools-2.0.20-makedumpfile-x86_64-Fix-incorrect-exclusion-by-e-option-wit.patch b/SOURCES/kexec-tools-2.0.20-makedumpfile-x86_64-Fix-incorrect-exclusion-by-e-option-wit.patch deleted file mode 100644 index 343c83d..0000000 --- a/SOURCES/kexec-tools-2.0.20-makedumpfile-x86_64-Fix-incorrect-exclusion-by-e-option-wit.patch +++ /dev/null @@ -1,41 +0,0 @@ -From aa5ab4cf6c7335392094577380d2eaee8a0a8d52 Mon Sep 17 00:00:00 2001 -From: Kazuhito Hagio -Date: Thu, 29 Aug 2019 12:26:34 -0400 -Subject: [PATCH] x86_64: Fix incorrect exclusion by -e option with KASLR - -The -e option uses info->vmemmap_start for creating a table to determine -the positions of page structures that should be excluded, but it is a -hardcoded value even with KASLR-enabled vmcore. As a result, the option -excludes incorrect pages from it. - -To fix this, get the vmemmap start address from info->mem_map_data. - -Signed-off-by: Kazuhito Hagio ---- - arch/x86_64.c | 10 ++++++++++ - 1 file changed, 10 insertions(+) - -diff --git a/makedumpfile-1.6.6/arch/x86_64.c b/makedumpfile-1.6.6/arch/x86_64.c -index 3c0fdc5e72fb..4eeaf4925f43 100644 ---- a/makedumpfile-1.6.6/arch/x86_64.c -+++ b/makedumpfile-1.6.6/arch/x86_64.c -@@ -679,6 +679,16 @@ find_vmemmap_x86_64() - if (NUMBER(sme_mask) != NOT_FOUND_NUMBER) - pmask &= ~(NUMBER(sme_mask)); - -+ /* -+ * vmemmap region can be randomized by KASLR. -+ * (currently we don't utilize info->vmemmap_end on x86_64.) -+ */ -+ if (info->mem_map_data && -+ info->mem_map_data[0].mem_map != NOT_MEMMAP_ADDR) -+ info->vmemmap_start = info->mem_map_data[0].mem_map; -+ -+ DEBUG_MSG("vmemmap_start: %16lx\n", info->vmemmap_start); -+ - pagestructsize = size_table.page; - hugepagesize = PTRS_PER_PMD * info->page_size; - vaddr_base = info->vmemmap_start; --- -2.18.1 - diff --git a/SOURCES/mkdumprd b/SOURCES/mkdumprd index cd1b592..274f914 100644 --- a/SOURCES/mkdumprd +++ b/SOURCES/mkdumprd @@ -224,15 +224,27 @@ check_size() { # $1: core_collector config value verify_core_collector() { - if grep -q "^raw" $conf_file && [ "${1%% *}" != "makedumpfile" ]; then - echo "Warning: specifying a non-makedumpfile core collector, you will have to recover the vmcore manually." + local _cmd="${1%% *}" + local _params="${1#* }" + + if [ "$_cmd" != "makedumpfile" ]; then + if is_raw_dump_target; then + echo "Warning: specifying a non-makedumpfile core collector, you will have to recover the vmcore manually." + fi + return fi + if is_ssh_dump_target || is_raw_dump_target; then - if [ "${1%% *}" = "makedumpfile" ]; then - ! strstr "$1" "-F" && { - perror_exit "The specified dump target needs makedumpfile \"-F\" option." - } + if ! strstr "$_params" "-F"; then + perror_exit "The specified dump target needs makedumpfile \"-F\" option." fi + _params="$_params vmcore" + else + _params="$_params vmcore dumpfile" + fi + + if ! $_cmd --check-params $_params; then + perror_exit "makedumpfile parameter check failed." fi } diff --git a/SOURCES/rhelonly-kexec-tools-2.0.20-makedumpfile-remove-lebl.patch b/SOURCES/rhelonly-kexec-tools-2.0.20-makedumpfile-remove-lebl.patch deleted file mode 100644 index ca63d82..0000000 --- a/SOURCES/rhelonly-kexec-tools-2.0.20-makedumpfile-remove-lebl.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 3beef142bc003d9cf2e957c6a21e51d661f9b13e Mon Sep 17 00:00:00 2001 -From: Pingfan Liu -Date: Thu, 28 Nov 2019 21:23:00 +0800 -Subject: [PATCH] makedumpfile: remove -lebl - -Signed-off-by: Pingfan Liu ---- - makedumpfile-1.6.6/Makefile | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/makedumpfile-1.6.6/Makefile b/makedumpfile-1.6.6/Makefile -index 1fdb628..df21b93 100644 ---- a/makedumpfile-1.6.6/Makefile -+++ b/makedumpfile-1.6.6/Makefile -@@ -50,7 +50,7 @@ OBJ_PART=$(patsubst %.c,%.o,$(SRC_PART)) - SRC_ARCH = arch/arm.c arch/arm64.c arch/x86.c arch/x86_64.c arch/ia64.c arch/ppc64.c arch/s390x.c arch/ppc.c arch/sparc64.c - OBJ_ARCH=$(patsubst %.c,%.o,$(SRC_ARCH)) - --LIBS = -ldw -lbz2 -lebl -ldl -lelf -lz -+LIBS = -ldw -lbz2 -ldl -lelf -lz - ifneq ($(LINKTYPE), dynamic) - LIBS := -static $(LIBS) - endif --- -2.20.1 - diff --git a/SOURCES/rhonly-kexec-tools-2.0.18-makedumpfile-arm64-Add-support-for-ARMv8.2-LVA-52-bi.patch b/SOURCES/rhonly-kexec-tools-2.0.18-makedumpfile-arm64-Add-support-for-ARMv8.2-LVA-52-bi.patch index dad84d1..71bdca4 100644 --- a/SOURCES/rhonly-kexec-tools-2.0.18-makedumpfile-arm64-Add-support-for-ARMv8.2-LVA-52-bi.patch +++ b/SOURCES/rhonly-kexec-tools-2.0.18-makedumpfile-arm64-Add-support-for-ARMv8.2-LVA-52-bi.patch @@ -42,10 +42,10 @@ Signed-off-by: Bhupesh Sharma makedumpfile.h | 1 + 3 files changed, 83 insertions(+), 29 deletions(-) -diff --git a/makedumpfile-1.6.6/arch/arm64.c b/makedumpfile-1.6.6/arch/arm64.c +diff --git a/makedumpfile-1.6.7/arch/arm64.c b/makedumpfile-1.6.7/arch/arm64.c index 0535193..5fcf59d 100644 ---- a/makedumpfile-1.6.6/arch/arm64.c -+++ b/makedumpfile-1.6.6/arch/arm64.c +--- a/makedumpfile-1.6.7/arch/arm64.c ++++ b/makedumpfile-1.6.7/arch/arm64.c @@ -41,6 +41,7 @@ typedef struct { static int pgtable_level; @@ -198,10 +198,10 @@ index 0535193..5fcf59d 100644 return TRUE; } -diff --git a/makedumpfile-1.6.6/makedumpfile.c b/makedumpfile-1.6.6/makedumpfile.c +diff --git a/makedumpfile-1.6.7/makedumpfile.c b/makedumpfile-1.6.7/makedumpfile.c index d76a435..c8906b5 100644 ---- a/makedumpfile-1.6.6/makedumpfile.c -+++ b/makedumpfile-1.6.6/makedumpfile.c +--- a/makedumpfile-1.6.7/makedumpfile.c ++++ b/makedumpfile-1.6.7/makedumpfile.c @@ -2313,6 +2313,7 @@ write_vmcoreinfo_data(void) WRITE_NUMBER("HUGETLB_PAGE_DTOR", HUGETLB_PAGE_DTOR); @@ -218,10 +218,10 @@ index d76a435..c8906b5 100644 READ_NUMBER("VA_BITS", VA_BITS); READ_NUMBER_UNSIGNED("PHYS_OFFSET", PHYS_OFFSET); READ_NUMBER_UNSIGNED("kimage_voffset", kimage_voffset); -diff --git a/makedumpfile-1.6.6/makedumpfile.h b/makedumpfile-1.6.6/makedumpfile.h +diff --git a/makedumpfile-1.6.7/makedumpfile.h b/makedumpfile-1.6.7/makedumpfile.h index 24b2f69..cccb52a 100644 ---- a/makedumpfile-1.6.6/makedumpfile.h -+++ b/makedumpfile-1.6.6/makedumpfile.h +--- a/makedumpfile-1.6.7/makedumpfile.h ++++ b/makedumpfile-1.6.7/makedumpfile.h @@ -1937,6 +1937,7 @@ struct number_table { long phys_base; long KERNEL_IMAGE_SIZE; diff --git a/SPECS/kexec-tools.spec b/SPECS/kexec-tools.spec index cfeae25..1ab590e 100644 --- a/SPECS/kexec-tools.spec +++ b/SPECS/kexec-tools.spec @@ -1,6 +1,6 @@ Name: kexec-tools Version: 2.0.20 -Release: 14%{?dist} +Release: 17%{?dist} License: GPLv2 Group: Applications/System Summary: The kexec/kdump userspace component @@ -13,7 +13,7 @@ Source4: kdump.sysconfig.i386 Source5: kdump.sysconfig.ppc64 Source7: mkdumprd Source8: kdump.conf -Source9: http://downloads.sourceforge.net/project/makedumpfile/makedumpfile/1.6.6/makedumpfile-1.6.6.tar.gz +Source9: http://downloads.sourceforge.net/project/makedumpfile/makedumpfile/1.6.7/makedumpfile-1.6.7.tar.gz Source10: kexec-kdump-howto.txt Source12: mkdumprd.8 Source13: 98-kexec.rules @@ -94,23 +94,23 @@ ExcludeArch: i686 Patch601: rhelonly-kexec-tools-2.0.16-koji-build-fail-workaround.patch Patch602: rhelonly-kexec-tools-2.0.18-eppic-fix-issues-with-hardening-flags.patch Patch603: rhonly-kexec-tools-2.0.18-makedumpfile-arm64-Add-support-for-ARMv8.2-LVA-52-bi.patch -Patch604: kexec-tools-2.0.20-makedumpfile-x86_64-Fix-incorrect-exclusion-by-e-option-wit.patch -Patch605: kexec-tools-2.0.20-Cleanup-remove-the-read_elf_kcore.patch -Patch606: kexec-tools-2.0.20-Fix-an-error-definition-about-the-variable-fname.patch -Patch607: kexec-tools-2.0.20-Cleanup-move-it-back-from-util_lib-elf_info.c.patch -Patch608: kexec-tools-2.0.20-Limit-the-size-of-vmcore-dmesg.txt-to-2G.patch -Patch609: kexec-tools-2.0.20-vmcore-dmesg-vmcore-dmesg.c-Fix-shifting-error-repor.patch -Patch610: kexec-tools-2.0.20-makedumpfile-Increase-SECTION_MAP_LAST_BIT-to-4.patch -Patch611: kexec-tools-2.0.20-makedumpfile-Fix-off-by-one-issue-in-exclude_nodata_pages.patch -Patch612: rhelonly-kexec-tools-2.0.20-makedumpfile-remove-lebl.patch -Patch613: kexec-tools-2.0.20-makedumpfile-assign-bitmap1-2-fd-for-subprocess-in-non-cycl.patch -Patch614: kexec-tools-2.0.20-kexec-add-variant-helper-functions-for-handling-memo.patch -Patch615: kexec-tools-2.0.20-arm64-kexec-allocate-memory-space-avoiding-reserved-.patch -Patch616: kexec-tools-2.0.20-arm64-kdump-deal-with-a-lot-of-resource-entries-in-p.patch -Patch617: kexec-tools-2.0.20-makedumpfile-arm64-fix-get_kaslr_offset_arm64-to-return-kas.patch -Patch618: kexec-tools-2.0.20-makedumpfile-Generalize-get_kaslr_offset_arm64-for-other-ar.patch -Patch619: kexec-tools-2.0.20-makedumpfile-Pass-0-to-get_kaslr_offset-in-find_kaslr_offse.patch -Patch620: kexec-tools-2.0.20-makedumpfile-s390-Use-get_kaslr_offset_general-for-s390x.patch +Patch604: kexec-tools-2.0.20-Cleanup-remove-the-read_elf_kcore.patch +Patch605: kexec-tools-2.0.20-Fix-an-error-definition-about-the-variable-fname.patch +Patch606: kexec-tools-2.0.20-Cleanup-move-it-back-from-util_lib-elf_info.c.patch +Patch607: kexec-tools-2.0.20-Limit-the-size-of-vmcore-dmesg.txt-to-2G.patch +Patch608: kexec-tools-2.0.20-vmcore-dmesg-vmcore-dmesg.c-Fix-shifting-error-repor.patch +Patch609: kexec-tools-2.0.20-kexec-add-variant-helper-functions-for-handling-memo.patch +Patch610: kexec-tools-2.0.20-arm64-kexec-allocate-memory-space-avoiding-reserved-.patch +Patch611: kexec-tools-2.0.20-arm64-kdump-deal-with-a-lot-of-resource-entries-in-p.patch + +# Patches 701 onward for makedumpfile +Patch701: kexec-tools-2.0.20-makedumpfile-PATCH-Remove-duplicated-variable-definitions.patch +Patch702: kexec-tools-2.0.20-makedumpfile-PATCH-cope-with-not-present-mem-section.patch +Patch703: kexec-tools-2.0.20-makedumpfile-PATCH-Introduce-check-params-option.patch +Patch704: kexec-tools-2.0.20-makedumpfile-PATCH-Makefile-Fix-build-errors-in-static-build.patch +Patch705: kexec-tools-2.0.20-makedumpfile-PATCH-Align-PMD_SECTION_MASK-with-PHYS_MASK.patch +Patch706: kexec-tools-2.0.20-makedumpfile-PATCH-Fix-cd_header-offset-overflow-with-large-pfn.patch + %description kexec-tools provides /usr/sbin/kexec binary that facilitates a new @@ -137,15 +137,12 @@ tar -z -x -v -f %{SOURCE19} %patch609 -p1 %patch610 -p1 %patch611 -p1 -%patch612 -p1 -%patch613 -p1 -%patch614 -p1 -%patch615 -p1 -%patch616 -p1 -%patch617 -p1 -%patch618 -p1 -%patch619 -p1 -%patch620 -p1 +%patch701 -p1 +%patch702 -p1 +%patch703 -p1 +%patch704 -p1 +%patch705 -p1 +%patch706 -p1 %ifarch ppc %define archdef ARCH=ppc @@ -174,8 +171,8 @@ cp %{SOURCE28} . make %ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 make -C eppic/libeppic -make -C makedumpfile-1.6.6 LINKTYPE=dynamic USELZO=on USESNAPPY=on -make -C makedumpfile-1.6.6 LDFLAGS="$LDFLAGS -I../eppic/libeppic -L../eppic/libeppic" eppic_makedumpfile.so +make -C makedumpfile-1.6.7 LINKTYPE=dynamic USELZO=on USESNAPPY=on +make -C makedumpfile-1.6.7 LDFLAGS="$LDFLAGS -I../eppic/libeppic -L../eppic/libeppic" eppic_makedumpfile.so %endif %install @@ -226,13 +223,13 @@ install -m 644 %{SOURCE16} $RPM_BUILD_ROOT%{_unitdir}/kdump.service install -m 755 -D %{SOURCE22} $RPM_BUILD_ROOT%{_prefix}/lib/systemd/system-generators/kdump-dep-generator.sh %ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 -install -m 755 makedumpfile-1.6.6/makedumpfile $RPM_BUILD_ROOT/usr/sbin/makedumpfile -install -m 644 makedumpfile-1.6.6/makedumpfile.8.gz $RPM_BUILD_ROOT/%{_mandir}/man8/makedumpfile.8.gz -install -m 644 makedumpfile-1.6.6/makedumpfile.conf.5.gz $RPM_BUILD_ROOT/%{_mandir}/man5/makedumpfile.conf.5.gz -install -m 644 makedumpfile-1.6.6/makedumpfile.conf $RPM_BUILD_ROOT/%{_sysconfdir}/makedumpfile.conf.sample -install -m 755 makedumpfile-1.6.6/eppic_makedumpfile.so $RPM_BUILD_ROOT/%{_libdir}/eppic_makedumpfile.so +install -m 755 makedumpfile-1.6.7/makedumpfile $RPM_BUILD_ROOT/usr/sbin/makedumpfile +install -m 644 makedumpfile-1.6.7/makedumpfile.8.gz $RPM_BUILD_ROOT/%{_mandir}/man8/makedumpfile.8.gz +install -m 644 makedumpfile-1.6.7/makedumpfile.conf.5.gz $RPM_BUILD_ROOT/%{_mandir}/man5/makedumpfile.conf.5.gz +install -m 644 makedumpfile-1.6.7/makedumpfile.conf $RPM_BUILD_ROOT/%{_sysconfdir}/makedumpfile.conf.sample +install -m 755 makedumpfile-1.6.7/eppic_makedumpfile.so $RPM_BUILD_ROOT/%{_libdir}/eppic_makedumpfile.so mkdir -p $RPM_BUILD_ROOT/usr/share/makedumpfile/eppic_scripts/ -install -m 644 makedumpfile-1.6.6/eppic_scripts/* $RPM_BUILD_ROOT/usr/share/makedumpfile/eppic_scripts/ +install -m 644 makedumpfile-1.6.7/eppic_scripts/* $RPM_BUILD_ROOT/usr/share/makedumpfile/eppic_scripts/ %endif %define remove_dracut_prefix() %(echo -n %1|sed 's/.*dracut-//g') @@ -371,6 +368,15 @@ done %endif %changelog +* Tue Apr 21 2020 Pingfan Liu - 2.0.20-17 +- mkdumprd: Use makedumpfile --check-params option + +* Thu Apr 9 2020 Pingfan Liu - 2.0.20-16 +- makedumpfile update to latest + +* Wed Apr 1 2020 Pingfan Liu - 2.0.20-15 +- makedumpfile rebase to 1.6.7 + * Tue Feb 18 2020 Pingfan Liu - 2.0.20-14 - kexec-tools/module-setup: Ensure eth devices get IP address for VLAN