Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2539408imj; Mon, 11 Feb 2019 04:41:28 -0800 (PST) X-Google-Smtp-Source: AHgI3IbruOz4GDU7/z6QFAnUKeMunxc+htHo22deawKIAC9MQq72w0a8lgMrytXR+w+bR8Kb6RIb X-Received: by 2002:a63:dc54:: with SMTP id f20mr23317348pgj.410.1549888888542; Mon, 11 Feb 2019 04:41:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549888888; cv=none; d=google.com; s=arc-20160816; b=LlS5jSAiRxdX9AOq8FWkiAQ4aVg9rTm79ABLHhNtXY6boB/15147yk5aldswfFwlYI D4ovuSF2C/mNDiuREx7oXKIGxGMkCEDF0o9dywRvf7hfuxl3DSLNi3tLGDQc498WmrWe QAV3B2vLFaMxVUEdygLqwFmkJzM6nr2FPyy26XrQM5durvTt6h9CTfGddLPLq/WQ58dC t/TChVSVU47VmVFVOk8Esddo+DKjc9S2uD0y4yakXbFj5IEEJ5xFxKumKwbUpOmXtBTl 8EGiSTCYc9wGW4SAq/INagvYdSTN0CQLCUtkqN9HAJgGNpjweeOc2e/tcP7HWGptFKT2 tgxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:date:message-id:from :references:cc:to:subject; bh=L+VbJWN1Wh6WJk8f3Jb7tuZ6BYI72F4mt9y93rDdaAM=; b=HkMv4AfZHrivcO6kTfzfukAGkWf5a71ziTJ02iwAOt8KuewyghdJ5LU/M4363NrP/k rzeoqK+17wFEARUzP2b4h1ZvN3C5NQnCxQBmvyl7O+SCsTl6aWSv/eYMd7xeGJAR5VB8 Q0E8RQWiCvAxXorQKCB4RVIK5fOjTfw6fuw1Iu/nhxfyzm/ITlJg/Yp+x+A8msqYUyYn L8M5kau8Q/xKSLlUR8U/4puQMXjU/f5mIEcWfJmJKYNNkSEOPB7uz6cl3HPNl/Giuq9x fsxKLe0QPFRPahmm98azLjhoBuUAuWSuYJWeWPcjoaKAO6hhywwmw95JQ91pqlY/W3op TEFQ== 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 7si10517363pll.297.2019.02.11.04.41.13; Mon, 11 Feb 2019 04:41:28 -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; 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 S1727548AbfBKMkk (ORCPT + 99 others); Mon, 11 Feb 2019 07:40:40 -0500 Received: from mail.sysgo.com ([176.9.12.79]:36668 "EHLO mail.sysgo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727309AbfBKMkj (ORCPT ); Mon, 11 Feb 2019 07:40:39 -0500 Subject: Re: [PATCH RESEND] initramfs: cleanup incomplete rootfs To: Andy Shevchenko Cc: Andrew Morton , Dominik Brodowski , Greg Kroah-Hartman , Philippe Ombredanne , Arnd Bergmann , Luc Van Oostenryck , Linux Kernel Mailing List 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> From: David Engraf Message-ID: <84d387a3-0519-d50b-2c5d-98c10f694376@sysgo.com> Date: Mon, 11 Feb 2019 13:40:35 +0100 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11.02.19 at 12:40, Andy Shevchenko wrote: > 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. Ok got it. When the memory behind the actual file size is clear (0x0) the decompression doesn't complain and just ignores the padding. Any other data will be interpreted as a new archive and thus you'll see the error message. Is it possible for you to fill the padding after the actual file size with 0x00 ? Best regards - David >> 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. >