Hello Bharath and Jean-Luc,

I'm too lazy to write both of you a seperate mail ;)
Both your reports have to do with LVM and I'm not able to repdroduce
them and so to trace them down.
Luckly somebody else now saw a problem in the LVM module code.

Please try if the attached patch helps.

In case you don't know how to do it:

You may need a deb-src line in /etc/apt/sources.list for this apt-get
call:
apt-get build-depends grub2

svn co svn://svn.sv.gnu.org/grub/trunk/grub2
cd grub2
patch -p1 < /path/to/circular-metadata.patch
svn co svn://svn.debian.org/svn/pkg-grub/grub2/trunk/debian
export DH_ALWAYS_EXCLUDE=".svn"
dpkg-buildpackage -b

If you still have problems compiling this then please feel free to send
me a mail in private (i.e. no CC @bugs.debian.org)

-------- Weitergeleitete Nachricht --------
> Von: Hans Lambermont <[EMAIL PROTECTED]>
> 
> Please find the patch attached, this was tested with circular metadata
> and the segfault in grub-setup is gone and the system boots fine.


-- 
Felix Zielcke
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 <[EMAIL PROTECTED]> (tiny change)
+	   Jan Derk Gerlings <[EMAIL PROTECTED]> (tiny change)
+
+	* disk/lvm.c: Add capability to read circular metadata
+
 2008-08-12  Robert Millan  <[EMAIL PROTECTED]>
 
 	* 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)

Reply via email to