[PATCH v5 2/2] efi: take size of partition entry from GPT header

2018-11-04 Thread Eugene Korenevsky
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

[PATCH v5 1/2] efi: add sanity checks for GPT entries

2018-11-04 Thread Eugene Korenevsky
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

Re: [PATCH v2] efi: take size of partition entry from GPT header

2018-10-06 Thread Eugene Korenevsky
> 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", >

Re: [PATCH v2] efi: take size of partition entry from GPT header

2018-09-13 Thread Eugene Korenevsky
> 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

Re: [PATCH v3] efi: take size of partition entry from GPT header

2018-09-13 Thread Eugene Korenevsky
> > 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

[PATCH v4] efi: take size of partition entry from GPT header

2018-09-12 Thread Eugene Korenevsky
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

[PATCH v3] efi: take size of partition entry from GPT header

2018-09-12 Thread Eugene Korenevsky
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/

Re: [PATCH v2] efi: take size of partition entry from GPT header

2018-09-11 Thread Eugene Korenevsky
> >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-

[PATCH v2] efi: take size of partition entry from GPT header

2018-09-11 Thread Eugene Korenevsky
(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

[PATCH] efi: take size of partition entry from GPT header

2018-09-10 Thread Eugene Korenevsky
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