Blob Blame History Raw
From 56511628fa6714b189509b2842eadce0842bfeb5 Mon Sep 17 00:00:00 2001
From: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Date: Mon, 4 Nov 2019 14:05:15 +0100
Subject: [PATCH] [PATCH] Fix off-by-one issue in exclude_nodata_pages()

When building a dump bitmap (2nd bitmap) for the ELF dump, the last pfn
of the cycle is always ignored in exclude_nodata_pages() function due to
off-by-one error on cycle boundary check. Thus, the respective bit of
the bitmap is never cleared.

That can lead to the error when such a pfn should not be dumpable (e.g.
the last pfn of the ELF-load of zero filesize). Based on the bit in the
bitmap the page is treated as dumpable in write_elf_pages_cyclic() function
and the follow on error is triggered in write_elf_load_segment() function
due to the failing sanity check of paddr_to_offset2():

   $ makedumpfile -E dump.elf dump.elf.E
   Checking for memory holes                         : [100.0 %] |
   write_elf_load_segment: Can't convert physaddr(7ffff000) to an offset.
   makedumpfile Failed.

Signed-off-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
---
 makedumpfile.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/makedumpfile-1.6.6/makedumpfile.c b/makedumpfile-1.6.6/makedumpfile.c
index de0973f9e763..4a000112ba59 100644
--- a/makedumpfile-1.6.6/makedumpfile.c
+++ b/makedumpfile-1.6.6/makedumpfile.c
@@ -4740,7 +4740,7 @@ exclude_nodata_pages(struct cycle *cycle)
 		if (pfn < cycle->start_pfn)
 			pfn = cycle->start_pfn;
 		if (pfn_end >= cycle->end_pfn)
-			pfn_end = cycle->end_pfn - 1;
+			pfn_end = cycle->end_pfn;
 		while (pfn < pfn_end) {
 			clear_bit_on_2nd_bitmap(pfn, cycle);
 			++pfn;
-- 
2.17.1