Skip to contentSkip to conversation

makedumpfile: output files filling ramdisk

PATCH In review Cliff Wickman 2 participants 2 messages Jun 15, 2010 – Jun 16, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 makedumpfile: output files filling ramdisk

makedumpfile's path FILENAME_BITMAP "/tmp/..." causes it to try to write bitmap files to the ramdisk. These can be very large if the machine has lots of memory, and so writing the file can fail.

makedumpfile is exec'd by kdumptool. And kdumptool should chroot to its --root directory. But if the intent is to avoid this problem it doesn't seem to work. That may be the proper fix, rather than the below.

A TMPDIR environment variable is set in the script /lib/mkinitrd/scripts/boot-kdump.sh. So this patch assumes that the FILENAME_BITMAP path should be based at TMPDIR.

Also below, LATEST_VERSION is updated to KERNEL_VERSION(2, 6, 32), as this seems to work on 2.6.32 and prevents a makedumpfile grumbling.

Diffed against makedumpfile-1.3.5

---
 makedumpfile.c |   13 ++++++++++---
 makedumpfile.h |    4 ++--
 2 files changed, 12 insertions(+), 5 deletions(-)
makedumpfile.c +10 -3
Index: makedumpfile-1.3.5/makedumpfile.c
===================================================================
@@ -933,14 +933,21 @@ int
 open_dump_bitmap(void)
 {
 	int i, fd;
+	char *tmpname;
 
-	if ((info->name_bitmap
-	    = (char *)malloc(sizeof(FILENAME_BITMAP))) == NULL) {
+	tmpname = getenv("TMPDIR");
+	if (!tmpname)
+		tmpname = "/tmp";
+
+	if ((info->name_bitmap = (char *)malloc(sizeof(FILENAME_BITMAP) +
+						strlen(tmpname) + 1)) == NULL) {
 		ERRMSG("Can't allocate memory for the filename. %s\n",
 		    strerror(errno));
 		return FALSE;
 	}
-	strcpy(info->name_bitmap, FILENAME_BITMAP);
+	strcpy(info->name_bitmap, tmpname);
+	strcat(info->name_bitmap, "/");
+	strcat(info->name_bitmap, FILENAME_BITMAP);
 	if ((fd = mkstemp(info->name_bitmap)) < 0) {
 		ERRMSG("Can't open the bitmap file(%s). %s\n",
 		    info->name_bitmap, strerror(errno));
makedumpfile.h +2 -2
Index: makedumpfile-1.3.5/makedumpfile.h
===================================================================
@@ -230,7 +230,7 @@ do { \
 #define BUFSIZE_FGETS		(1500)
 #define BUFSIZE_BITMAP		(4096)
 #define PFN_BUFBITMAP		(BITPERBYTE*BUFSIZE_BITMAP)
-#define FILENAME_BITMAP		"/tmp/kdump_bitmapXXXXXX"
+#define FILENAME_BITMAP		"kdump_bitmapXXXXXX"
 #define FILENAME_STDOUT		"STDOUT"
 
 /*
@@ -449,7 +449,7 @@ do { \
 #define KVER_MIN_SHIFT 16
 #define KERNEL_VERSION(x,y,z) (((x) << KVER_MAJ_SHIFT) | ((y) << KVER_MIN_SHIFT) | (z))
 #define OLDEST_VERSION		KERNEL_VERSION(2, 6, 15)/* linux-2.6.15 */
-#define LATEST_VERSION		KERNEL_VERSION(2, 6, 31)/* linux-2.6.31 */
+#define LATEST_VERSION		KERNEL_VERSION(2, 6, 32)/* linux-2.6.32 */
 
 /*
  * vmcoreinfo in /proc/vmcore

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#1 lore raw

Hi,

Thank you for your patch.
We'll merge and test it.

But I have a question.
What is your tested CPU arch? (x86/x86_64/ia64...)

And could you separate this patch like below?
o [1/2] output files filling ramdisk
o [2/2] update LATEST_VERSION

Signature · 7 lines
Regards,
Masayuki Igawa


From: Cliff Wickman <[email protected]>
Subject: [PATCH] makedumpfile: output files filling ramdisk
Date: Tue, 15 Jun 2010 14:49:25 -0500
Quoted 76 lines

makedumpfile's path FILENAME_BITMAP "/tmp/..." causes it to try to write bitmap files to the ramdisk. These can be very large if the machine has lots of memory, and so writing the file can fail.

makedumpfile is exec'd by kdumptool. And kdumptool should chroot to its --root directory. But if the intent is to avoid this problem it doesn't seem to work. That may be the proper fix, rather than the below.

A TMPDIR environment variable is set in the script /lib/mkinitrd/scripts/boot-kdump.sh. So this patch assumes that the FILENAME_BITMAP path should be based at TMPDIR.

Also below, LATEST_VERSION is updated to KERNEL_VERSION(2, 6, 32), as this seems to work on 2.6.32 and prevents a makedumpfile grumbling.

Diffed against makedumpfile-1.3.5

---
 makedumpfile.c |   13 ++++++++++---
 makedumpfile.h |    4 ++--
 2 files changed, 12 insertions(+), 5 deletions(-)

Index: makedumpfile-1.3.5/makedumpfile.c
===================================================================

makedumpfile.c +10 -3
@@ -933,14 +933,21 @@ int
 open_dump_bitmap(void)
 {
 	int i, fd;
+	char *tmpname;
 
-	if ((info->name_bitmap
-	    = (char *)malloc(sizeof(FILENAME_BITMAP))) == NULL) {
+	tmpname = getenv("TMPDIR");
+	if (!tmpname)
+		tmpname = "/tmp";
+
+	if ((info->name_bitmap = (char *)malloc(sizeof(FILENAME_BITMAP) +
+						strlen(tmpname) + 1)) == NULL) {
 		ERRMSG("Can't allocate memory for the filename. %s\n",
 		    strerror(errno));
 		return FALSE;
 	}
-	strcpy(info->name_bitmap, FILENAME_BITMAP);
+	strcpy(info->name_bitmap, tmpname);
+	strcat(info->name_bitmap, "/");
+	strcat(info->name_bitmap, FILENAME_BITMAP);
 	if ((fd = mkstemp(info->name_bitmap)) < 0) {
 		ERRMSG("Can't open the bitmap file(%s). %s\n",
 		    info->name_bitmap, strerror(errno));

Index: makedumpfile-1.3.5/makedumpfile.h
===================================================================

makedumpfile.h +2 -2
@@ -230,7 +230,7 @@ do { \
 #define BUFSIZE_FGETS		(1500)
 #define BUFSIZE_BITMAP		(4096)
 #define PFN_BUFBITMAP		(BITPERBYTE*BUFSIZE_BITMAP)
-#define FILENAME_BITMAP		"/tmp/kdump_bitmapXXXXXX"
+#define FILENAME_BITMAP		"kdump_bitmapXXXXXX"
 #define FILENAME_STDOUT		"STDOUT"
 
 /*
@@ -449,7 +449,7 @@ do { \
 #define KVER_MIN_SHIFT 16
 #define KERNEL_VERSION(x,y,z) (((x) << KVER_MAJ_SHIFT) | ((y) << KVER_MIN_SHIFT) | (z))
 #define OLDEST_VERSION		KERNEL_VERSION(2, 6, 15)/* linux-2.6.15 */
-#define LATEST_VERSION		KERNEL_VERSION(2, 6, 31)/* linux-2.6.31 */
+#define LATEST_VERSION		KERNEL_VERSION(2, 6, 32)/* linux-2.6.32 */
 
 /*
  * vmcoreinfo in /proc/vmcore
Quoted 5 lines

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec