From 68f9e69a1693466e8535dcc8945826470c742439 Mon Sep 17 00:00:00 2001 From: Kazuhito Hagio Date: Mon, 9 Sep 2019 16:55:15 -0400 Subject: [PATCH] makedumpfile: x86_64: Fix incorrect exclusion by -e option with KASLR Backport from the makedumpfile devel branch in upstream. commit aa5ab4cf6c7335392094577380d2eaee8a0a8d52 Author: Kazuhito Hagio Date: Thu Aug 29 12:26:34 2019 -0400 [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 Signed-off-by: Kazuhito Hagio Acked-by: Kairui Song --- ...-Fix-incorrect-exclusion-by-e-option.patch | 41 +++++++++++++++++++ kexec-tools.spec | 2 + 2 files changed, 43 insertions(+) create mode 100644 kexec-tools-2.0.20-makedumpfile-x86_64-Fix-incorrect-exclusion-by-e-option.patch diff --git a/kexec-tools-2.0.20-makedumpfile-x86_64-Fix-incorrect-exclusion-by-e-option.patch b/kexec-tools-2.0.20-makedumpfile-x86_64-Fix-incorrect-exclusion-by-e-option.patch new file mode 100644 index 0000000..fa60b6a --- /dev/null +++ b/kexec-tools-2.0.20-makedumpfile-x86_64-Fix-incorrect-exclusion-by-e-option.patch @@ -0,0 +1,41 @@ +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 3c0fdc5..4eeaf49 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.20.1 + diff --git a/kexec-tools.spec b/kexec-tools.spec index 71898da..3fd41a7 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -77,6 +77,7 @@ Patch0: kexec-tools-2.0.20-fix-broken-multiboot2-buliding-for-i386.patch # # Patches 101 through 200 are meant for x86_64 kexec-tools enablement # +Patch101: kexec-tools-2.0.20-makedumpfile-x86_64-Fix-incorrect-exclusion-by-e-option.patch # # Patches 301 through 400 are meant for ppc64 kexec-tools enablement @@ -112,6 +113,7 @@ tar -z -x -v -f %{SOURCE19} %patch0 -p1 %patch601 -p1 %patch602 -p1 +%patch101 -p1 %ifarch ppc %define archdef ARCH=ppc