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
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)
_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel