Received: from list by lists.gnu.org with archive (Exim 4.71) id 1dKlPv-0006ld-VT for mharc-grub-devel@gnu.org; Tue, 13 Jun 2017 08:59:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41515) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dKlPs-0006l3-O0 for grub-devel@gnu.org; Tue, 13 Jun 2017 08:59:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dKlPn-0004k4-S1 for grub-devel@gnu.org; Tue, 13 Jun 2017 08:59:28 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:47271) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dKlPn-0004iD-Hk for grub-devel@gnu.org; Tue, 13 Jun 2017 08:59:23 -0400 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v5DCxJvt023535 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Jun 2017 12:59:19 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id v5DCxITN011768 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Jun 2017 12:59:19 GMT Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id v5DCxIwU012240; Tue, 13 Jun 2017 12:59:18 GMT Received: from olila.local.net-space.pl (/10.175.188.201) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 13 Jun 2017 05:59:17 -0700 Date: Tue, 13 Jun 2017 14:59:13 +0200 From: Daniel Kiper To: Eric Snowberg Cc: The development of GNU GRUB , "Vladimir 'phcoder' Serbinenko" , alexander.burmashev@oracle.com, arvidjaar@gmail.com Subject: Re: [PATCH] parser: Remove escape from the state transitions Message-ID: <20170613125913.GF4441@olila.local.net-space.pl> References: <1496182072-146693-1-git-send-email-eric.snowberg@oracle.com> <20170602104121.GI19333@olila.local.net-space.pl> <20170607192331.GH711@olila.local.net-space.pl> <026D638D-7E2A-4C74-BF4E-6201897E0C08@oracle.com> <20170607213657.GI711@olila.local.net-space.pl> <37A8B0CB-420C-4811-9B41-6099E65021A2@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <37A8B0CB-420C-4811-9B41-6099E65021A2@oracle.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Source-IP: userv0021.oracle.com [156.151.31.71] Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by userp1040.oracle.com id v5DCxJvt023535 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] [fuzzy] X-Received-From: 156.151.31.81 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Jun 2017 12:59:29 -0000 On Wed, Jun 07, 2017 at 03:43:34PM -0600, Eric Snowberg wrote: > > > On Jun 7, 2017, at 3:36 PM, Daniel Kiper wr= ote: > > > > On Wed, Jun 07, 2017 at 02:48:04PM -0600, Eric Snowberg wrote: > >>> On Jun 7, 2017, at 1:23 PM, Daniel Kiper = wrote: > >>> On Mon, Jun 05, 2017 at 08:29:47AM -0600, Eric Snowberg wrote: > >>>>> On Jun 2, 2017, at 4:41 AM, Daniel Kiper wrote: > >>>>> On Tue, May 30, 2017 at 04:07:52PM -0600, Eric Snowberg wrote: > >>>>>> Remove GRUB_PARSER_STATE_ESC with state GRUB_PARSER_STATE_TEXT f= rom > >>>>>> the list of not allowed characters. > >>>>>> > >>>>>> This fixes a problem where a properly escaped comma is in the di= sk path. > >>>>>> > >>>>>> For example: /pci@306/pci@1/LSI,mrsas@0/disk@0:a > >>>>>> > >>>>>> During grub install, the search.fs_uuid is correctly stored in t= he > >>>>>> core.img. > >>>>>> > >>>>>> As seen here: > >>>>>> > >>>>>> 001e380: 7365 6172 6368 2e66 735f 7575 6964 2039 search.fs_uuid= 9 > >>>>>> 001e390: 6462 6137 6333 362d 6431 6432 2d34 6163 dba7c36-d1d2-4= ac > >>>>>> 001e3a0: 642d 6135 3037 2d30 3634 6132 3462 3538 d-a507-064a24b= 58 > >>>>>> 001e3b0: 3666 3420 726f 6f74 2069 6565 6531 3237 6f4 root ieee1= 27 > >>>>>> 001e3c0: 352f 2f70 6369 4033 3036 2f70 6369 4031 5//pci@306/pci= @1 > >>>>>> 001e3d0: 2f4c 5349 5c2c 6d72 7361 7340 302f 6469 /LSI\,mrsas@0/= di > >>>>>> 001e3e0: 736b 4030 3a61 200a 7365 7420 7072 6566 sk@0:a .set pr= ef > >>>>>> 001e3f0: 6978 3d28 2472 6f6f 7429 272f 6772 7562 ix=3D($root)'/= grub > >>>>>> 001e400: 3227 0a00 0000 0000 0000 0003 0000 0010 2'............= .. > >>>>>> 001e410: 2f67 7275 6232 0000 /grub2.. > >>>>>> > >>>>>> Before this change the following args would be sent to > >>>>>> grub_cmd_do_search: > >>>>>> > >>>>>> key: 9dba7c36-d1d2-4acd-a507-064a24b586f4 > >>>>>> var: root > >>>>>> hint: ieee1275//pci@306/pci@1/LSI,mrsas@0/disk@0:a > >>>>>> > >>>>>> The hint above is not correct. It should be: > >>>>>> > >>>>>> hint: ieee1275//pci@306/pci@1/LSI\,mrsas@0/disk@0:a > >>>>>> > >>>>>> Later on, when it tries to use this disk, it incorrectly truncat= es > >>>>>> the device name since the comma isn=E2=80=99t escaped and tries = to do the > >>>>>> grub_disk_open with ieee1275//pci@306/pci@1/LSI. > >>>>>> > >>>>>> Signed-off-by: Eric Snowberg > >>>>>> --- > >>>>>> grub-core/kern/parser.c | 1 - > >>>>>> 1 files changed, 0 insertions(+), 1 deletions(-) > >>>>>> > >>>>>> diff --git a/grub-core/kern/parser.c b/grub-core/kern/parser.c > >>>>>> index 78175aa..be88baa 100644 > >>>>>> --- a/grub-core/kern/parser.c > >>>>>> +++ b/grub-core/kern/parser.c > >>>>>> @@ -30,7 +30,6 @@ static struct grub_parser_state_transition sta= te_transitions[] =3D { > >>>>>> {GRUB_PARSER_STATE_TEXT, GRUB_PARSER_STATE_QUOTE, '\'', 0}, > >>>>>> {GRUB_PARSER_STATE_TEXT, GRUB_PARSER_STATE_DQUOTE, '\"', 0}, > >>>>>> {GRUB_PARSER_STATE_TEXT, GRUB_PARSER_STATE_VAR, '$', 0}, > >>>>>> - {GRUB_PARSER_STATE_TEXT, GRUB_PARSER_STATE_ESC, '\\', 0}, > >>>>> > >>>>> I have a feeling that this way you break parser for everybody. > >>>> > >>>> Can you explain what would break on other platforms with this chan= ge? > >>> > >>> After your patch embedded config is parsed incorrectly, e.g. "set a= =3D\f" > >>> sets $a to "\f" instead of "f=E2=80=9D. > >> > >> That is a useful config? > > > > Sorry, I do not understand the question. > > > >>>>> Could you explain why it is valid for all? > >>>> > >>>> Any platform containing a device with a comma in it would have the > >>>> problem I identified above. > >>> > >>> So, I think that you should store unescaped strings in core.img if = it is required. > >> > >> Throughout GRUB a comma is escaped unless it is before a partition n= umber. > >> If I store it unescaped in the core.img I would still have the same = problem > >> above when going into grub_disk_open. Hmmm... Does it (un)escape paths? > > I understand that this can be a problem for you and I am happy that y= ou wish > > to fix it. However, I do not accept breakage of the parser as a solut= ion for > > this problem. At least in such form (by the way, even if we assume th= at patch > > is correct it seems to me incomplete after closer look). Sorry. So, I= am looking > > forward for another patch(es) which properly fixes the issue. > > Could you provide a recommendation on how to fix it then? I think that we should store and use everywhere if possible unescaped texts. Escaped versions should be used only if required, e.g. if we pass something to a shell. On the other hand if we get as an input escaped form we should unsecape it immediately. This way we avoid a lot of problems coming from mixing escaped and unescaped forms in various places. Daniel