Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp6149582ybv; Tue, 18 Feb 2020 10:54:13 -0800 (PST) X-Google-Smtp-Source: APXvYqw3fhAZVCWlEb2t0jopzD9RHAMg+7H1sydpFn2JXvuO0i2Lvlqj2g07shSjcyz8ZYpqojt9 X-Received: by 2002:aca:458:: with SMTP id 85mr2233574oie.56.1582052053005; Tue, 18 Feb 2020 10:54:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582052052; cv=none; d=google.com; s=arc-20160816; b=KAHKIMl9M8MLL9gnIxEv1SMufJEzJ/2289nkZcWlvNuHg+lSOhnkY95dn/N2txWX1K UWD0NADDUALxU3znS8B4w+PVixGUdvuVVRCUrzwYfCvkROndN5qDpUXqpoFNa3Y7zJwp qznvaroYC24Z0sjc3KXJKccpubfqjSGX2mKq15y8wtce2XSzd9Q/gSreUIsM7v9r8eJ/ nu7UeNo7sjP25LnH/Dt6oAibBXLiX1Apgu7i5rC9YD1IXlx5qYxG06yvXCwmpfdjiuw9 AAH3Vji77l3gksjpqBI9b7w/ilybUsUxleA7Kny5h3VSmqOwSaQ1ADRkMGymF3N7SyYz Attg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=6j4dbVJFJ7oC5DhQZUAIAKi7jxQSaytsVxqOSb9w4KQ=; b=RN+P+j0SkcUiH49OK+Bg/Jez2dvvwfe8sOYRCzQ1ocnmqWZr6Qk2/L1LJo8c0OF+LF pHEIlawtHICGij1xQSDcRWtjaqNe0z2rP6FaS1xkPrNABTPW4nwYEaNjGhcAIeTWnv2v LV0HYWKU3W1lhmDFXzZNPusqPkN9JRK85ArbcEj24FrZWUPidkcrCWnhlpbQr36WnqJA pI048ww+SsWonHIgGj4uj0+mxFp9QxoWmtnRuxhSXP5jk/nc91NRPshFAjt3vYaNYOGs Bq6PBNk5fbtZLCN2zZPGwT7+a0uzFa86SnYOqscEsZXk4z8kru2j8BvS4GJAyJRDaOgh tshQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=U2j547Cy; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 71si2395520otm.111.2020.02.18.10.53.59; Tue, 18 Feb 2020 10:54:12 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=U2j547Cy; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726515AbgBRSxk (ORCPT + 99 others); Tue, 18 Feb 2020 13:53:40 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:53798 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726339AbgBRSxk (ORCPT ); Tue, 18 Feb 2020 13:53:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=6j4dbVJFJ7oC5DhQZUAIAKi7jxQSaytsVxqOSb9w4KQ=; b=U2j547CyaTMSl1ZbRusn62lgFo J84flzxCZ4FHWDTcaPQ1AXHDxrJ4x9KkJ4LkWBgafCFjPC1U5sTuP2Xga8daT30nhifZiBXhNOkGa nL27PfE/VPWQjKFtFMEWNa2HvzjkyCFuFi0AohXmC6XOGhRfjc+QP3NVjvuRmrJUOKkB6xsgDcLN6 Tm1XDKozCfBPbzoqOqd8YPIMQjf1OdhXTZ/hOY7UA47vOkuseO4GfUb4lTd18nx2XKopkgHIxUsYV aQN4ihIQzpNNZwDK+rVq1IToXO1awP5GMc1SVbK95/HKgB2pn4ACNF2ijCKTa5bNuZOGmNp9sVzLw aizBuPiw==; Received: from hch by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1j4800-0007Am-Hw; Tue, 18 Feb 2020 18:53:36 +0000 Date: Tue, 18 Feb 2020 10:53:36 -0800 From: Christoph Hellwig To: Nikolai Merinov Cc: hch@infradead.org, Davidlohr Bueso , Jens Axboe , Ard Biesheuvel , linux-efi@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3] partitions/efi: Fix partition name parsing in GUID partition entry Message-ID: <20200218185336.GA14242@infradead.org> References: <20181124162123.21300-1-n.merinov@inango-systems.com> <20191224092119.4581-1-n.merinov@inango-systems.com> <20200108133926.GC4455@infradead.org> <26f7bd89f212f68b03a4b207e96d8702c9049015.1578910723.git.n.merinov@inango-systems.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <26f7bd89f212f68b03a4b207e96d8702c9049015.1578910723.git.n.merinov@inango-systems.com> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 13, 2020 at 03:27:23PM +0500, 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 > --- > block/partitions/efi.c | 3 ++- > block/partitions/efi.h | 2 +- > include/linux/efi.h | 5 +++++ > 3 files changed, 8 insertions(+), 2 deletions(-) > > diff --git a/block/partitions/efi.c b/block/partitions/efi.c > index db2fef7dfc47..f1d0820de844 100644 > --- a/block/partitions/efi.c > +++ b/block/partitions/efi.c > @@ -715,7 +715,8 @@ 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 = 0xff & efi_char16le_to_cpu( > + ptes[i].partition_name[label_count]); Why are you swapping the order of the comparism to an unusual one here? > - efi_char16_t partition_name[72 / sizeof (efi_char16_t)]; > + efi_char16le_t partition_name[72 / sizeof(efi_char16le_t)]; > } __packed gpt_entry; > > typedef struct _gpt_mbr_record { > diff --git a/include/linux/efi.h b/include/linux/efi.h > index aa54586db7a5..47882f2d45db 100644 > --- a/include/linux/efi.h > +++ b/include/linux/efi.h > @@ -45,9 +45,14 @@ > typedef unsigned long efi_status_t; > typedef u8 efi_bool_t; > typedef u16 efi_char16_t; /* UNICODE character */ > +typedef __le16 efi_char16le_t; /* UTF16-LE */ > +typedef __be16 efi_char16be_t; /* UTF16-BE */ > typedef u64 efi_physical_addr_t; > typedef void *efi_handle_t; > > +#define efi_char16le_to_cpu le16_to_cpu > +#define efi_char16be_to_cpu be16_to_cpu I'd rather use plain __le16 and le16_to_cpu here. Also the be variants seems to be entirely unused.