linux-efi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
To: Nikolai Merinov <n.merinov@inango-systems.com>
Cc: Davidlohr Bueso <dave@stgolabs.net>, Jens Axboe <axboe@kernel.dk>,
	linux-efi <linux-efi@vger.kernel.org>,
	linux-block@vger.kernel.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] partitions/efi: Fix partition name parsing in GUID partition entry
Date: Tue, 24 Dec 2019 10:51:19 +0100	[thread overview]
Message-ID: <CAKv+Gu98Gi5Uvz7AZw4ky_-sxOZxJ4687jxyQsJU6d3TGkem1g@mail.gmail.com> (raw)
In-Reply-To: <20191224092119.4581-1-n.merinov@inango-systems.com>

On Tue, 24 Dec 2019 at 10:29, Nikolai Merinov
<n.merinov@inango-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@inango-systems.com>
>

Acked-by: Ard Biesheuvel <ardb@kernel.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
>

  reply	other threads:[~2019-12-24  9:51 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-24 16:21 [PATCH] partitions/efi: Fix partition name parsing in GUID partition entry Nikolai Merinov
2018-11-25 21:16 ` kbuild test robot
2019-12-24  9:21 ` [PATCH v2] " Nikolai Merinov
2019-12-24  9:51   ` Ard Biesheuvel [this message]
2020-01-08 13:39   ` Christoph Hellwig
2020-01-13 10:27     ` [PATCH v3] " Nikolai Merinov
2020-02-18 13:34       ` Nikolai Merinov
2020-02-18 18:53       ` Christoph Hellwig
2020-02-24 11:38         ` Nikolai Merinov
2020-02-24 17:08           ` hch
2020-03-06  8:43             ` Nikolai Merinov
2020-03-06  9:25               ` Ard Biesheuvel
2020-03-06 10:14                 ` Ard Biesheuvel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAKv+Gu98Gi5Uvz7AZw4ky_-sxOZxJ4687jxyQsJU6d3TGkem1g@mail.gmail.com \
    --to=ard.biesheuvel@linaro.org \
    --cc=axboe@kernel.dk \
    --cc=dave@stgolabs.net \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=n.merinov@inango-systems.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).