sanity check for
sizeof_partition_entry
Changes since v3: style fixes
Changes since v4: sanity checks for GPT entries; split into
patchset
Signed-off-by: Eugene Korenevsky
---
block/partitions/efi.c | 31 ---
1 file changed, 20 insertions(+), 11 deletions(-)
diff --git a/block/partiti
Obvious sanity checks have been added for GPT entries.
GPT entries should not:
- collide with GPT header
- collide with GPT partitions
- override the disk size
These checks also ensure GPT entries are not too large.
Signed-off-by: Eugene Korenevsky
---
block/partitions/efi.c | 61
> is_gpt_valid() already contains
> pt_size = (u64)le32_to_cpu((*gpt)->num_partition_entries) *
> le32_to_cpu((*gpt)->sizeof_partition_entry);
> if (pt_size > KMALLOC_MAX_SIZE)
> pr_debug("GUID Partition Table is too large: %llu > %lu
> bytes\n",
>
> I suspect you also need a sanity check that the value isn't too small
> or stupidly large.
What would be the criterion for too large entries?
--
Eugene
> > Please rearrange this like:
> >
> >for (i = 0; i < le32_to_cpu(gpt->num_partition_entries) &&
> > i < state->limit-1; i++)
>
> Better still cache le32_to_cpu(gpt->num_partition_entries) to a local
> so that it only has to be calculated once (even if it gets s
sanity check for
sizeof_partition_entry
Changes since v3: style fixes
Signed-off-by: Eugene Korenevsky
---
block/partitions/efi.c | 31 ---
1 file changed, 20 insertions(+), 11 deletions(-)
diff --git a/block/partitions/efi.c b/block/partitions/efi.c
index 39f70d968754..0d10a582b5bc 1
sanity check for
sizeof_partition_entry
Signed-off-by: Eugene Korenevsky
---
block/partitions/efi.c | 32 +---
1 file changed, 21 insertions(+), 11 deletions(-)
diff --git a/block/partitions/efi.c b/block/partitions/efi.c
index 39f70d968754..c8ff7860973d 100644
--- a/block/partitions/
> >The GPT with entries sized more than sizeof(gpt_entry) is not illegal.
> >OVMF firmware from EDK2 perfectly works with it, see edk2-tianocore source
> >code.
> But _why_ is this needed? Does this firmware need larger sized entries (ie:
> does
> not work without it)?
A disk with correct large-
(gpt_entry) is not illegal.
OVMF firmware from EDK2 perfectly works with it, see edk2-tianocore source
code.
Changes since v1: refactoring (extract get_gpt_entry function),
fix (&ptes[i] -> pte)
Signed-off-by: Eugene Korenevsky
---
block/part
Use gpt_header.sizeof_partition_entry instead of sizeof(gpt_entry)
for GPT entry size.
According to UEFI spec, GPT entry size is specified in GPT header.
Signed-off-by: Eugene Korenevsky
---
block/partitions/efi.c | 26 --
1 file changed, 12 insertions(+), 14 deletions
10 matches
Mail list logo