Blame SOURCES/kexec-tools-2.0.20-makedumpfile-Fix-off-by-one-issue-in-exclude_nodata_pages.patch

bda30f
From 56511628fa6714b189509b2842eadce0842bfeb5 Mon Sep 17 00:00:00 2001
bda30f
From: Mikhail Zaslonko <zaslonko@linux.ibm.com>
bda30f
Date: Mon, 4 Nov 2019 14:05:15 +0100
bda30f
Subject: [PATCH] [PATCH] Fix off-by-one issue in exclude_nodata_pages()
bda30f
bda30f
When building a dump bitmap (2nd bitmap) for the ELF dump, the last pfn
bda30f
of the cycle is always ignored in exclude_nodata_pages() function due to
bda30f
off-by-one error on cycle boundary check. Thus, the respective bit of
bda30f
the bitmap is never cleared.
bda30f
bda30f
That can lead to the error when such a pfn should not be dumpable (e.g.
bda30f
the last pfn of the ELF-load of zero filesize). Based on the bit in the
bda30f
bitmap the page is treated as dumpable in write_elf_pages_cyclic() function
bda30f
and the follow on error is triggered in write_elf_load_segment() function
bda30f
due to the failing sanity check of paddr_to_offset2():
bda30f
bda30f
   $ makedumpfile -E dump.elf dump.elf.E
bda30f
   Checking for memory holes                         : [100.0 %] |
bda30f
   write_elf_load_segment: Can't convert physaddr(7ffff000) to an offset.
bda30f
   makedumpfile Failed.
bda30f
bda30f
Signed-off-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
bda30f
---
bda30f
 makedumpfile.c | 2 +-
bda30f
 1 file changed, 1 insertion(+), 1 deletion(-)
bda30f
bda30f
diff --git a/makedumpfile-1.6.6/makedumpfile.c b/makedumpfile-1.6.6/makedumpfile.c
bda30f
index de0973f9e763..4a000112ba59 100644
bda30f
--- a/makedumpfile-1.6.6/makedumpfile.c
bda30f
+++ b/makedumpfile-1.6.6/makedumpfile.c
bda30f
@@ -4740,7 +4740,7 @@ exclude_nodata_pages(struct cycle *cycle)
bda30f
 		if (pfn < cycle->start_pfn)
bda30f
 			pfn = cycle->start_pfn;
bda30f
 		if (pfn_end >= cycle->end_pfn)
bda30f
-			pfn_end = cycle->end_pfn - 1;
bda30f
+			pfn_end = cycle->end_pfn;
bda30f
 		while (pfn < pfn_end) {
bda30f
 			clear_bit_on_2nd_bitmap(pfn, cycle);
bda30f
 			++pfn;
bda30f
-- 
bda30f
2.17.1
bda30f