bugGNU GRUB - Bugs: bug #64167, grub fails to parse LVM...


You are not allowed to post comments on this tracker with your current authentication level.

bug #64167: grub fails to parse LVM information from PV

Submitter:  Torsten Hilbrich <myrkr_el>
Submitted:  Tue 09 May 2023 06:28:02 AM UTC
Category:  Booting Severity:  Major
Priority:  5 - Normal Item Group:  Software Error
Status:  None Privacy:  Public
Assigned to:  None Originator Name:  Torsten Hilbrich
Open/Closed:  Open Release:  Git master
Release:  Reproducibility:  Every Time
Planned Release:  None

Tue 27 Jun 2023 05:48:14 AM UTC, comment #3: 

I tried the patch and the error changed in my reproducer from

./grub-fstest: error: cannot open `(lvm/sinavw-SYS1)/VERSION': disk `lvm/sinavw-SYS1' not found.


./grub-fstest: error: cannot open `(lvm/sinavw-SYS1)/VERSION': unknown filesystem.

which is likely to due using a truncated disk image here.

So it seems that the patch helps for my problem too.

Torsten Hilbrich <myrkr_el>
Mon 26 Jun 2023 11:50:53 PM UTC, comment #2: 

I suspect you've hit this bug:

I've hit this issue myself and, having done a similar round of debugging, I'm also pretty sure grub is broken in the case where the LVM metadata isn't contiguous on-disk, which means that any LVM operation that touches the metadata could trigger this bug.

Daniel Gnoutcheff <gnoutchd>
Tue 09 May 2023 06:37:52 AM UTC, comment #1: 

Small correction, the mda_end points to just after the name "ISO-EMSIFDBO".

Torsten Hilbrich <myrkr_el>
Tue 09 May 2023 06:28:02 AM UTC, original submission:  

Grub version 2.06

I have a test system with the following partition layout:

/dev/nvme0n1: Partitioned as GPT
/dev/nvme0n1p3: A boot partition, partition type "EFI System"
  On that partition boot as installed as EFI binary
/dev/nvme0n1p5: Partition type "Linux LVM"

The PV contains a volume group named "sinavw", it has a number of LV where SYS1 and SYS2 can then be used for booting.

The system is the following, whenever to load the kernel from the LV the following error is output:

error: no server is specified

Using the user-space grub-fstest tool I was able to diagnose the problem a bit more. The failure is happening while parsing the LVM meta data from the PV. I have extracted the first about 1 MiB from the /dev/nvme0n1p5 partition, with the call of:

grub-fstest --verbose start-of-pv-with-error cat '(lvm/sinavw-SYS1)/VERSION'

I could reproduce the problem.

The error occurs when trying to parse the name of the LV "ISO-EMSIFDBO", it seems that the mda_end previously determined points to the newline after that name. So the following code block from grub-core/disk/lvm.c, function grub_lvm_detect (around line 459) determines that the condition "q == mda_end" is true.

              lv = grub_zalloc (sizeof (*lv));

              q = p;
              while (*q != ' ' && q < mda_end)

              if (q == mda_end)
                goto lvs_fail;

Here is some debugger output around that code:

456                      while (*q != ' ' && q < mda_end)
1: q = 0x7fcfd76b9004 "ISO-EMSIFDBO {\nid = \"Ze7l6L-hS8k-QPYf-VPTz-OuLD-bNxO-iRC5mP\"\nstatus = [\"READ\", \"WRITE\", \"VISIBLE\"]\nflags = []\ncreation_time = 1600763824\ncreation_host = \"hilbrich.torsten.2016.at.secunet.de\"\nsegment_c"...
(gdb) p mda_end
$1 = 0x7fcfd76b9010 " {\nid = \"Ze7l6L-hS8k-QPYf-VPTz-OuLD-bNxO-iRC5mP\"\nstatus = [\"READ\", \"WRITE\", \"VISIBLE\"]\nflags = []\ncreation_time = 1600763824\ncreation_host = \"hilbrich.torsten.2016.at.secunet.de\"\nsegment_count = 1\n\nse"...

The same PV can be used within the linux system without any problem. I use a current kernel (currently 6.1.28) and the lvm2 tools in version 2.02.180.

I also noticed that when performing some LVM operation on linux the problem happened to disappear in the past, only the reappear later on. I assume that the position of the current copy of the meta data changes and influences the problem.

Torsten Hilbrich <myrkr_el>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #54713:  start-of-pv-with-error added by myrkr_el (1MiB - application/octet-stream)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by gnoutchd (Posted a comment)
  • -email is unavailable- added by myrkr_el (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.


    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-05-09 myrkr_el Attached File- Added start-of-pv-with-error, #54713

    Back to the top

    Powered by Savane 3.13-a854.
    Corresponding source code