Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp4856154imd; Tue, 30 Oct 2018 08:22:47 -0700 (PDT) X-Google-Smtp-Source: AJdET5d4oiteT8xoLpyJS+gAoIbgw+Z74NyQSqcw/7wT2MLO2dD6BmpcaISLeuXXrUPcEurxym8B X-Received: by 2002:a63:4c6:: with SMTP id 189mr18553109pge.391.1540912967782; Tue, 30 Oct 2018 08:22:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540912967; cv=none; d=google.com; s=arc-20160816; b=y6fionBjjIxWnJKP6nXSZZcr8U5+42TErL5tsH/jKMeBWavT2aJAaHc+q83DEPMQww 0Vgl4i5oUUnhbb9PQsU8YV3bJZcVNQ8HaJNBqiuQ5MTK5eSlAbuCaot8UL3vRyww08Me cQpeMLWJACEysDGn5oi/eI5b587pNdAlPvmdjBHH++vyUAhBLow5IJxrk8QiE3cQz2uA 5Kp6rCjzRTxhOJir4vd0f0cc4sdis+QwAEQ4/JIsrsw7rt60yJxxDOS5kTSWhGDxOvV+ y8yOGooqPwC3uqa5yQ0jqL7RG35Lg/BuLP/WUcy1Sa/YhPvMcPwMH35KPjBT1yxyipIv gluw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=eHPkGlnhL+bCyypwWxJSU+JWJl4nAGomzmPaHWmIfhk=; b=nTB4/ePL6y86b+1oqzPIainyU6Ioll7+6ViQ72zIvfNZqe82hotNDbBhwSbNSuYtSD PEcQgY/tfl0YcUZKS4jVAilwlP5WpjbfgqSvfgS0F1/dB7p7QdBtGWZ5lxROwioWaM4B 8TSOPDsaslGCbsQMSTAT7ZmlIw9aPCNlWwe4c7laLghQzdeYHg+LMEySUunC5iXJS1NB eJoCKFvUGzAwwfCNN3iDpikO+NOz7QH+yOs4Dkgm2HSgcWRL1AJv+a39/EjF+jdwb1Dy pu7b5FcWPUpNne/rFOWc41eYz63StkgrOjJzXYfZS22/fvcLt6llmB4jYFtydrmyUK2O 0VBg== 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 a8-v6si23279387plz.94.2018.10.30.08.22.18; Tue, 30 Oct 2018 08:22:47 -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 S1727507AbeJaAMQ (ORCPT + 99 others); Tue, 30 Oct 2018 20:12:16 -0400 Received: from mail.sysgo.com ([176.9.12.79]:47898 "EHLO mail.sysgo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726223AbeJaAMP (ORCPT ); Tue, 30 Oct 2018 20:12:15 -0400 From: David Engraf To: linux@dominikbrodowski.net, akpm@linux-foundation.org, gregkh@linuxfoundation.org, pombredanne@nexb.com, arnd@arndb.de, luc.vanoostenryck@gmail.com Cc: linux-kernel@vger.kernel.org, David Engraf Subject: [PATCH RESEND] initramfs: cleanup incomplete rootfs Date: Tue, 30 Oct 2018 16:18:05 +0100 Message-Id: <20181030151805.5519-1-david.engraf@sysgo.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181022134048.19693-1-david.engraf@sysgo.com> References: <20181022134048.19693-1-david.engraf@sysgo.com> 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