Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2480910imj; Mon, 11 Feb 2019 03:41:03 -0800 (PST) X-Google-Smtp-Source: AHgI3IaH8+ZFCjfguXDjyqt5a9YJoq9+tRnePJUgP3C3oPWnEj6zHj/woPXaG6eryTXi6KwZzi82 X-Received: by 2002:a17:902:2ec1:: with SMTP id r59mr37584508plb.254.1549885263521; Mon, 11 Feb 2019 03:41:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549885263; cv=none; d=google.com; s=arc-20160816; b=dViFqFm6UNNktmFJ1ODyATDy80Vv7U/S/xebDbzURTyCc5XVLikJ/2UJZVG3YivUOE 2AlCf0CPoxzeHVnXjD1L6moypQ7GfWNOhZgTXNc+9Dia3+hPd3mqAjoqfGAxjO8ml9Gx mc7V904STIOf12I4ROurIKru2OAdXbW/5o51T0drjOyxwJj1/0m568GUialAY+ZuKoe3 uvsXPfhYuK18u0UzibI6xL/ITX6UogSLZ3x7tgQ57VcdGlg0GUBe8C7riVgxvJwY+seq gNn4x8VRMFT2gUH1BPRk7HSjEAp4VcOgHBVAqYLx8M4xK5E3/cqkTm+lJfFm7q9pxKig 0b9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=+IsEkd/ZMwpdBpE6nFFh4qrK/KiRL5J2KgEBPPqn/PM=; b=Xd7nDKn8N2KwnATeL6uIUh00VMqpSG0Ajf/vsVG/KYRjW3yN3k+/DA1Xg8KftS87cm AXk4NVGaw80ePV4PzzmaAMnw26+dtZndyq9p4vvHM+tw55Wjg7c+xSHq2veO7ww1klaQ WO2D1XCT8SwD5j9LcEFr5mHw9NIu2o8KXQjYMuhxkEEZ4U7otTAg24aJWtLfIzx7XJ6s gkJKYQKIsKuVPdYDMg6SroJa+rEpxSdasmdpyKTtR9f9Voz6bO87mLgBudckRhMsfIKI oy00JKijNbt91Vy97JVELgHlMEx+yKHrN56xV/zXNsRjB/7o33pnxqwqvsDJ7hglo2+B a40A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qTTw001Q; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id az4si7367948plb.231.2019.02.11.03.40.46; Mon, 11 Feb 2019 03:41:03 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qTTw001Q; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726892AbfBKLkl (ORCPT + 99 others); Mon, 11 Feb 2019 06:40:41 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:32995 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726041AbfBKLkl (ORCPT ); Mon, 11 Feb 2019 06:40:41 -0500 Received: by mail-pl1-f195.google.com with SMTP id y10so2718232plp.0 for ; Mon, 11 Feb 2019 03:40:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=+IsEkd/ZMwpdBpE6nFFh4qrK/KiRL5J2KgEBPPqn/PM=; b=qTTw001QgWRa3oBZKZ3Lg0R8FpkxxIJeA9BC9g0DT+hGLnQb8puIfueDqgsQzqnauy vVfP6idBjn3Quuwg0jnj7c3tjkkk1wk1z0aOq/mOVAAtuR8qCOVW00uJf0e8ckUKfKdG kldP4xtM9RZ1RHflNbbKZdjVFojyU+qe3CE0/NsHJs0L/bvBUlwJGMw4BxrTKZrw+9ZI xuCaE7nb01IQWqUTslStmg9js/eDPOnkABVEKHVurJMJz0cenMOT7PoJQCoGylKXSuDl +mn3AWS8G/pOSQcJqhn7ecabnNSFrSkJRdsplcOI/A0k15keia1EOfXGAmXcwc+Y8xkN Pk0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=+IsEkd/ZMwpdBpE6nFFh4qrK/KiRL5J2KgEBPPqn/PM=; b=lIkowupxO1cFT5WPp1bmV/k8bplrsfkflbDTNLB2eY4CW3kpk9H4IOdMDzgdT9So3n M+P4Aqrf9mkgfbARHYEkDqDSkdFDangg51LqtMRs0nrNOBwTqfYH3klfK98VVqYXNl5F MpTRkoASkhT3tKwyQrrgmC+2+upz6e6vUmqGhr1lnx5Xj29CBw78HjGMDMn8p+4bqXtz yeRZ9qwfYD6P8NYXO0fmmoq3V0c8xw1fAhreKC7TKKRwbvNQS0HvGJyzO3KRsB+e5ASY I7AqMIKFWCL5o1ftILap2Tfetupr23v7vRCx5zdiaW8LjMeIMBsjPRvNC1QPkjXEohy8 0Jlw== X-Gm-Message-State: AHQUAuaTvCB5nEcm1b4BA1vpr1uH4FzFtqRUNNSShUGH0whA8EB74nlt D/9juk7g7xYHKgUP3gjA1I4ejWnCuPin1VuwV+0= X-Received: by 2002:a17:902:1a2:: with SMTP id b31mr37434660plb.87.1549885240370; Mon, 11 Feb 2019 03:40:40 -0800 (PST) MIME-Version: 1.0 References: <20181022134048.19693-1-david.engraf@sysgo.com> <20181030151805.5519-1-david.engraf@sysgo.com> <20190208140810.76ef6c25825a5644d9625f0a@linux-foundation.org> <744e7bcb-9315-0283-67c5-c2cb2d094251@sysgo.com> <28139206-7fed-e00e-8f52-47e68655963d@sysgo.com> In-Reply-To: <28139206-7fed-e00e-8f52-47e68655963d@sysgo.com> From: Andy Shevchenko Date: Mon, 11 Feb 2019 13:40:29 +0200 Message-ID: Subject: Re: [PATCH RESEND] initramfs: cleanup incomplete rootfs To: David Engraf Cc: Andrew Morton , Dominik Brodowski , Greg Kroah-Hartman , Philippe Ombredanne , Arnd Bergmann , Luc Van Oostenryck , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 11, 2019 at 10:49 AM David Engraf wrote: > On 11.02.19 at 08:56, David Engraf wrote: > > On 09.02.19 at 11:35, Andy Shevchenko wrote: > >> On Sat, Feb 9, 2019 at 12:08 AM Andrew Morton > >> wrote: > >>> On Fri, 8 Feb 2019 21:45:21 +0200 Andy Shevchenko > >>> wrote: > >>>> On Tue, Oct 30, 2018 at 5:22 PM David Engraf > >>>> wrote: > >>>>> > >>>>> 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. > >>>> > >>>> This breaks my setup where I have U-boot provided more size of > >>>> initramfs than needed. This allows a bit of flexibility to increase or > >>>> decrease initramfs compressed image without taking care of bootloader. > >>>> The proper solution is to do this if we sure that we didn't get enough > >>>> memory, otherwise I can't consider the error fatal to clean up rootfs. > >>> > >>> OK, thanks. Maybe David can suggest a fix - I'll queue up a revert > >>> meanwhile. > >>> > >>> I don't really understand the failure. Why does an oversized initramfs > >>> cause unpack_to_rootfs() to fail? > >> > >> In my case I have got "Junk in compressed archive". I don't know (I > >> would check if needed) which exact condition I got since there are > >> three places with this message. The file itself smaller than the size > >> passed through bootparam. So, when decomression is finished > >> (successfully!) we still have a garbarge in the memory which is not > >> related to archive. Message per se is okay to have, though I consider > >> this non-fatal. > > > > I can reproduce this special case. The unpacking decompresses the whole > > size instead of checking the archive size. I will have a look how to get > > the real archive size. > > I did some checks and manually increased the initramfs size but I always > get the following kernel panic: We need to be on the same page here. There are two sizes of initramfs compressed archive: 1) actual file size; 2) what is declared by boot loader and provided via boot parameters. In my case I have the 2) bigger than the actual file size. Kernel decompresses the initramfs, prints an error that there is junk, which is understandable and continues to run init, etc. > Kernel panic - not syncing: junk in compressed archive > ---[ end Kernel panic - not syncing: junk in compressed archive > > The panic was not introduced by my patch. Could you please check if you > get a panic as well or is your rootfs just empty? Since your patch applied I get rootfs clean followed by inability to find working init. So, I have a panic with different reason. > I also had a look at the decompression in unpack_to_rootfs(). This > function already ensures unpacking only the real size of the archive. > But it is called in a loop, thus it unpacks the first archive and then > tries to unpack the reset of the data which are garbage in my case. > Is it intended to allow extracting multiple archives as rootfs? Yes. You can chain up to 64 archives IIRC. > If not > we could remove the loop and unpack only the first archive. Otherwise we > could ignore errors when the first archive was extracted without errors. Not the first one, but all the first one_s_. Means, that at least one, when it's first(!), is decompressed successfully. -- With Best Regards, Andy Shevchenko