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

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