[kexec-tools] Fix free bitmap_buffer_cyclic error.

WANG Chao wangchao at fedoraproject.org
Wed Jul 16 06:57:16 UTC 2014


commit 598e09b6b608530703cfc762bce6193439689f3e
Author: Baoquan He <bhe at redhat.com>
Date:   Tue Jul 15 15:50:22 2014 +0800

    Fix free bitmap_buffer_cyclic error.
    
    This is a backport of the following upstream commit. It is about freeing
    the wrong bitmap thing, it could increase the risk of OOM when system is
    in an edge of OOM.
    
    commit 0e7b1a6e3c1919c9222b662d458637ddf802dd04
    Author: Arthur Zou <zzou at redhat.com>
    Date:   Wed May 7 17:54:16 2014 +0900
    
        [PATCH v3] Fix free bitmap_buffer_cyclic error.
    
        Description:
        In create_dump_bitmap() and write_kdump_pages_and_bitmap_cyclic(),
        What should be freed is info->partial_bitmap instead of info->bitmap.
    
        Solution:
        Add two functions to free the bitmap_buffer_cyclic. info->partial_bitmap1
        is freed by free_bitmap1_buffer_cyclic(). info->partial_bitmap2 is
        freed by free_bitmap2_buffer_cyclic(). At the same time, remove
        thoes frees that free partial_bitmap1 or partial_bitmap2 at the end
        of main() because partial_bitmap1 and partial_bitmap2 has been freed
        after dump file has been written out, so there is no need to free it
        again at the end of main.
    
        Signed-off-by: Arthur Zou <zzou at redhat.com>
    
    Signed-off-by: Baoquan He <bhe at redhat.com>
    Acked-by: Vivek Goyal <vgoyal at redhat.com>

 ...pfile-Fix-free-bitmap_buffer_cyclic-error.patch |  111 ++++++++++++++++++++
 kexec-tools.spec                                   |    2 +
 2 files changed, 113 insertions(+), 0 deletions(-)
