Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp7404991ybl; Tue, 24 Dec 2019 01:52:11 -0800 (PST) X-Google-Smtp-Source: APXvYqysxjy6IjfZLGU0vqd2y5dXjqpTge30cjgl8KknCdJko7eHEVb+hNo/s8NoXcrVbLlOT/kK X-Received: by 2002:a9d:1c95:: with SMTP id l21mr28695302ota.271.1577181131346; Tue, 24 Dec 2019 01:52:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577181131; cv=none; d=google.com; s=arc-20160816; b=h9doVmEOkek+XLr7PNNvGPjSHT3T45puT87J8UqlSdZpDdhB8l/NY/GQVjZG4g6WJ2 exfeE6eWFIDj8HiIEl6y3B4teZgdGho1M/hbwbc14DknbMFACKevJ3qqK7xvmHHfMico 5ZcVaLflqh6zjFUJk/nNnDcodEiFkb2SJYvxuY8t5UlD2dXtUxHVnNpRiHYxM6nExDC6 YocX7nwc3KEbwPk69FvI5pumfgnI/EnVdFoyUkKGr/+YX5ToGbecaV8ROHTti7oCwJiO zaCBCPmZLwa05eINn+XXbQJLgrVqeqx2Ne/RU5kURyj81333+rvI9PM5nLyVdLoY9WUS JUHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=lDQYVJqwKy9VrlC0fN44xu7g3oqePLWya4mj982q/t4=; b=Q1a3gZQ1wFZweAkL3/cMZDe0hBeIyFWDT7VuLQQR6yRSeTULixyLUsbrob++QxFd6S /SmgwrlXmmCiEytY6OlrEhz7eYeoEEwPYQyzw8kx0vqUCl0f9eshnXgM7HR3D9t6Cl8h E2S5YMTwOOc0s4RMJxUhjSmgsy0JGNzQ3qTKQab6RclU8EvudWWkgUcGUZ539h+jlNA3 UL4Jh/+7+TCrMzX3ts9677JpIlohicA5rL03iA2rX+/AHMlRR6BPpiQJJk98Px7YBNZr QgeZR2CF5iw7czC6vsPct9hpPBaQHKce5Uia7k9GW1qD119Tht80/9o32KKBdrCn0sfk IoRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Mvr4fmpi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z2si10559404oix.100.2019.12.24.01.51.59; Tue, 24 Dec 2019 01:52:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Mvr4fmpi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726171AbfLXJvX (ORCPT + 99 others); Tue, 24 Dec 2019 04:51:23 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:43362 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726104AbfLXJvX (ORCPT ); Tue, 24 Dec 2019 04:51:23 -0500 Received: by mail-wr1-f66.google.com with SMTP id d16so19325080wre.10 for ; Tue, 24 Dec 2019 01:51:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=lDQYVJqwKy9VrlC0fN44xu7g3oqePLWya4mj982q/t4=; b=Mvr4fmpiYrB+0nQxpkrmFTOnyzLDm840DZitghmn7r7y7CSSt7X1vRiUo5L2xBup/6 +EyhBuGG6GLwXTdN3CiDjOktiOf78SK0fEUhKSO8l7/JDkdleUySM72uJph3VC2cJMuw PgSWE+B0Sn8oNhssbI5Ap2ToUa7Hq9zdKNVlBkZxTsKQ4Xc/pwAavtDBYNPq+FE9nvTf Tv2+NVLe9D459gaDmlO30F9cB1am0spqDov+c0rs79iaRpzZQ3nClKjyF0xdXCyyOyab SlaYHUg1jl3MyPim8SsrzIRMTXN40WDNcyysvb8LzTitvBMgSxIdaqYA/OZOuXcW2NTy vYBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=lDQYVJqwKy9VrlC0fN44xu7g3oqePLWya4mj982q/t4=; b=AwRE0PLYyZDthTgTYKSeT4W9rdXQJxZhn2LDwwxc2CZSCTFU1C0UMY2lQwcde9Skpj JT9FQ/1bTsIWcqnaoL74sKJxv3faESyhbs9/D01zmF1eE+fikGWPmdY6HXbjwrssrnNl JdtWGfTv7Y41pUi2z1/QS8ph8g1M45tzTjpOjKOeTGDUVHK3dyD354aw1tNmvvIpz3kG M8igHLDAjU/hhCuIJi8ofomKXi9kxWEVPeJXUdJg3xCr3d7VfG7mQ1i/XdiwYUYHS6v6 YAlrrRGN7EVrlQhBtdYVIiiOIrora+P5l/DABIZko/pce/qdfNF4pANwodQJQAm6cZGb WhDQ== X-Gm-Message-State: APjAAAV+g9PZoPvRCxCzceOXUPMvjlItWqZ+ZsY+r0nz2K9VedU5dZ5M gxv53uyyVwtIPsyYQh77Mp0R3dQsVDbiHBrddCetoA== X-Received: by 2002:a5d:43c7:: with SMTP id v7mr32288671wrr.32.1577181080636; Tue, 24 Dec 2019 01:51:20 -0800 (PST) MIME-Version: 1.0 References: <20181124162123.21300-1-n.merinov@inango-systems.com> <20191224092119.4581-1-n.merinov@inango-systems.com> In-Reply-To: <20191224092119.4581-1-n.merinov@inango-systems.com> From: Ard Biesheuvel Date: Tue, 24 Dec 2019 10:51:19 +0100 Message-ID: Subject: Re: [PATCH v2] partitions/efi: Fix partition name parsing in GUID partition entry To: Nikolai Merinov Cc: Davidlohr Bueso , Jens Axboe , linux-efi , linux-block@vger.kernel.org, Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 24 Dec 2019 at 10:29, Nikolai Merinov 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 > Acked-by: Ard Biesheuvel > 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 >