nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

Blame SOURCES/0459-disk-lvm-Do-not-allow-a-LV-to-be-it-s-own-segment-s-.patch

9723a8
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
9723a8
From: Daniel Axtens <dja@axtens.net>
9723a8
Date: Fri, 22 Jan 2021 14:42:21 +1100
9723a8
Subject: [PATCH] disk/lvm: Do not allow a LV to be it's own segment's node's
9723a8
 LV
9723a8
9723a8
This prevents infinite recursion in the diskfilter verification code.
9723a8
9723a8
Signed-off-by: Daniel Axtens <dja@axtens.net>
9723a8
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
9723a8
---
9723a8
 grub-core/disk/lvm.c | 10 +++++++---
9723a8
 1 file changed, 7 insertions(+), 3 deletions(-)
9723a8
9723a8
diff --git a/grub-core/disk/lvm.c b/grub-core/disk/lvm.c
9723a8
index 9eda28d852c..7e86bb7df4f 100644
9723a8
--- a/grub-core/disk/lvm.c
9723a8
+++ b/grub-core/disk/lvm.c
9723a8
@@ -840,9 +840,13 @@ error_parsing_metadata:
9723a8
 		    }
9723a8
 		if (lv1->segments[i].nodes[j].pv == NULL)
9723a8
 		  for (lv2 = vg->lvs; lv2; lv2 = lv2->next)
9723a8
-		    if (grub_strcmp (lv2->name,
9723a8
-				     lv1->segments[i].nodes[j].name) == 0)
9723a8
-		      lv1->segments[i].nodes[j].lv = lv2;
9723a8
+		    {
9723a8
+		      if (lv1 == lv2)
9723a8
+		        continue;
9723a8
+		      if (grub_strcmp (lv2->name,
9723a8
+				       lv1->segments[i].nodes[j].name) == 0)
9723a8
+			lv1->segments[i].nodes[j].lv = lv2;
9723a8
+		    }
9723a8
 	      }
9723a8
 	
9723a8
       }