Blame SOURCES/kexec-tools-2.0.20-makedumpfile-PATCH-Avoid-false-positive-failure-in-mem_seciton-va.patch

f8bec6
From 81b79c514ff6fc881f1df4cb04ecb2d7cb22badc Mon Sep 17 00:00:00 2001
f8bec6
From: Kazuhito Hagio <k-hagio-ab@nec.com>
f8bec6
Date: Wed, 19 Feb 2020 12:48:13 -0500
f8bec6
Subject: [PATCH] [PATCH] Avoid false-positive failure in mem_seciton
f8bec6
 validation
f8bec6
f8bec6
Currently in get_mem_section(), we check whether SYMBOL(mem_section)
f8bec6
is a pointer to the array or a pointer to the pointer to the array
f8bec6
for some cases.
f8bec6
f8bec6
However, with commit e113f1c974c8 ("[PATCH] cope with not-present
f8bec6
mem section") relaxing the check, there was a report that the function
f8bec6
failed because both of two validate_mem_section() calls return TRUE.
f8bec6
f8bec6
Avoid the false-positive failure by not calling the second one if the
f8bec6
first one returns TRUE.
f8bec6
f8bec6
Reported-by: Pingfan Liu <piliu@redhat.com>
f8bec6
Acked-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
f8bec6
Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
f8bec6
---
f8bec6
 makedumpfile.c | 29 ++++++-----------------------
f8bec6
 1 file changed, 6 insertions(+), 23 deletions(-)
f8bec6
f8bec6
diff --git a/makedumpfile-1.6.7/makedumpfile.c b/makedumpfile-1.6.7/makedumpfile.c
f8bec6
index f5860a1..4c4251e 100644
f8bec6
--- a/makedumpfile-1.6.7/makedumpfile.c
f8bec6
+++ b/makedumpfile-1.6.7/makedumpfile.c
f8bec6
@@ -3472,7 +3472,6 @@ static int
f8bec6
 get_mem_section(unsigned int mem_section_size, unsigned long *mem_maps,
f8bec6
 		unsigned int num_section)
f8bec6
 {
f8bec6
-	unsigned long mem_section_ptr;
f8bec6
 	int ret = FALSE;
f8bec6
 	unsigned long *mem_sec = NULL;
f8bec6
 
f8bec6
@@ -3484,34 +3483,18 @@ get_mem_section(unsigned int mem_section_size, unsigned long *mem_maps,
f8bec6
 	ret = validate_mem_section(mem_sec, SYMBOL(mem_section),
f8bec6
 				   mem_section_size, mem_maps, num_section);
f8bec6
 
f8bec6
-	if (is_sparsemem_extreme()) {
f8bec6
-		int symbol_valid = ret;
f8bec6
-		int pointer_valid;
f8bec6
-		int mem_maps_size = sizeof(*mem_maps) * num_section;
f8bec6
-		unsigned long *mem_maps_ex = NULL;
f8bec6
+	if (!ret && is_sparsemem_extreme()) {
f8bec6
+		unsigned long mem_section_ptr;
f8bec6
+
f8bec6
 		if (!readmem(VADDR, SYMBOL(mem_section), &mem_section_ptr,
f8bec6
 			     sizeof(mem_section_ptr)))
f8bec6
 			goto out;
f8bec6
 
f8bec6
-		if ((mem_maps_ex = malloc(mem_maps_size)) == NULL) {
f8bec6
-			ERRMSG("Can't allocate memory for the mem_maps. %s\n",
f8bec6
-			    strerror(errno));
f8bec6
-			goto out;
f8bec6
-		}
f8bec6
+		ret = validate_mem_section(mem_sec, mem_section_ptr,
f8bec6
+				mem_section_size, mem_maps, num_section);
f8bec6
 
f8bec6
-		pointer_valid = validate_mem_section(mem_sec,
f8bec6
-						     mem_section_ptr,
f8bec6
-						     mem_section_size,
f8bec6
-						     mem_maps_ex,
f8bec6
-						     num_section);
f8bec6
-		if (pointer_valid)
f8bec6
-			memcpy(mem_maps, mem_maps_ex, mem_maps_size);
f8bec6
-		if (mem_maps_ex)
f8bec6
-			free(mem_maps_ex);
f8bec6
-		ret = symbol_valid ^ pointer_valid;
f8bec6
-		if (!ret) {
f8bec6
+		if (!ret)
f8bec6
 			ERRMSG("Could not validate mem_section.\n");
f8bec6
-		}
f8bec6
 	}
f8bec6
 out:
f8bec6
 	if (mem_sec != NULL)
f8bec6
-- 
f8bec6
2.7.5
f8bec6