From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [80.241.56.152]) by sourceware.org (Postfix) with ESMTPS id 4CBB33857374 for ; Fri, 20 May 2022 13:01:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4CBB33857374 Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4L4RgD4BvWz9skg; Fri, 20 May 2022 15:01:12 +0200 (CEST) Date: Fri, 20 May 2022 15:01:09 +0200 From: Iain Buclaw Subject: Re: [PATCH] gdc 9, 10 and 11 bug fix To: Marc =?iso-8859-1?q?Aur=E8le?= La France Cc: gcc-patches@gcc.gnu.org References: <1652619184.mo716bh9xr.astroid@pulse.none> <1652785964.hma4ncd2fy.astroid@pulse.none> <1652803794.4apc2k19jf.astroid@pulse.none> In-Reply-To: MIME-Version: 1.0 Message-Id: <1653051283.jungooescn.astroid@pulse.none> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 May 2022 13:01:18 -0000 Excerpts from Marc Aur=C3=A8le La France's message of Mai 20, 2022 6:56 am: > On Tue, 17 May 2022, Marc Aur=C3=A8le La France wrote: >> On Tue, 17 May 2022, Iain Buclaw wrote: >>> Excerpts from Marc Aur=C3=A8le La France's message of Mai 17, 2022 5:31= pm: >>>> On Tue, 17 May 2022, Iain Buclaw wrote: >>>>> Excerpts from Marc Aur=C3=A8le La France's message of Mai 16, 2022 11= :34 pm: >>>>>> On Sun, 15 May 2022, Iain Buclaw wrote: >>>>>>> Excerpts from Marc Aur=C3=A8le La France's message of Mai 12, 2022 = 10:29 pm: >=20 >>>>>>>> No compiler has any business rejecting files for the sole crime of >>>>>>>> being symlinked to. The following applies, modulo patch fuzz, to = the >>>>>>>> 9, 10 and 11 series of compilers. >=20 >>>>>>>> Given my use of shadow trees, this bug attempted to prevent me fro= m >>>>>>>> building 12.1.0. The D-based gdc in 12.1.0 and up does not exhibi= t >>>>>>>> this quirky behaviour. >=20 >>>>>>> Thanks, I've checked upstream and see the following change: >=20 >>>>>>> https://github.com/dlang/dmd/pull/11836/commits/ebda81e44fd0ca4b247= a1860d9bef411c41c16cb >=20 >>>>>>> It should be fine to just backport that. >=20 >>>>>> Thanks for the pointer. >=20 >>>>>> I ended up with the three slightly different diffs below, one each f= or >>>>>> the 9, 10 and 11 branches. Each was rebuilt using 8.5.0, then used = to >>>>>> rebuild 12.1.0. All of this ran smoothly without complaint, althoug= h I >>>>>> wouldn't want to do this on a 486... >=20 >>>>>> Signed-off-by: Marc Aur=C3=A8le La France >=20 >>>>>> For GCC 9 ---------- 8< ---------- >>>>>>=20 >>>>>> diff -aNpRruz -X /etc/diff.excludes gcc-9.4.0/gcc/d/dmd/root/filenam= e.c=20 >>>>>> devel-9.4.0/gcc/d/dmd/root/filename.c >>>>>> --- gcc-9.4.0/gcc/d/dmd/root/filename.c 2021-06-01 01:53:04.71647477= 4=20 >>>>>> -0600 >>>>>> +++ devel-9.4.0/gcc/d/dmd/root/filename.c 2022-05-15 15:02:49.995441= 507=20 >>>>>> -0600 >>>>>> @@ -475,53 +475,7 @@ const char *FileName::safeSearchPath(Strings *p= ath,=20 >>>>>> const char *name) >>>>>> >>>>>> return FileName::searchPath(path, name, false); >>>>>> #elif POSIX >>>>>> - /* Even with realpath(), we must check for // and disallow it >>>>>> - */ >>>>>> - for (const char *p =3D name; *p; p++) >>>>>> - { >>>>>> - char c =3D *p; >>>>>> - if (c =3D=3D '/' && p[1] =3D=3D '/') >>>>>> - { >>>>>> - return NULL; >>>>>> - } >>>>>> - } >=20 >>>>> I'd keep this check in, otherwise removing/replacing only the `if >>>>> (path)` branch looks OK to me. >=20 >>>> The corresponding D code doesn't care about double slashes and neither >>>> should this. Also, the comment is misleading as realpath() would no >>>> longer be used here. >=20 >>> True, but the D front-end does check the path in other places now: >=20 >>> https://github.com/dlang/dmd/blob/e9ba29d71b557fe079e95ee6554f116b24159= bab/src/dmd/root/filename.d#L787-L803 >=20 >>> https://github.com/dlang/dmd/blob/e9ba29d71b557fe079e95ee6554f116b24159= bab/src/dmd/expressionsem.d#L5984-L6007 >=20 >>> If we remove all checks, then there'd be nothing to prevent either >>> import("/file") or import("../file") from being used. >=20 >> There is still no check for double slashes. All I want here is to fix a= C++=20 >> -> D migration bug without leaving any detritus behind. >=20 > Anything more on this? >=20 My concern is that given: pragma(msg, import("/etc/fstab")); pragma(msg, import("../../../../../../etc/fstab")); This will result in errors with both `gdc-11 -J.` and `gdc-12 -J.` gdc-11: --- error: file "/etc/fstab" cannot be found or not in a path specified with -J 1 | pragma(msg, import("/etc/fstab")); | ^ error: file "../../../../../../etc/fstab" cannot be found or not in a path = specified with -J 2 | pragma(msg, import("../../../../../../etc/fstab")); | ^ --- gdc-12: --- error: absolute path is not allowed in import expression: =E2=80=98"/etc/fs= tab"=E2=80=99 1 | pragma(msg, import("/etc/fstab")); | ^ error: path refers to parent (=E2=80=98..=E2=80=99) directory: =E2=80=98"..= /../../../../../etc/fstab"=E2=80=99 2 | pragma(msg, import("../../../../../../etc/fstab")); | ^ absimport.d:2:1: note: while evaluat --- With just this change alone, that means both forms will be permitted. If we're going to fix how searchPath checks imports, might as well move in the direction of the v2.100 behaviour in gdc-12, and include a couple checks for absolute paths and `..` in the string. Regards, Iain.