[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKv+Gu98Gi5Uvz7AZw4ky_-sxOZxJ4687jxyQsJU6d3TGkem1g@mail.gmail.com>
Date: Tue, 24 Dec 2019 10:51:19 +0100
From: Ard Biesheuvel <ard.biesheuvel@...aro.org>
To: Nikolai Merinov <n.merinov@...ngo-systems.com>
Cc: Davidlohr Bueso <dave@...olabs.net>, Jens Axboe <axboe@...nel.dk>,
linux-efi <linux-efi@...r.kernel.org>,
linux-block@...r.kernel.org,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2] partitions/efi: Fix partition name parsing in GUID
partition entry
On Tue, 24 Dec 2019 at 10:29, Nikolai Merinov
<n.merinov@...ngo-systems.com> wrote:
>
> GUID partition entry defined to have a partition name as 36 UTF-16LE
> code units. This means that on big-endian platforms ASCII symbols
> would be read with 0xXX00 efi_char16_t character code. In order to
> correctly extract ASCII characters from a partition name field we
> should be converted from 16LE to CPU architecture.
>
> The problem exists on all big endian platforms.
>
> Signed-off-by: Nikolai Merinov <n.merinov@...ngo-systems.com>
>
Acked-by: Ard Biesheuvel <ardb@...nel.org>
> diff --git a/block/partitions/efi.c b/block/partitions/efi.c
> index db2fef7dfc47..51287a8a3bea 100644
> --- a/block/partitions/efi.c
> +++ b/block/partitions/efi.c
> @@ -715,7 +715,7 @@ int efi_partition(struct parsed_partitions *state)
> ARRAY_SIZE(ptes[i].partition_name));
> info->volname[label_max] = 0;
> while (label_count < label_max) {
> - u8 c = ptes[i].partition_name[label_count] & 0xff;
> + u8 c = le16_to_cpu(ptes[i].partition_name[label_count]) & 0xff;
> if (c && !isprint(c))
> c = '!';
> info->volname[label_count] = c;
> diff --git a/block/partitions/efi.h b/block/partitions/efi.h
> index 3e8576157575..0b6d5b7be111 100644
> --- a/block/partitions/efi.h
> +++ b/block/partitions/efi.h
> @@ -88,7 +88,7 @@ typedef struct _gpt_entry {
> __le64 starting_lba;
> __le64 ending_lba;
> gpt_entry_attributes attributes;
> - efi_char16_t partition_name[72 / sizeof (efi_char16_t)];
> + __le16 partition_name[72 / sizeof (__le16)];
> } __packed gpt_entry;
>
> typedef struct _gpt_mbr_record {
> --
> 2.17.1
>
Powered by blists - more mailing lists