Blame SOURCES/kexec-tools-2.0.22-makedumpfile-check-for-invalid-physical-address-proc-kcore-when-making-ELF-dumpfile.patch

52edda
From 9a6f589d99dcef114c89fde992157f5467028c8f Mon Sep 17 00:00:00 2001
52edda
From: Tao Liu <ltao@redhat.com>
52edda
Date: Fri, 18 Jun 2021 18:28:04 +0800
52edda
Subject: [PATCH] check for invalid physical address of /proc/kcore
52edda
 when making ELF dumpfile
52edda
52edda
Previously when executing makedumpfile with -E option against
52edda
/proc/kcore, makedumpfile will fail:
52edda
52edda
  # makedumpfile -E -d 31 /proc/kcore kcore.dump
52edda
  ...
52edda
  write_elf_load_segment: Can't convert physaddr(ffffffffffffffff) to an offset.
52edda
52edda
  makedumpfile Failed.
52edda
52edda
It's because /proc/kcore contains PT_LOAD program headers which have
52edda
physaddr (0xffffffffffffffff).  With -E option, makedumpfile will
52edda
try to convert the physaddr to an offset and fails.
52edda
52edda
Skip the PT_LOAD program headers which have such physaddr.
52edda
52edda
Signed-off-by: Tao Liu <ltao@redhat.com>
52edda
Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
52edda
---
52edda
 makedumpfile.c | 2 +-
52edda
 1 file changed, 1 insertion(+), 1 deletion(-)
52edda
52edda
diff --git a/makedumpfile-1.6.8/makedumpfile.c b/makedumpfile-1.6.8/makedumpfile.c
52edda
index 894c88e..fcb571f 100644
52edda
--- a/makedumpfile-1.6.8/makedumpfile.c
52edda
+++ b/makedumpfile-1.6.8/makedumpfile.c
52edda
@@ -7764,7 +7764,7 @@ write_elf_pages_cyclic(struct cache_data *cd_header, struct cache_data *cd_page)
52edda
 		if (!get_phdr_memory(i, &load))
52edda
 			return FALSE;
52edda
 
52edda
-		if (load.p_type != PT_LOAD)
52edda
+		if (load.p_type != PT_LOAD || load.p_paddr == NOT_PADDR)
52edda
 			continue;
52edda
 
52edda
 		off_memory= load.p_offset;
52edda
-- 
52edda
2.29.2
52edda