Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1Kd2tR-0001qo-Q1 for mharc-grub-devel@gnu.org; Tue, 09 Sep 2008 09:04:29 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Kd2tQ-0001qf-Me for grub-devel@gnu.org; Tue, 09 Sep 2008 09:04:28 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Kd2tP-0001qQ-Tx for grub-devel@gnu.org; Tue, 09 Sep 2008 09:04:28 -0400 Received: from [199.232.76.173] (port=48213 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kd2tP-0001qN-N7 for grub-devel@gnu.org; Tue, 09 Sep 2008 09:04:27 -0400 Received: from mail.newtec.eu ([62.58.98.194]:1606) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Kd2tP-0007Nm-5r for grub-devel@gnu.org; Tue, 09 Sep 2008 09:04:27 -0400 Received: from (newtec.be [192.168.1.209]) by scmgateway.newtec.be with smtp id 273c_d46e5a68_7e6f_11dd_9c6e_00188b32e08b; Tue, 09 Sep 2008 15:04:26 +0200 Received: from betur.newtec.eu ([192.168.210.209]) by mail.newtec.eu with ESMTP; Tue, 09 Sep 2008 15:04:17 +0200 Received: from (unknown [192.168.210.209]) by scmgateway.newtec.be with smtp id 267f_ced0ae6c_7e6f_11dd_8287_00188b32e08b; Tue, 09 Sep 2008 15:04:16 +0200 Received: from gagh (gagh.ehv.newtec.eu [192.168.210.147]) by betur.newtec.eu with ESMTP; Tue, 09 Sep 2008 15:03:55 +0200 Received: by gagh (Postfix, from userid 1001) id 7C0F87EA47; Tue, 9 Sep 2008 15:03:51 +0200 (CEST) Date: Tue, 9 Sep 2008 15:03:51 +0200 To: The development of GRUB 2 Message-ID: <20080909130351.GB6969@gagh.ehv.newtec.eu> References: <20080828111405.GD8224@gagh.ehv.newtec.eu> <1219922711.4598.49.camel@fz.local> <20080829090019.GA6721@gagh.ehv.newtec.eu> <87wshzhkh7.fsf@xs4all.nl> <1220476513.21922.7.camel@fz.local> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="YZ5djTAD1cGYuMQK" Content-Disposition: inline In-Reply-To: <1220476513.21922.7.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: 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: Tue, 09 Sep 2008 13:04:28 -0000 --YZ5djTAD1cGYuMQK Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Felix Zielcke wrote on 20080903: > could you please address Marco's issues and send a new patch so the > topic is brought up again? Please find attached a new patch. I hope I managed to fix all remarks that were made ;-) If not then please let me know. This is intended for the Changelog : 2008-09-09 Hans Lambermont * disk/lvm.c (grub_lvm_scan_device): Allocate buffer space for the circular metadata worst case scenario. If the metadata is circular then copy the wrap in place. * include/grub/lvm.h: Add GRUB_LVM_MDA_HEADER_SIZE, from the LVM2 project lib/format_text/layout.h Circular metadata bug found and patch debugged by Jan Derk Gerlings The 'svn diff --diff-cmd diff -x -up' style patch is attached. regards, Hans Lambermont -- Hans Lambermont, M.Sc. - Newtec - OS-Platform&VAS http://newtec.eu/ t:+31408519234 m:+31629064887 --YZ5djTAD1cGYuMQK Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="grublvm.patch" Index: disk/lvm.c =================================================================== --- disk/lvm.c (revision 1858) +++ disk/lvm.c (working copy) @@ -281,7 +281,8 @@ grub_lvm_scan_device (const char *name) goto fail; } - metadatabuf = grub_malloc (mda_size); + /* Allocate buffer space for the circular worst-case scenario. */ + metadatabuf = grub_malloc (2 * mda_size); if (! metadatabuf) goto fail; @@ -300,6 +301,16 @@ grub_lvm_scan_device (const char *name) } rlocn = mdah->raw_locns; + if (grub_le_to_cpu64 (rlocn->offset) + grub_le_to_cpu64 (rlocn->size) > + grub_le_to_cpu64 (mdah->size)) + { + /* Metadata is circular. Copy the wrap in place. */ + grub_memcpy (metadatabuf + mda_size, + metadatabuf + GRUB_LVM_MDA_HEADER_SIZE, + grub_le_to_cpu64 (rlocn->offset) + + grub_le_to_cpu64 (rlocn->size) - + grub_le_to_cpu64 (mdah->size)); + } p = q = metadatabuf + grub_le_to_cpu64 (rlocn->offset); while (*q != ' ' && q < metadatabuf + mda_size) Index: include/grub/lvm.h =================================================================== --- include/grub/lvm.h (revision 1858) +++ include/grub/lvm.h (working copy) @@ -103,6 +103,7 @@ struct grub_lvm_pv_header { #define GRUB_LVM_FMTT_MAGIC "\040\114\126\115\062\040\170\133\065\101\045\162\060\116\052\076" #define GRUB_LVM_FMTT_VERSION 1 +#define GRUB_LVM_MDA_HEADER_SIZE 512 /* On disk */ struct grub_lvm_raw_locn { --YZ5djTAD1cGYuMQK--