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

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