Backport from upstream.
commit 9a6f589d99dcef114c89fde992157f5467028c8f
Author: Tao Liu <ltao(a)redhat.com>
Date: Fri Jun 18 18:28:04 2021 +0800
[PATCH] check for invalid physical address of /proc/kcore when making ELF dumpfile
Previously when executing makedumpfile with -E option against
/proc/kcore, makedumpfile will fail:
# makedumpfile -E -d 31 /proc/kcore kcore.dump
...
write_elf_load_segment: Can't convert physaddr(ffffffffffffffff) to an offset.
makedumpfile Failed.
It's because /proc/kcore contains PT_LOAD program headers which have
physaddr (0xffffffffffffffff). With -E option, makedumpfile will
try to convert the physaddr to an offset and fails.
Skip the PT_LOAD program headers which have such physaddr.
Signed-off-by: Tao Liu <ltao(a)redhat.com>
Signed-off-by: Kazuhito Hagio <k-hagio-ab(a)nec.com>
Signed-off-by: Tao Liu <ltao(a)redhat.com>
---
...-proc-kcore-when-making-ELF-dumpfile.patch | 43 +++++++++++++++++++
kexec-tools.spec | 2 +
2 files changed, 45 insertions(+)
create mode 100644
kexec-tools-2.0.22-makedumpfile-check-for-invalid-physical-address-proc-kcore-when-making-ELF-dumpfile.patch
diff --git
a/kexec-tools-2.0.22-makedumpfile-check-for-invalid-physical-address-proc-kcore-when-making-ELF-dumpfile.patch
b/kexec-tools-2.0.22-makedumpfile-check-for-invalid-physical-address-proc-kcore-when-making-ELF-dumpfile.patch
new file mode 100644
index 0000000..8cf780c
--- /dev/null
+++
b/kexec-tools-2.0.22-makedumpfile-check-for-invalid-physical-address-proc-kcore-when-making-ELF-dumpfile.patch
@@ -0,0 +1,43 @@
+From 9a6f589d99dcef114c89fde992157f5467028c8f Mon Sep 17 00:00:00 2001
+From: Tao Liu <ltao(a)redhat.com>
+Date: Fri, 18 Jun 2021 18:28:04 +0800
+Subject: [PATCH] check for invalid physical address of /proc/kcore
+ when making ELF dumpfile
+
+Previously when executing makedumpfile with -E option against
+/proc/kcore, makedumpfile will fail:
+
+ # makedumpfile -E -d 31 /proc/kcore kcore.dump
+ ...
+ write_elf_load_segment: Can't convert physaddr(ffffffffffffffff) to an offset.
+
+ makedumpfile Failed.
+
+It's because /proc/kcore contains PT_LOAD program headers which have
+physaddr (0xffffffffffffffff). With -E option, makedumpfile will
+try to convert the physaddr to an offset and fails.
+
+Skip the PT_LOAD program headers which have such physaddr.
+
+Signed-off-by: Tao Liu <ltao(a)redhat.com>
+Signed-off-by: Kazuhito Hagio <k-hagio-ab(a)nec.com>
+---
+ makedumpfile.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/makedumpfile-1.6.9/makedumpfile.c b/makedumpfile-1.6.9/makedumpfile.c
+index 894c88e..fcb571f 100644
+--- a/makedumpfile-1.6.9/makedumpfile.c
++++ b/makedumpfile-1.6.9/makedumpfile.c
+@@ -7764,7 +7764,7 @@ write_elf_pages_cyclic(struct cache_data *cd_header, struct
cache_data *cd_page)
+ if (!get_phdr_memory(i, &load))
+ return FALSE;
+
+- if (load.p_type != PT_LOAD)
++ if (load.p_type != PT_LOAD || load.p_paddr == NOT_PADDR)
+ continue;
+
+ off_memory= load.p_offset;
+--
+2.29.2
+
diff --git a/kexec-tools.spec b/kexec-tools.spec
index 5aeda5a..f14b02f 100644
--- a/kexec-tools.spec
+++ b/kexec-tools.spec
@@ -102,6 +102,7 @@ Requires: systemd-udev%{?_isa}
#
Patch601: ./kexec-tools-2.0.22-makedumpfile-Increase-SECTION_MAP_LAST_BIT-to-5.patch
Patch602:
./kexec-tools-2.0.22-makedumpfile-check-for-invalid-physical-address-proc-kcore-when-finding-max_paddr.patch
+Patch603:
./kexec-tools-2.0.22-makedumpfile-check-for-invalid-physical-address-proc-kcore-when-making-ELF-dumpfile.patch
%description
kexec-tools provides /sbin/kexec binary that facilitates a new
@@ -119,6 +120,7 @@ tar -z -x -v -f %{SOURCE19}
%patch601 -p1
%patch602 -p1
+%patch603 -p1
%ifarch ppc
%define archdef ARCH=ppc
--
2.29.2