Opened 3 years ago

Closed 3 years ago

#10369 closed bug (fixed)

arm binaries have an executable stack

Reported by: erikd Owned by: erikd
Priority: normal Milestone: 7.10.2
Component: Compiler Version: 7.11
Keywords: Cc: ezyang
Operating System: Unknown/Multiple Architecture: arm
Type of failure: Other Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

Test T703 is currently failing on on armhf/linux. The test result shows:

GNU_STACK  0x000000 0x00000000 0x00000000 0x00000 0x00000 RWE 0

Arm compiles via LLVM, but x86_64 executbles compiled via LLVM do not have an executable stack.

The other difference between the x86_64 and Arm is the Arm uses ld.gold as the linker. Sure enough, adding -optl -Wl,-z,noexecstack to the ghc command line fixes this, but a better solution is needed.

This is probably also an issue on AArch64 which also uses the ld.gold linker.

Change History (7)

comment:1 Changed 3 years ago by erikd

Cc: ezyang added

@ezyang : What do you think of the idea of adding the required ld command line args to ld flags field of the ghc settings file (when using ld.gold)?

comment:2 Changed 3 years ago by erikd

Owner: set to erikd

comment:3 Changed 3 years ago by erikd

@rwbarton suggests checking if the same problem exists when using ld.gold on x86_64/linux.

comment:4 Changed 3 years ago by erikd

Tested this on x86_64 by hacking aclocal.m4 to add x86_64 to arm and aarch64, then configured and checked that the settings file contained:

 ("C compiler link flags", " -fuse-ld=gold"),
 ("ld command", "/usr/bin/ld.gold"),

built the compiler and then ran test T703 and it passed.

So, when using ld.gold on x86_64 we do not end up with an executable stack. This seems like an Arm specific problem.

comment:5 Changed 3 years ago by Erik de Castro Lopo <erikd@…>

In 63a10bbc42492c58feb377d79e05a185e6efcd5a/ghc:

arm: Force non-executable stack (#10369)

Test `T703` was found to be failing on arm/linux. The solution
was to add a linker flag to explicitly set the stack to
non-executable.

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>

Test Plan: validate on x86_64 and arm linux

Reviewers: ezyang, rwbarton, austin

Subscribers: bgamari, thomie

Differential Revision: https://phabricator.haskell.org/D875

GHC Trac Issues: #10369

comment:6 Changed 3 years ago by erikd

Milestone: 7.12.17.10.2
Status: newmerge

comment:7 Changed 3 years ago by thoughtpolice

Resolution: fixed
Status: mergeclosed

Merged to ghc-7.10.

Note: See TracTickets for help on using tickets.