All of lore.kernel.org
 help / color / mirror / Atom feed
From: Glenn Washburn <development@efficientek.com>
To: grub-devel@gnu.org
Cc: Daniel Kiper <daniel.kiper@oracle.com>,
	Peter Jones <pjones@redhat.com>,
	"Vladimir 'phcoder' Serbinenko" <phcoder@gmail.com>,
	Rogier <rogier777@gmail.com>,
	Horst Prote <prote@fmi.uni-stuttgart.de>,
	Glenn Washburn <development@efficientek.com>
Subject: [PATCH] lvm: Grub2 fails to detect LVM volumes due to an incorrect computation of mda_end
Date: Mon,  6 May 2024 15:18:45 -0500	[thread overview]
Message-ID: <20240506201845.669759-1-development@efficientek.com> (raw)

From: Rogier <rogier777@gmail.com>

When handling a regular LVM volume, Grub can fail with the message:
error: disk `lvmid/******-****-****-****-****-****-
****/******-****-****-****-****-****-******' not found.

If the condition which triggers this exists, grub-probe will report the
error mentioned above. Similarly, the grub boot code will fail to detect
LVM volumes, resulting in a failure to boot off of LVM disks/partitions.
The condition can be created on any LVM VG by an LVM configuration change,
so any system with /boot on LVM can become unbootable at 'any' time (after
any LVM configuration change).

The problem is caused by an incorrect computation of mda_end in lvm.c, when
the metadata area wraps around. Apparently, this can start happening at
around 220 metadata changes to the VG.

Fixes: 879c4a834 (lvm: Fix two more potential data-dependent alloc overflows)
Fixes: https://savannah.gnu.org/bugs/?61620

Signed-off-by: Rogier <rogier777@gmail.com>
Signed-off-by: Glenn Washburn <development@efficientek.com>
---
I have done no testing of this patch. I've only created a suitable patch
for review. This seems like a fairly serious issue that might one day bite
me, so I think it deserves a review.

Glenn
---
 grub-core/disk/lvm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/grub-core/disk/lvm.c b/grub-core/disk/lvm.c
index 794248540cd3..8535d5a5863a 100644
--- a/grub-core/disk/lvm.c
+++ b/grub-core/disk/lvm.c
@@ -290,7 +290,7 @@ grub_lvm_detect (grub_disk_t disk,
 
   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;
-- 
2.34.1


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

             reply	other threads:[~2024-05-06 20:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-06 20:18 Glenn Washburn [this message]
2024-05-08 15:48 ` [PATCH] lvm: Grub2 fails to detect LVM volumes due to an incorrect computation of mda_end Daniel Kiper via Grub-devel
2024-05-16  4:04   ` Michael Chang via Grub-devel
2024-05-16  4:21     ` Michael Chang via Grub-devel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240506201845.669759-1-development@efficientek.com \
    --to=development@efficientek.com \
    --cc=daniel.kiper@oracle.com \
    --cc=grub-devel@gnu.org \
    --cc=phcoder@gmail.com \
    --cc=pjones@redhat.com \
    --cc=prote@fmi.uni-stuttgart.de \
    --cc=rogier777@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.