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

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