On Mon, 3 Aug 2026 at 15:33, Peter Robinson <[email protected]> wrote: > > On Mon, 3 Aug 2026 at 13:20, Ilias Apalodimas > <[email protected]> wrote: > > > > On Fri, 31 Jul 2026 at 15:40, Alexey Charkov <[email protected]> wrote: > > > > > > Several GPT header fields are read without converting from > > > little-endian, which is wrong on big-endian hosts. > > > > Probably because we got no BE architecture running EFI. > > Isn't the EFI spec explicitly LE?
Ah yes, I forgot that part. Alexey, you can drop that patch in v2 Cheers /Ilias > > > > gpt_fill_pte() takes my_lba and partition_entry_lba raw when working out > > > the region a partition must not overlap, so on a big-endian host both > > > bounds are byte-swapped garbage and the overlap check does not do > > > anything useful. > > > > > > gpt_verify_partitions() compares the loop counter against > > > num_partition_entries raw, so its "More partitions than allowed!" guard > > > never triggers. > > > > > > It also swaps gpt_part_size, which is already in host order, having been > > > computed from two le64_to_cpu() results a few lines above. Drop the > > > conversion rather than adding one. > > > > > > All of this is a no-op on little-endian targets. > > > > > > Signed-off-by: Alexey Charkov <[email protected]> > > > > In any case it;'s good to have > > Reviewed-by: Ilias Apalodimas <[email protected]> > > > > > --- > > > disk/part_efi.c | 8 ++++---- > > > 1 file changed, 4 insertions(+), 4 deletions(-) > > > > > > diff --git a/disk/part_efi.c b/disk/part_efi.c > > > index af311867a285..062389c3af0c 100644 > > > --- a/disk/part_efi.c > > > +++ b/disk/part_efi.c > > > @@ -462,10 +462,10 @@ int gpt_fill_pte(struct blk_desc *desc, > > > char *str_type_guid; > > > unsigned char *bin_type_guid; > > > #endif > > > - size_t hdr_start = gpt_h->my_lba; > > > + size_t hdr_start = le64_to_cpu(gpt_h->my_lba); > > > size_t hdr_end = hdr_start + 1; > > > > > > - size_t pte_start = gpt_h->partition_entry_lba; > > > + size_t pte_start = le64_to_cpu(gpt_h->partition_entry_lba); > > > size_t pte_end = pte_start + gpt_pte_blocks(desc, gpt_h); > > > > > > for (i = 0; i < parts; i++) { > > > @@ -851,7 +851,7 @@ int gpt_verify_partitions(struct blk_desc *desc, > > > gpt_e = *gpt_pte; > > > > > > for (i = 0; i < parts; i++) { > > > - if (i == gpt_head->num_partition_entries) { > > > + if (i == le32_to_cpu(gpt_head->num_partition_entries)) { > > > pr_err("More partitions than allowed!\n"); > > > return -1; > > > } > > > @@ -877,7 +877,7 @@ int gpt_verify_partitions(struct blk_desc *desc, > > > (unsigned long long)gpt_part_size, > > > (unsigned long long)partitions[i].size); > > > > > > - if (le64_to_cpu(gpt_part_size) != partitions[i].size) { > > > + if (gpt_part_size != partitions[i].size) { > > > /* We do not check the extend partition size */ > > > if ((i == parts - 1) && (partitions[i].size == 0)) > > > continue; > > > > > > -- > > > 2.54.0 > > >
