Blame SOURCES/kexec-tools-2.0.22-makedumpfile-check-for-invalid-physical-address-proc-kcore-when-finding-max_paddr.patch

d43fe6
From 38d921a2ef50ebd36258097553626443ffe27496 Mon Sep 17 00:00:00 2001
d43fe6
From: Coiby Xu <coxu@redhat.com>
d43fe6
Date: Tue, 15 Jun 2021 18:26:31 +0800
d43fe6
Subject: [PATCH] check for invalid physical address of /proc/kcore
d43fe6
 when finding max_paddr
d43fe6
d43fe6
Kernel commit 464920104bf7adac12722035bfefb3d772eb04d8 ("/proc/kcore:
d43fe6
update physical address for kcore ram and text") sets an invalid paddr
d43fe6
(0xffffffffffffffff = -1) for PT_LOAD segments of not direct mapped
d43fe6
regions:
d43fe6
d43fe6
  $ readelf -l /proc/kcore
d43fe6
  ...
d43fe6
  Program Headers:
d43fe6
    Type           Offset             VirtAddr           PhysAddr
d43fe6
                   FileSiz            MemSiz              Flags  Align
d43fe6
    NOTE           0x0000000000000120 0x0000000000000000 0x0000000000000000
d43fe6
                   0x0000000000002320 0x0000000000000000         0x0
d43fe6
    LOAD           0x1000000000010000 0xd000000000000000 0xffffffffffffffff
d43fe6
                                                         ^^^^^^^^^^^^^^^^^^
d43fe6
                   0x0001f80000000000 0x0001f80000000000  RWE    0x10000
d43fe6
d43fe6
makedumpfile uses max_paddr to calculate the number of sections for
d43fe6
sparse memory model thus wrong number is obtained based on max_paddr
d43fe6
(-1).  This error could lead to the failure of copying /proc/kcore
d43fe6
for RHEL-8.5 on ppc64le machine [1]:
d43fe6
d43fe6
  $ makedumpfile /proc/kcore vmcore1
d43fe6
  get_mem_section: Could not validate mem_section.
d43fe6
  get_mm_sparsemem: Can't get the address of mem_section.
d43fe6
d43fe6
  makedumpfile Failed.
d43fe6
d43fe6
Let's check if the phys_start of the segment is a valid physical
d43fe6
address to fix this problem.
d43fe6
d43fe6
[1] https://bugzilla.redhat.com/show_bug.cgi?id=1965267
d43fe6
d43fe6
Reported-by: Xiaoying Yan <yiyan@redhat.com>
d43fe6
Signed-off-by: Coiby Xu <coxu@redhat.com>
d43fe6
---
d43fe6
 elf_info.c | 2 +-
d43fe6
 1 file changed, 1 insertion(+), 1 deletion(-)
d43fe6
d43fe6
diff --git a/makedumpfile-1.6.8/elf_info.c b/makedumpfile-1.6.8/elf_info.c
d43fe6
index e8affb7..bc24083 100644
d43fe6
--- a/makedumpfile-1.6.8/elf_info.c
d43fe6
+++ b/makedumpfile-1.6.8/elf_info.c
d43fe6
@@ -628,7 +628,7 @@ get_max_paddr(void)
d43fe6
 
d43fe6
 	for (i = 0; i < num_pt_loads; i++) {
d43fe6
 		pls = &pt_loads[i];
d43fe6
-		if (max_paddr < pls->phys_end)
d43fe6
+		if (pls->phys_start != NOT_PADDR && max_paddr < pls->phys_end)
d43fe6
 			max_paddr = pls->phys_end;
d43fe6
 	}
d43fe6
 	return max_paddr;
d43fe6
-- 
d43fe6
2.29.2
d43fe6