Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp2247218ima; Mon, 22 Oct 2018 06:50:31 -0700 (PDT) X-Google-Smtp-Source: ACcGV62lBHP1qdF0pI+a3Bq50ISLuyOvBvZUpv9MtOc0tfHcbTiFFJQBc/udqNgR8/9Sk7Au6N6t X-Received: by 2002:a17:902:1129:: with SMTP id d38-v6mr39678630pla.270.1540216231477; Mon, 22 Oct 2018 06:50:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540216231; cv=none; d=google.com; s=arc-20160816; b=flAa/XsFWSUydtSmIOTFd/0HDBWQtyZXY5F2XW/iJHjPOAejpRyDn8I3l7l3DCvIDi XlwTNvySh34m5JkY9I4jbkWldfphXdpLaAyYHRh9SFIFATMJ97EA/xIiHsDeUeLc+UMS HGJNwBfLsBMwwpgI87fFkMnPwuKYgJvOsIvmW3q9A3tI3Zp6ciFo6GEViLSXzlhvoSPb KjSjeCdx4/fVkMRl0AhTcLn0tDQHeXEs6pq09PDSAngJrUiQ0BwbJW4tfcIU5ZeWCJh3 b2TRJNFg6RQhQs/kf1QjYN1w3I6jBlZs0MS2Su18YcuPCkWrZ/vHWvm7Tao6ZStUxOMg Jnmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=eHPkGlnhL+bCyypwWxJSU+JWJl4nAGomzmPaHWmIfhk=; b=Fdr0Khjt1MFvNCi8gpthwNILlhTDrQXpBgeuvfTCV2uU2uv/SsLkJKiHUV+M6xFdV+ kr3hogfWS9zgl8dvtqei2VJlP7/uSdvt7ZCTi+FZ5yaAfZOMw0BXWnGPQfWzXsZHRJc6 tVJ1HSqbOz8K/4OgM10mheVPytbitJIgcHqgcQjsypKTo3hTGaXIPQQfhnQx733H6dgv zRktTQUNRtuMeINLzYF/b9lYARJH+tnR4/fze/Wf/yoa78wI3FdzWMYWHUCf5K7eEhbv pDZKwOqFb0Mq5Fs0fsq63N055Jk0an7EQZ3CZhfYy9L6EDRiBXDU/21dyjUUpI0wql4h CvYQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b20-v6si34203369pgk.360.2018.10.22.06.50.15; Mon, 22 Oct 2018 06:50:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727873AbeJVWHb (ORCPT + 99 others); Mon, 22 Oct 2018 18:07:31 -0400 Received: from mail.sysgo.com ([176.9.12.79]:56058 "EHLO mail.sysgo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727210AbeJVWHa (ORCPT ); Mon, 22 Oct 2018 18:07:30 -0400 X-Greylist: delayed 448 seconds by postgrey-1.27 at vger.kernel.org; Mon, 22 Oct 2018 18:07:30 EDT From: David Engraf To: linux@dominikbrodowski.net, akpm@linux-foundation.org, pombredanne@nexb.com, gregkh@linuxfoundation.org, arnd@arndb.de, luc.vanoostenryck@gmail.com Cc: linux-kernel@vger.kernel.org, David Engraf Subject: [PATCH] initramfs: cleanup incomplete rootfs Date: Mon, 22 Oct 2018 15:40:48 +0200 Message-Id: <20181022134048.19693-1-david.engraf@sysgo.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: David Engraf --- init/initramfs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/init/initramfs.c b/init/initramfs.c index 640557788026..aa3a46cfcb4e 100644 --- a/init/initramfs.c +++ b/init/initramfs.c @@ -548,7 +548,6 @@ static void __init free_initrd(void) initrd_end = 0; } -#ifdef CONFIG_BLK_DEV_RAM #define BUF_SIZE 1024 static void __init clean_rootfs(void) { @@ -595,7 +594,6 @@ static void __init clean_rootfs(void) ksys_close(fd); kfree(buf); } -#endif static int __init populate_rootfs(void) { @@ -638,8 +636,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 } -- 2.17.1