---
diff --git a/kexec-tools-2.0.4-makedumpfile-Fix-free-bitmap_buffer_cyclic-error.patch b/kexec-tools-2.0.4-makedumpfile-Fix-free-bitmap_buffer_cyclic-error.patch
new file mode 100644
index 0000000..f95d1c9
--- /dev/null
+++ b/kexec-tools-2.0.4-makedumpfile-Fix-free-bitmap_buffer_cyclic-error.patch
@@ -0,0 +1,111 @@
+From 0e7b1a6e3c1919c9222b662d458637ddf802dd04 Mon Sep 17 00:00:00 2001
+From: Arthur Zou <zzou at redhat.com>
+Date: Wed, 7 May 2014 17:54:16 +0900
+Subject: [PATCH] [PATCH v3] Fix free bitmap_buffer_cyclic error.
+
+Description:
+In create_dump_bitmap() and write_kdump_pages_and_bitmap_cyclic(),
+What should be freed is info->partial_bitmap instead of info->bitmap.
+
+Solution:
+Add two functions to free the bitmap_buffer_cyclic. info->partial_bitmap1
+is freed by free_bitmap1_buffer_cyclic(). info->partial_bitmap2 is
+freed by free_bitmap2_buffer_cyclic(). At the same time, remove
+thoes frees that free partial_bitmap1 or partial_bitmap2 at the end
+of main() because partial_bitmap1 and partial_bitmap2 has been freed
+after dump file has been written out, so there is no need to free it
+again at the end of main.
+
+Signed-off-by: Arthur Zou <zzou at redhat.com>
+Signed-off-by: Baoquan He <bhe at redhat.com>
+---
+ makedumpfile.c | 38 ++++++++++++++++++++++++++++++--------
+ 1 file changed, 30 insertions(+), 8 deletions(-)
+
+diff --git a/makedumpfile.c b/makedumpfile.c
+index 16081a5..ef8a750 100644
+--- a/makedumpfile-1.5.6/makedumpfile.c
++++ b/makedumpfile-1.5.6/makedumpfile.c
+@@ -5130,6 +5130,31 @@ free_bitmap_buffer(void)
+ 	free_bitmap2_buffer();
+ }
+ 
++void
++free_bitmap1_buffer_cyclic()
++{
++	if (info->partial_bitmap1 != NULL){
++		free(info->partial_bitmap1);
++		info->partial_bitmap1 = NULL;
++	}
++}
++
++void
++free_bitmap2_buffer_cyclic()
++{
++	if (info->partial_bitmap2 != NULL){
++		free(info->partial_bitmap2);
++		info->partial_bitmap2 = NULL;
++	}
++}
++
++void
++free_bitmap_buffer_cyclic()
++{
++	free_bitmap1_buffer_cyclic();
++	free_bitmap2_buffer_cyclic();
++}
++
+ int
+ create_dump_bitmap(void)
+ {
+@@ -5147,8 +5172,7 @@ create_dump_bitmap(void)
+ 				goto out;
+ 
+ 			info->num_dumpable = get_num_dumpable_cyclic();
+-
+-			free_bitmap2_buffer();
++			free_bitmap2_buffer_cyclic();
+ 		}
+ 
+ 	} else {
+@@ -6190,6 +6214,8 @@ write_elf_pages_cyclic(struct cache_data *cd_header, struct cache_data *cd_page)
+ 	if (!write_cache_bufsz(cd_page))
+ 		return FALSE;
+ 
++	free_bitmap_buffer_cyclic();
++
+ 	/*
+ 	 * print [100 %]
+ 	 */
+@@ -6947,7 +6973,7 @@ write_kdump_pages_and_bitmap_cyclic(struct cache_data *cd_header, struct cache_d
+ 	}
+ 
+ 
+-	free_bitmap1_buffer();
++	free_bitmap1_buffer_cyclic();
+ 
+ 	if (!prepare_bitmap2_buffer_cyclic())
+ 		return FALSE;
+@@ -6970,7 +6996,7 @@ write_kdump_pages_and_bitmap_cyclic(struct cache_data *cd_header, struct cache_d
+ 			return FALSE;
+ 	}
+ 
+-
++	free_bitmap2_buffer_cyclic();
+ 
+ 	gettimeofday(&tv_start, NULL);
+ 
+@@ -9349,10 +9375,6 @@ out:
+ 			free(info->splitting_info);
+ 		if (info->p2m_mfn_frame_list != NULL)
+ 			free(info->p2m_mfn_frame_list);
+-		if (info->partial_bitmap1 != NULL)
+-			free(info->partial_bitmap1);
+-		if (info->partial_bitmap2 != NULL)
+-			free(info->partial_bitmap2);
+ 		free(info);
+ 	}
+ 	free_elf_info();
+-- 
+1.8.5.3
+
diff --git a/kexec-tools.spec b/kexec-tools.spec
index 55a1bdb..aa0e78c 100644
--- a/kexec-tools.spec
+++ b/kexec-tools.spec
@@ -77,6 +77,7 @@ ExcludeArch: aarch64
 Patch601: kexec-tools-2.0.3-disable-kexec-test.patch
 Patch602: kexec-tools-2.0.4-makedumpfile-Fix-Makefile-for-eppic_makedumpfile.so-build.patch
 Patch603: kexec-tools-2.0.4-makedumpfile-Introduce-the-mdf_pfn_t-type.patch
+Patch604: kexec-tools-2.0.4-makedumpfile-Fix-free-bitmap_buffer_cyclic-error.patch
 
 %description
 kexec-tools provides /sbin/kexec binary that facilitates a new
@@ -115,6 +116,7 @@ tar -z -x -v -f %{SOURCE23}
 %patch601 -p1
 %patch602 -p1
 %patch603 -p1
+%patch604 -p1
 
 tar -z -x -v -f %{SOURCE13}
 


More information about the scm-commits mailing list