makedumpfile: x86_64: Fix incorrect exclusion by -e option with KASLR

Backport from the makedumpfile devel branch in upstream.

commit aa5ab4cf6c7335392094577380d2eaee8a0a8d52
Author: Kazuhito Hagio <k-hagio@ab.jp.nec.com>
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 <k-hagio@ab.jp.nec.com>

Signed-off-by: Kazuhito Hagio <k-hagio@ab.jp.nec.com>
Acked-by: Kairui Song <kasong@redhat.com>
This commit is contained in:
Kazuhito Hagio 2019-09-09 16:55:15 -04:00 committed by Kairui Song
parent 680c0d3414
commit 68f9e69a16
2 changed files with 43 additions and 0 deletions

View File

@ -0,0 +1,41 @@
From aa5ab4cf6c7335392094577380d2eaee8a0a8d52 Mon Sep 17 00:00:00 2001
From: Kazuhito Hagio <k-hagio@ab.jp.nec.com>
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 <k-hagio@ab.jp.nec.com>
---
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

View File

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