Bug#987008: Grub fails to find LVM volume after previous LV rename

Rogier rogier777 at gmail.com
Sat Aug 28 00:30:18 BST 2021


Dear maintainer,

I have also run into this bug, in the same version of grub (2.02+dfsg1-20+deb10u4).

As *any* change to the LVM configuration can trigger the bug, rendering the system unbootable, this is a ticking bomb for users of LVM. IMO the severity of this bug should be increased to critical.

I did some investigation, and the cause is an incorrect computation of mda_end when the metadata area wraps around.

The following patch fixes the problem:
---------------------------------------------------
Index: grub2-2.02+dfsg1/grub-core/disk/lvm.c
===================================================================
--- grub2-2.02+dfsg1.orig/grub-core/disk/lvm.c
+++ grub2-2.02+dfsg1/grub-core/disk/lvm.c
@@ -253,7 +253,7 @@ error_parsing_metadata:

   p = q = (char *)ptr;

-  if (grub_add ((grub_size_t)metadatabuf, (grub_size_t)mda_size, &ptr))
+  if (grub_add (ptr, (grub_size_t)grub_le_to_cpu64 (rlocn->size), &ptr))
     goto error_parsing_metadata;

   mda_end = (char *)ptr;
----------------------------------------------------

I checked the sources of grub2-2.04 in bullseye, and the code in question looks exactly the same, so this same bug is also present in bullseye and testing.

Kind regards,

Rogier.



More information about the Pkg-grub-devel mailing list