[patch 45/58] initramfs: cleanup incomplete rootfs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: David Engraf <david.engraf@xxxxxxxxx>
Subject: initramfs: cleanup incomplete rootfs

Unpacking an external initrd may fail e.g.  not enough memory.  This leads
to an incomplete rootfs because some files might be extracted already. 
Fixed by cleaning the rootfs so the kernel is not using an incomplete
rootfs.

Link: http://lkml.kernel.org/r/20181030151805.5519-1-david.engraf@xxxxxxxxx
Signed-off-by: David Engraf <david.engraf@xxxxxxxxx>
Cc: Dominik Brodowski <linux@xxxxxxxxxxxxxxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
Cc: Philippe Ombredanne <pombredanne@xxxxxxxx>
Cc: Arnd Bergmann <arnd@xxxxxxxx>
Cc: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 init/initramfs.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

--- a/init/initramfs.c~initramfs-cleanup-incomplete-rootfs
+++ a/init/initramfs.c
@@ -550,7 +550,6 @@ skip:
 	initrd_end = 0;
 }
 
-#ifdef CONFIG_BLK_DEV_RAM
 #define BUF_SIZE 1024
 static void __init clean_rootfs(void)
 {
@@ -597,7 +596,6 @@ static void __init clean_rootfs(void)
 	ksys_close(fd);
 	kfree(buf);
 }
-#endif
 
 static int __init populate_rootfs(void)
 {
@@ -640,8 +638,10 @@ static int __init populate_rootfs(void)
 		printk(KERN_INFO "Unpacking initramfs...\n");
 		err = unpack_to_rootfs((char *)initrd_start,
 			initrd_end - initrd_start);
-		if (err)
+		if (err) {
 			printk(KERN_EMERG "Initramfs unpacking failed: %s\n", err);
+			clean_rootfs();
+		}
 		free_initrd();
 #endif
 	}
_



[Index of Archives]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux