Received: from list by lists.gnu.org with archive (Exim 4.71) id 1abjkV-0004yT-Kh for mharc-grub-devel@gnu.org; Fri, 04 Mar 2016 02:02:07 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58748) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1abjkS-0004xq-3f for grub-devel@gnu.org; Fri, 04 Mar 2016 02:02:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1abjkO-0007HC-R3 for grub-devel@gnu.org; Fri, 04 Mar 2016 02:02:04 -0500 Received: from smtp.nue.novell.com ([195.135.221.5]:37863) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1abjkO-0007Gu-HL for grub-devel@gnu.org; Fri, 04 Mar 2016 02:02:00 -0500 Received: from nwb-ext-pat.microfocus.com ([10.120.13.103]) by smtp.nue.novell.com with ESMTP (TLS encrypted); Fri, 04 Mar 2016 08:01:58 +0100 Received: from linux-dsax.tai.apac.novell.com (nwb-a10-snat.microfocus.com [10.120.13.202]) by nwb-ext-pat.microfocus.com with ESMTP (TLS encrypted); Fri, 04 Mar 2016 07:01:35 +0000 Date: Fri, 4 Mar 2016 14:50:04 +0800 From: Michael Chang To: The development of GNU GRUB Subject: Re: [PATCH] fix attempt to seek outside of the file error when parsing xen ELF notes Message-ID: <20160304065004.GA12009@linux-dsax.tai.apac.novell.com> Mail-Followup-To: The development of GNU GRUB References: <20160303073328.GA32595@leap-t5810.suse> <56D87FB7.8070108@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <56D87FB7.8070108@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 195.135.221.5 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Mar 2016 07:02:05 -0000 On Thu, Mar 03, 2016 at 09:17:27PM +0300, Andrei Borzenkov wrote: > 03.03.2016 10:33, Michael Chang пишет: > > The kernel bzImage payload length appears to be incorrectly minus by 4 when > > trying to grub_file_offset_open for the uncompressed vmlinux image. If gzip > > used as compressor it will lead to the file->size read from offset of crc32 > > instead of the uncompressed image size. > > > > [1] > > http://www.onicos.com/staff/iz/formats/gzip.html > > --- > > grub-core/loader/i386/xen_file.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/grub-core/loader/i386/xen_file.c b/grub-core/loader/i386/xen_file.c > > index 5836218..37f9ad8 100644 > > --- a/grub-core/loader/i386/xen_file.c > > +++ b/grub-core/loader/i386/xen_file.c > > @@ -55,11 +55,11 @@ grub_xen_file (grub_file_t file) > > grub_dprintf ("xen", "found bzimage payload 0x%llx-0x%llx\n", > > (unsigned long long) (lh.setup_sects + 1) * 512 > > + lh.payload_offset, > > - (unsigned long long) lh.payload_length - 4); > > + (unsigned long long) lh.payload_length); > > > > off_file = grub_file_offset_open (file, (lh.setup_sects + 1) * 512 > > + lh.payload_offset, > > - lh.payload_length - 4); > > + lh.payload_length); > > if (!off_file) > > goto fail; > > > > > Looks strange indeed. I wonder what was original intention, code looked > this way from the very beginning. May be it is required with some other > format? I also wonder that possibility. But looking into other formats it looks to me more likely a bug than intended. Unless there's unexpected padding in the end of payload, it looks to me that xz would also be failed in footer sanity check as the last stream block's footer magic is discarded by that size of payload_length - 4. Thanks, Michael