On Wed, Sep 20, 2017 at 12:25:46PM +0000, Joseph Myers wrote:
> On Wed, 20 Sep 2017, Andreas Schwab wrote:
> 
> > On Sep 19 2017, Joseph Myers <jos...@codesourcery.com> wrote:
> > 
> > > I've sent a glibc patch 
> > > <https://sourceware.org/ml/libc-alpha/2017-09/msg00734.html>.  I think 
> > > the 
> > > key questions for architecture experts now are: on each of those three 
> > > architectures, do trampolines ever require executable stacks, and, if 
> > > they 
> > > do, how does this work at present when the kernel defaults to 
> > > non-executable and my understanding at 
> > > <https://sourceware.org/ml/libc-alpha/2017-09/msg00747.html> would be 
> > > that 
> > > glibc would only make thread stacks executable on those architectures, 
> > > not 
> > > the main process stacks, and GCC will never generate an explicit marker 
> > > on 
> > > those architectures to request an executable stack?
> > 
> > For ia64 on linux there is EF_IA_64_LINUX_EXECUTABLE_STACK to request
> > executable heap and stack.  But since ia64 uses function descriptors,
> > trampolines never need that.
> 
> Thanks.  I think this adequately confirms my glibc patch is safe for ia64.  
> The questions above remain for hppa and microblaze.

If for some architectures which generally don't need executable stack for
nested indirect function calls we don't want the .note.GNU-stack notes
in *.s files, the question is if the linker in that case shouldn't either
ignore those notes and either never generate PT_GNU_STACK segments,
or always generate it with RW, then either glibc/kernel can always rely on
missing PT_GNU_STACK - unclear, possibly executable stack, or PT_GNU_STACK
present, RW means no-exec, RWX means exec stack, or it can have some list of
architectures for which missing PT_GNU_STACK means non-exec stack.

The current state is really not very good, some *.s/*.S files have
.note.GNU-stack notes emitted regardless of architecture, e.g. for all linux
arches, while others (e.g. arch specific) don't have those notes.  And the
compiler sometimes emits them, sometimes it doesn't (e.g. RH ia64 gcc had
.note.GNU-stack emission patched in, while upstream didn't; similarly for
ppc64 (non-le)).  So when mixing that, there is often PT_GNU_STACK with RWX
e.g. on ia64 or ppc64 even when there is no exec stack.

        Jakub

Reply via email to