Skip to contentSkip to conversation

partitions: efi: verify header is outside usable area

PATCH New Davidlohr Bueso 1 participant 1 message Sep 5, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 2/3 partitions: efi: verify header is outside usable area

The first usable logical block can be used by a GUID partition entry, and therefore cannot be used by the header.

---
 block/partitions/efi.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
block/partitions/efi.c +7 -0
index 7795bb4..abf33a2 100644
@@ -363,6 +363,13 @@ static int is_gpt_valid(struct parsed_partitions *state, u64 lba,
 		goto fail;
 	}
 
+	/* The header must be outside usable range */
+	if (le64_to_cpu((*gpt)->first_usable_lba) < lba &&
+	    le64_to_cpu((*gpt)->last_usable_lba) > lba) {
+		pr_debug("GPT: Header is inside usable area\n");
+		goto fail;
+	}
+
 	/* Check that sizeof_partition_entry has the correct value */
 	if (le32_to_cpu((*gpt)->sizeof_partition_entry) != sizeof(gpt_entry)) {
 		pr_debug("GUID Partitition Entry Size check failed.\n");
Signature · 1 line
1.7.4.1