kexec-tools/SOURCES/kexec-tools-2.0.20-makedump...

81 lines
2.6 KiB
Diff

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