forked from bottlerocket-os/bottlerocket
-
Notifications
You must be signed in to change notification settings - Fork 0
/
0036-gpt-include-backup-in-sync-check-in-revalidation.patch
40 lines (34 loc) · 1.42 KB
/
0036-gpt-include-backup-in-sync-check-in-revalidation.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
From 23ce2d3a2b0422c725b1cfb0c61fccba595f8b9b Mon Sep 17 00:00:00 2001
From: Michael Marineau <[email protected]>
Date: Wed, 21 Sep 2016 15:01:09 -0700
Subject: [PATCH] gpt: include backup-in-sync check in revalidation
---
grub-core/lib/gpt.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/grub-core/lib/gpt.c b/grub-core/lib/gpt.c
index 3ac2987..c27bcc5 100644
--- a/grub-core/lib/gpt.c
+++ b/grub-core/lib/gpt.c
@@ -372,6 +372,11 @@ grub_gpt_check_backup (grub_gpt_t gpt)
if (backup <= end)
return grub_error (GRUB_ERR_BAD_PART_TABLE, "invalid backup GPT LBA");
+ /* If both primary and backup are valid but differ prefer the primary. */
+ if ((gpt->status & GRUB_GPT_PRIMARY_HEADER_VALID) &&
+ !grub_gpt_headers_equal (gpt))
+ return grub_error (GRUB_ERR_BAD_PART_TABLE, "backup GPT out of sync");
+
return GRUB_ERR_NONE;
}
@@ -435,11 +440,6 @@ grub_gpt_read_backup (grub_disk_t disk, grub_gpt_t gpt)
if (grub_le_to_cpu64 (gpt->backup.header_lba) != sector)
return grub_error (GRUB_ERR_BAD_PART_TABLE, "invalid backup GPT LBA");
- /* If both primary and backup are valid but differ prefer the primary. */
- if ((gpt->status & GRUB_GPT_PRIMARY_HEADER_VALID) &&
- !grub_gpt_headers_equal(gpt))
- return grub_error (GRUB_ERR_BAD_PART_TABLE, "backup GPT of of sync");
-
gpt->status |= GRUB_GPT_BACKUP_HEADER_VALID;
return GRUB_ERR_NONE;
}
--
2.21.3