From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by sourceware.org (Postfix) with ESMTP id 0924A385DC05 for ; Wed, 1 Apr 2020 08:47:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 0924A385DC05 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-84-_R6ihbdbOi6_CFact3-3gw-1; Wed, 01 Apr 2020 04:47:04 -0400 X-MC-Unique: _R6ihbdbOi6_CFact3-3gw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9604D100550D; Wed, 1 Apr 2020 08:47:02 +0000 (UTC) Received: from oldenburg2.str.redhat.com (ovpn-113-15.ams2.redhat.com [10.36.113.15]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2F483912B0; Wed, 1 Apr 2020 08:46:59 +0000 (UTC) From: Florian Weimer To: Fangrui Song Cc: Mark Wielaard , "H.J. Lu" , Cary Coutant , "Zhang\, Annita" , "Liu\, Hongtao" , gnu-gabi , GNU C Library , Binutils Subject: Re: binutils ld and new PT_GNU_PROPERTY segment References: <20200219182701.vrtzwhgtpelmpaub@google.com> <2e29243995903cf2d52975543675f2b92fa1e201.camel@klomp.org> <20200222051913.meiied65a5daylvk@google.com> Date: Wed, 01 Apr 2020 10:46:58 +0200 In-Reply-To: <20200222051913.meiied65a5daylvk@google.com> (Fangrui Song's message of "Fri, 21 Feb 2020 21:19:13 -0800") Message-ID: <87tv231tkt.fsf@oldenburg2.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-5.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gnu-gabi@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gnu-gabi mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Apr 2020 08:47:09 -0000 * Fangrui Song: > Below is my understanding of these matters. Hope they will be useful for > interested stakeholders (for example, AArch64 devs, though PT_GNU_PROPERT= Y is > currently driven by x86) who don't follow the discussions so closely. > > 1. We need PT_GNU_PROPERTY. > Old linkers don't know the special processing on input .note.gnu.propert= y sections. > The output .note.gnu.property does not take -z ibt/-z shstk/-z force-bti= /-z pac-plt into account =3D> > invalid. > The produced PT_NOTE may contain multiple NT_GNU_PROPERTY_TYPE_0 =3D> in= valid [3] In practice, we can recognize binaries produced by old linkers when the object has been linked on a CET-enabled distribution because the produced notes are always invalid. The glibc dynamic loader already checks for this and does not enable CET in this case. ld -r involving exactly one CET-enabled object and one or more non-CET objects is still problematic, of course, but it seems an unlikely outcome. The only way I can see this happening is with a CET-by-default GCC (such as the one Ubuntu uses), but then you still would have to use another linker (not /usr/bin/ld). So even that seems like a fringe issue to me. In short, we looked at this situation, and still think that it's supportable. > Also note that sh_addralign(.note.gnu.property)=3D8 on a 64-bit > platform, while > sh_addralign(.note.gnu.build-id)=3Dsh_addralign(.note.ABI-tag)=3D...=3D4 > (ancient mistake made by at least Linux/FreeBSD/NetBSD/...) GNU ld > before PR ld/23658 may create corrupted PT_NOTE. Yes, we ran into some of these issues in our distribution and had to rebuild a few objects. > For at least the above reasons, loaders are better not interpreting PT_N= OTE. > glibc/sysdeps/x86/dl-prop.h is currently interpreting PT_NOTE =3D> it > should be fixed. I'm not sure we can do that for backwards compatibility reasons. The ABI has been out there for several years now. > Given point 1 and 3, this comment deserves a reconsideration: > > > Binaries with .note.gnu.property section have been put into many > > OS releases. We must support them. > > 2. .note.gnu.property behaves strangely, unlike a regular SHT_NOTE. > For a .note.gnu.property aware linker (newer GNU ld, newer lld), > .note.gnu.property input sections are dropped. > > (We have .note.GNU-stack and .note.GNU-split-stack which both require sp= ecial processing, but > they are SHT_PROGBITS.) > > 3. We need SHT_GNU_PROPERTY. > The output .note.gnu.property being SHT_NOTE causes linkers to place the= section in both PT_NOTE > and PT_GNU_PROPERTY. > PT_NOTE, as explained by point 1 above, can cause trouble to old loaders= . > Have we proved that "older linker-produced concatenated PT_NOTE cannot c= ause trouble to loaders interpreting PT_NOTE"? > > SHT_GNU_PROPERTY does not contribute to PT_NOTE and will not cause any p= roblem to old loaders > interpreting PT_NOTE. Yes, I agree that it's desirable to add SHT_GNU_PROPERTY. Thanks, Florian