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

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