From 6348884a9d80c0aeedc21618624b6e2c463c05c5 Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Tue, 3 May 2022 14:44:10 +0200 Subject: [PATCH] Avoid false-positive mem_section validation with vmlinux Resolves: bz2081323 Upstream: github.com/makedumpfile/makedumpfile.git Conflicts: None commit 6d0d95ecc04a70f8448d562ff0fbbae237f5c929 Author: Kazuhito Hagio Date: Thu Apr 21 08:58:29 2022 +0900 [PATCH] Avoid false-positive mem_section validation with vmlinux Currently get_mem_section() validates if SYMBOL(mem_section) is the address of the mem_section array first. But there was a report that the first validation wrongly returned TRUE with -x vmlinux and SPARSEMEM_EXTREME (4.15+) on s390x. This leads to crash failing statup with the following seek error: crash: seek error: kernel virtual address: 67fffc2800 type: "memory section root table" Skip the first validation when satisfying the conditions. Reported-by: Dave Wysochanski Signed-off-by: Kazuhito Hagio Reviewed-and-Tested-by: Philipp Rudo Reviewed-by: Pingfan Liu Signed-off-by: Philipp Rudo --- ..._mem_section_validation_with_vmlinux.patch | 76 +++++++++++++++++++ kexec-tools.spec | 2 + 2 files changed, 78 insertions(+) create mode 100644 kexec-tools-2.0.23-makedumpfile-Avoid_false_positive_mem_section_validation_with_vmlinux.patch diff --git a/kexec-tools-2.0.23-makedumpfile-Avoid_false_positive_mem_section_validation_with_vmlinux.patch b/kexec-tools-2.0.23-makedumpfile-Avoid_false_positive_mem_section_validation_with_vmlinux.patch new file mode 100644 index 0000000..db1cf3b --- /dev/null +++ b/kexec-tools-2.0.23-makedumpfile-Avoid_false_positive_mem_section_validation_with_vmlinux.patch @@ -0,0 +1,76 @@ + commit 6d0d95ecc04a70f8448d562ff0fbbae237f5c929 + Author: Kazuhito Hagio + Date: Thu Apr 21 08:58:29 2022 +0900 + + [PATCH] Avoid false-positive mem_section validation with vmlinux + + Currently get_mem_section() validates if SYMBOL(mem_section) is the address + of the mem_section array first. But there was a report that the first + validation wrongly returned TRUE with -x vmlinux and SPARSEMEM_EXTREME + (4.15+) on s390x. This leads to crash failing statup with the following + seek error: + + crash: seek error: kernel virtual address: 67fffc2800 type: "memory section root table" + + Skip the first validation when satisfying the conditions. + + Reported-by: Dave Wysochanski + Signed-off-by: Kazuhito Hagio + Reviewed-and-Tested-by: Philipp Rudo + Reviewed-by: Pingfan Liu + + diff --git a/makedumpfile-1.7.0/makedumpfile.c b/makedumpfile-1.7.0/makedumpfile.c + index a2f45c84cee3ba57ce3d3cf3f1905e6a03f4fd09..65d1c7c2f02c9ae8ead9de0f0217235fe72b3ca7 100644 + --- a/makedumpfile-1.7.0/makedumpfile.c + +++ b/makedumpfile-1.7.0/makedumpfile.c + @@ -3698,6 +3698,22 @@ validate_mem_section(unsigned long *mem_sec, + return ret; + } + + +/* + + * SYMBOL(mem_section) varies with the combination of memory model and + + * its source: + + * + + * SPARSEMEM + + * vmcoreinfo: address of mem_section root array + + * -x vmlinux: address of mem_section root array + + * + + * SPARSEMEM_EXTREME v1 + + * vmcoreinfo: address of mem_section root array + + * -x vmlinux: address of mem_section root array + + * + + * SPARSEMEM_EXTREME v2 (with 83e3c48729d9 and a0b1280368d1) 4.15+ + + * vmcoreinfo: address of mem_section root array + + * -x vmlinux: address of pointer to mem_section root array + + */ + static int + get_mem_section(unsigned int mem_section_size, unsigned long *mem_maps, + unsigned int num_section) + @@ -3710,12 +3726,27 @@ get_mem_section(unsigned int mem_section_size, unsigned long *mem_maps, + strerror(errno)); + return FALSE; + } + + + + /* + + * There was a report that the first validation wrongly returned TRUE + + * with -x vmlinux and SPARSEMEM_EXTREME v2 on s390x, so skip it. + + * Howerver, leave the fallback validation as it is for the -i option. + + */ + + if (is_sparsemem_extreme() && info->name_vmlinux) { + + unsigned long flag = 0; + + if (get_symbol_type_name("mem_section", DWARF_INFO_GET_SYMBOL_TYPE, + + NULL, &flag) + + && !(flag & TYPE_ARRAY)) + + goto skip_1st_validation; + + } + + + ret = validate_mem_section(mem_sec, SYMBOL(mem_section), + mem_section_size, mem_maps, num_section); + + if (!ret && is_sparsemem_extreme()) { + unsigned long mem_section_ptr; + + +skip_1st_validation: + if (!readmem(VADDR, SYMBOL(mem_section), &mem_section_ptr, + sizeof(mem_section_ptr))) + goto out; diff --git a/kexec-tools.spec b/kexec-tools.spec index 1b76665..f8aff28 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -124,6 +124,7 @@ Patch604: ./kexec-tools-2.0.23-02-_PATCH_v2_2_3_use_pointer_arithmetics_for_dump Patch605: ./kexec-tools-2.0.23-03-_PATCH_v2_3_3_use_cycle_detection_when_parsing_the_prink_log_buf.patch Patch606: ./kexec-tools-2.0.23-04-_PATCH_print_error_when_reading_with_unsupported_compression.patch Patch607: ./kexec-tools-2.0.23-05-util_lib_elf_info_harden_parsing_of_printk_buffer.patch +Patch608: ./kexec-tools-2.0.23-makedumpfile-Avoid_false_positive_mem_section_validation_with_vmlinux.patch %description kexec-tools provides /sbin/kexec binary that facilitates a new @@ -151,6 +152,7 @@ tar -z -x -v -f %{SOURCE19} %patch605 -p1 %patch606 -p1 %patch607 -p1 +%patch608 -p1 %ifarch ppc %define archdef ARCH=ppc