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

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