public inbox for gnu-gabi@sourceware.org
 help / color / mirror / Atom feed
From: Szabolcs Nagy <szabolcs.nagy@arm.com>
To: Florian Weimer <fweimer@redhat.com>
Cc: Fangrui Song <i@maskray.me>,
	GNU C Library <libc-alpha@sourceware.org>,
	gnu-gabi <gnu-gabi@sourceware.org>,
	Mark Wielaard <mark@klomp.org>,
	"Zhang, Annita" <annita.zhang@intel.com>,
	Binutils <binutils@sourceware.org>,
	Cary Coutant <ccoutant@gmail.com>,
	"Liu, Hongtao" <hongtao.liu@intel.com>
Subject: Re: binutils ld and new PT_GNU_PROPERTY segment
Date: Wed, 1 Apr 2020 10:22:55 +0100	[thread overview]
Message-ID: <20200401092253.GM27072@arm.com> (raw)
In-Reply-To: <87tv231tkt.fsf@oldenburg2.str.redhat.com>

The 04/01/2020 10:46, Florian Weimer via Libc-alpha wrote:
> * Fangrui Song:
> 
> > Below is my understanding of these matters. Hope they will be useful for
> > interested stakeholders (for example, AArch64 devs, though PT_GNU_PROPERTY 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.property sections.
> >  The output .note.gnu.property does not take -z ibt/-z shstk/-z force-bti/-z pac-plt into account =>
> >  invalid.
> >  The produced PT_NOTE may contain multiple NT_GNU_PROPERTY_TYPE_0 => invalid [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.

why only -r is problematic?

i thought linking exactly one marked object and other non-marked
ones with an old linker will have the (incorrect) marking on the
output that cannot be recognised as wrong.

this is why my plan for aarch64 is to only check PT_GNU_PROPERTY
in glibc (which implies a new linker), i believe the kernel
patches do so too.

> 
> In short, we looked at this situation, and still think that it's
> supportable.
> 
> >  Also note that sh_addralign(.note.gnu.property)=8 on a 64-bit
> >  platform, while
> >  sh_addralign(.note.gnu.build-id)=sh_addralign(.note.ABI-tag)=...=4
> >  (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_NOTE.
> >  glibc/sysdeps/x86/dl-prop.h is currently interpreting PT_NOTE => 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.

on non-x86 targets it can be still done.

> >  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 special 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 cause trouble to loaders interpreting PT_NOTE"?
> >
> >  SHT_GNU_PROPERTY does not contribute to PT_NOTE and will not cause any problem to old loaders
> >  interpreting PT_NOTE.
> 
> Yes, I agree that it's desirable to add SHT_GNU_PROPERTY.

+1

  reply	other threads:[~2020-04-01  9:23 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-01  0:00 Mark Wielaard
2020-01-01  0:00 ` H.J. Lu
2020-01-01  0:00   ` Fangrui Song via gnu-gabi
2020-01-01  0:00     ` Mark Wielaard
2020-01-01  0:00       ` H.J. Lu
2020-01-01  0:00         ` Mark Wielaard
2020-01-01  0:00           ` H.J. Lu
2020-01-01  0:00             ` H.J. Lu
2020-01-01  0:00             ` Mark Wielaard
2020-01-01  0:00               ` H.J. Lu
2020-01-01  0:00                 ` Fangrui Song
2020-01-01  0:00                   ` H.J. Lu
2020-01-01  0:00                     ` Mark Wielaard
2020-01-01  0:00                       ` H.J. Lu
2020-01-01  0:00                         ` Mark Wielaard
2020-01-01  0:00                           ` H.J. Lu
2020-01-01  0:00                             ` Mark Wielaard
2020-01-01  0:00                               ` Fangrui Song
2020-04-01  8:46                                 ` Florian Weimer
2020-04-01  9:22                                   ` Szabolcs Nagy [this message]
2020-04-01  9:29                                     ` Florian Weimer
2020-04-01 10:10                                       ` Szabolcs Nagy
2020-04-01 10:21                                         ` Florian Weimer
2020-01-01  0:00                             ` Fangrui Song
2020-01-01  0:00                               ` H.J. Lu
2020-01-01  0:00     ` Zhang, Annita
2020-01-01  0:00   ` Mark Wielaard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200401092253.GM27072@arm.com \
    --to=szabolcs.nagy@arm.com \
    --cc=annita.zhang@intel.com \
    --cc=binutils@sourceware.org \
    --cc=ccoutant@gmail.com \
    --cc=fweimer@redhat.com \
    --cc=gnu-gabi@sourceware.org \
    --cc=hongtao.liu@intel.com \
    --cc=i@maskray.me \
    --cc=libc-alpha@sourceware.org \
    --cc=mark@klomp.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).