Blame SOURCES/kexec-tools-2.0.14-makedumpfile-sadump-set-info-page_size-before-cache_init.patch

23ef29
From 90cc28fc9ab0a0076bcd9120b4f791401655280d Mon Sep 17 00:00:00 2001
23ef29
Message-Id: <90cc28fc9ab0a0076bcd9120b4f791401655280d.1496033260.git.panand@redhat.com>
23ef29
In-Reply-To: <302c16ede3723264ca0abb5eef9c9f553ffcfbd7.1496033260.git.panand@redhat.com>
23ef29
References: <302c16ede3723264ca0abb5eef9c9f553ffcfbd7.1496033260.git.panand@redhat.com>
23ef29
From: "Hatayama, Daisuke" <d.hatayama@jp.fujitsu.com>
23ef29
Date: Tue, 23 May 2017 02:52:51 +0000
23ef29
Subject: [PATCH 3/3] sadump: set info->page_size before cache_init()
23ef29
23ef29
Currently, makedumpfile results in Segmentation fault on sadump dump
23ef29
files as follows:
23ef29
23ef29
    # LANG=C makedumpfile -f --message-level=31 -ld31 -x vmlinux ./sadump_vmcore sadump_vmcore-ld31
23ef29
    sadump: read dump device as single partition
23ef29
    sadump: single partition configuration
23ef29
    page_size    : 4096
23ef29
    sadump: timezone information is missing
23ef29
    Segmentation fault
23ef29
23ef29
By bisect, I found that this issue is caused by the following commit
23ef29
that moves invocation of cache_init() in initial() a bit early:
23ef29
23ef29
    # git bisect bad
23ef29
    8e2834bac4f62da3894da297f083068431be6d80 is the first bad commit
23ef29
    commit 8e2834bac4f62da3894da297f083068431be6d80
23ef29
    Author: Pratyush Anand <panand@redhat.com>
23ef29
    Date:   Thu Mar 2 17:37:11 2017 +0900
23ef29
23ef29
        [PATCH v3 2/7] initial(): call cache_init() a bit early
23ef29
23ef29
        Call cache_init() before get_kcore_dump_loads(), because latter uses
23ef29
        cache_search().
23ef29
23ef29
        Call path is like this :
23ef29
        get_kcore_dump_loads() -> process_dump_load() -> vaddr_to_paddr() ->
23ef29
        vtop4_x86_64() -> readmem() -> cache_search()
23ef29
23ef29
        Signed-off-by: Pratyush Anand <panand@redhat.com>
23ef29
23ef29
    :100644 100644 6942047199deb09dd1fff2121e264584dbb05587 3b8e9810468de26b0d8b73d456f0bd4f3d3aa2fe M      makedumpfile.c
23ef29
23ef29
In this timing, on sadump vmcores, info->page_size has not been
23ef29
initialized yet so has 0. So, malloc() in cache_init() returns a chunk
23ef29
of 0 size. A bit later, info->page_size is initialized with 4096.
23ef29
Later processing on cache.c behaves assuming the chunk size is 8 *
23ef29
4096. This destroys objects allocated after the chunk, resulting in
23ef29
the above Segmentation fault.
23ef29
23ef29
To fix this issue, this commit moves setting info->page_size before
23ef29
cache_init().
23ef29
23ef29
Signed-off-by: HATAYAMA Daisuke <d.hatayama@jp.fujitsu.com>
23ef29
Cc: Pratyush Anand <panand@redhat.com>
23ef29
---
23ef29
 makedumpfile.c | 6 +++---
23ef29
 1 file changed, 3 insertions(+), 3 deletions(-)
23ef29
23ef29
diff --git a/makedumpfile-1.6.1/makedumpfile.c b/makedumpfile-1.6.1/makedumpfile.c
23ef29
index 9babf1a07154..2e4286c83b8f 100644
23ef29
--- a/makedumpfile-1.6.1/makedumpfile.c
23ef29
+++ b/makedumpfile-1.6.1/makedumpfile.c
23ef29
@@ -3921,6 +3921,9 @@ initial(void)
23ef29
 	if (!get_value_for_old_linux())
23ef29
 		return FALSE;
23ef29
 
23ef29
+	if (info->flag_sadump && !set_page_size(sadump_page_size()))
23ef29
+			return FALSE;
23ef29
+
23ef29
 	if (!is_xen_memory() && !cache_init())
23ef29
 		return FALSE;
23ef29
 
23ef29
@@ -3949,9 +3952,6 @@ initial(void)
23ef29
 			return FALSE;
23ef29
 		}
23ef29
 
23ef29
-		if (!set_page_size(sadump_page_size()))
23ef29
-			return FALSE;
23ef29
-
23ef29
 		if (!sadump_initialize_bitmap_memory())
23ef29
 			return FALSE;
23ef29
 
23ef29
-- 
23ef29
2.9.3
23ef29