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

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