Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1KYzqj-0005L7-FV for mharc-grub-devel@gnu.org; Fri, 29 Aug 2008 05:00:57 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KYzqh-0005I8-7w for grub-devel@gnu.org; Fri, 29 Aug 2008 05:00:55 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KYzqe-0005EK-6d for grub-devel@gnu.org; Fri, 29 Aug 2008 05:00:54 -0400 Received: from [199.232.76.173] (port=54800 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KYzqd-0005Dr-Nv for grub-devel@gnu.org; Fri, 29 Aug 2008 05:00:51 -0400 Received: from mail.newtec.eu ([62.58.98.194]:1216) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KYzqc-0005ut-VQ for grub-devel@gnu.org; Fri, 29 Aug 2008 05:00:51 -0400 Received: from (NEWTEC_CY.NEWTEC_CORP.NEWTEC_ROOT.newtec.be [192.168.1.209]) by scmgateway.newtec.be with smtp id 5a6f_f99682fe_75a8_11dd_adb0_00188b32e08b; Fri, 29 Aug 2008 11:00:49 +0200 Received: from betur.newtec.eu ([192.168.210.209]) by mail.newtec.eu with ESMTP; Fri, 29 Aug 2008 11:00:26 +0200 Received: from (unknown [192.168.210.209]) by scmgateway.newtec.be with smtp id 5a28_ec09c240_75a8_11dd_9b2a_00188b32e08b; Fri, 29 Aug 2008 11:00:26 +0200 Received: from gagh (gagh.ehv.newtec.eu [192.168.210.148]) by betur.newtec.eu with ESMTP; Fri, 29 Aug 2008 11:00:22 +0200 Received: by gagh (Postfix, from userid 1001) id D46EA7EA0F; Fri, 29 Aug 2008 11:00:19 +0200 (CEST) Date: Fri, 29 Aug 2008 11:00:19 +0200 To: The development of GRUB 2 Message-ID: <20080829090019.GA6721@gagh.ehv.newtec.eu> References: <20080828111405.GD8224@gagh.ehv.newtec.eu> <1219922711.4598.49.camel@fz.local> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="BOKacYhQ+x31HxR3" Content-Disposition: inline In-Reply-To: <1219922711.4598.49.camel@fz.local> User-Agent: Mutt/1.5.17+20080114 (2008-01-14) From: hans.lambermont@newtec.eu (Hans Lambermont) X-NAI-Spam-Score: 0 X-detected-kernel: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Felix Zielcke , Jan Derk Gerlings Subject: Re: grub 1.96 svn 20080813 and circular lvm2 metadata X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Aug 2008 09:00:55 -0000 --BOKacYhQ+x31HxR3 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Felix Zielcke wrote on 20080828: > Am Donnerstag, den 28.08.2008, 13:14 +0200 schrieb Hans Lambermont: >> My colleague Jan Derk Gerlings found a bug in the way grub 1.96, svn >> version 20080813 (and earlier) reads the circular lvm2 metadata >> buffer. > > Great, on Debian BTS we have 2 bugs [0] related to LVM and I wasn't > able yet to trace them down, but that could be the reason for them. > >> Shall we attempt to fix this and send a patch ? > > Yes please do :) Please find the patch attached, this was tested with circular metadata and the segfault in grub-setup is gone and the system boots fine. > Because GRUB is a GNU project, you have to obey the GNU Coding Standards [1] Ok, I hope I got it right. If not please let me know. regards, Hans Lambermont -- Hans Lambermont, M.Sc. - Newtec - OS-Platform&VAS http://newtec.eu/ t:+31408519234 m:+31629064887 --BOKacYhQ+x31HxR3 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="circular-metadata.patch" diff -uwr grub-1.96_svn20080813-org/ChangeLog grub-1.96_svn20080813-new/ChangeLog --- grub-1.96_svn20080813-org/ChangeLog 2008-08-13 17:24:36.000000000 +0200 +++ grub-1.96_svn20080813-new/ChangeLog 2008-08-29 10:33:03.000000000 +0200 @@ -1,3 +1,8 @@ +2008-08-28 Hans Lambermont (tiny change) + Jan Derk Gerlings (tiny change) + + * disk/lvm.c: Add capability to read circular metadata + 2008-08-12 Robert Millan * loader/i386/pc/multiboot.c (grub_multiboot_load_elf32): Move part diff -uwr grub-1.96_svn20080813-org/disk/lvm.c grub-1.96_svn20080813-new/disk/lvm.c --- grub-1.96_svn20080813-org/disk/lvm.c 2008-08-28 14:32:53.000000000 +0200 +++ grub-1.96_svn20080813-new/disk/lvm.c 2008-08-28 18:31:19.000000000 +0200 @@ -281,7 +281,8 @@ goto fail; } - metadatabuf = grub_malloc (mda_size); + /* alloc for circular worst-case scenario */ + metadatabuf = grub_malloc (2*mda_size); if (! metadatabuf) goto fail; @@ -300,6 +301,12 @@ } rlocn = mdah->raw_locns; + if (rlocn->offset + rlocn->size > mdah->size) + { + /* metadata is circular */ + grub_memcpy(metadatabuf + mda_size, metadatabuf + mdah->start, + ((rlocn->offset + rlocn->size) - mdah->size)); + } p = q = metadatabuf + grub_le_to_cpu64 (rlocn->offset); while (*q != ' ' && q < metadatabuf + mda_size) --BOKacYhQ+x31HxR3--