makedumpfile: Do not proceed when get_num_dumpable_cyclic() fails

Backport from the makedumpfile devel branch in upstream.

commit c1b834f80311706db2b5070cbccdcba3aacc90e5
Author: Kazuhito Hagio <k-hagio@ab.jp.nec.com>
Date:   Tue Jul 23 11:50:52 2019 -0400

    [PATCH] Do not proceed when get_num_dumpable_cyclic() fails

    Currently, when get_num_dumpable_cyclic() fails and returns FALSE in
    create_dump_bitmap(), info->num_dumpable is set to 0 and makedumpfile
    proceeds to write a broken dumpfile slowly with incorrect progress
    indicator due to the value.

    It should not proceed when get_num_dumpable_cyclic() fails.

    Signed-off-by: Kazuhito Hagio <k-hagio@ab.jp.nec.com>

Signed-off-by: Kazuhito Hagio <k-hagio@ab.jp.nec.com>
Acked-by: Dave Young <dyoung@redhat.com>
Acked-by: Kairui Song <kasong@redhat.com>
This commit is contained in:
Kazuhito Hagio 2019-08-02 10:59:37 -04:00 committed by Kairui Song
parent 4a0f9763c0
commit 076b839dd4
2 changed files with 46 additions and 0 deletions

View File

@ -0,0 +1,44 @@
From c1b834f80311706db2b5070cbccdcba3aacc90e5 Mon Sep 17 00:00:00 2001
From: Kazuhito Hagio <k-hagio@ab.jp.nec.com>
Date: Tue, 23 Jul 2019 11:50:52 -0400
Subject: [PATCH 1/2] Do not proceed when get_num_dumpable_cyclic() fails
Currently, when get_num_dumpable_cyclic() fails and returns FALSE in
create_dump_bitmap(), info->num_dumpable is set to 0 and makedumpfile
proceeds to write a broken dumpfile slowly with incorrect progress
indicator due to the value.
It should not proceed when get_num_dumpable_cyclic() fails.
Signed-off-by: Kazuhito Hagio <k-hagio@ab.jp.nec.com>
---
makedumpfile.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/makedumpfile.c b/makedumpfile.c
index d76a4358a2b2..88df788fd6e7 100644
--- a/makedumpfile-1.6.6/makedumpfile.c
+++ b/makedumpfile-1.6.6/makedumpfile.c
@@ -7344,7 +7344,8 @@ create_dump_bitmap(void)
if (!prepare_bitmap2_buffer())
goto out;
- info->num_dumpable = get_num_dumpable_cyclic();
+ if (!(info->num_dumpable = get_num_dumpable_cyclic()))
+ goto out;
if (!info->flag_elf_dumpfile)
free_bitmap2_buffer();
@@ -7362,7 +7363,8 @@ create_dump_bitmap(void)
if (!create_2nd_bitmap(&cycle))
goto out;
- info->num_dumpable = get_num_dumpable_cyclic();
+ if (!(info->num_dumpable = get_num_dumpable_cyclic()))
+ goto out;
}
ret = TRUE;
--
2.18.1

View File

@ -92,6 +92,7 @@ Patch0: kexec-tools-2.0.20-fix-broken-multiboot2-buliding-for-i386.patch
# #
# Patches 601 onward are generic patches # Patches 601 onward are generic patches
# #
Patch601: kexec-tools-2.0.20-makedumpfile-Do-not-proceed-when-get_num_dumpable_cyclic-fails.patch
%description %description
kexec-tools provides /sbin/kexec binary that facilitates a new kexec-tools provides /sbin/kexec binary that facilitates a new
@ -108,6 +109,7 @@ tar -z -x -v -f %{SOURCE9}
tar -z -x -v -f %{SOURCE19} tar -z -x -v -f %{SOURCE19}
%patch0 -p1 %patch0 -p1
%patch601 -p1
%ifarch ppc %ifarch ppc
%define archdef ARCH=ppc %define archdef ARCH=ppc