[erlang-patches] Remove executable stacks (HiPE/amd64)
Mikael Pettersson
mikpe@REDACTED
Sun Feb 1 16:21:41 CET 2009
Mikael Pettersson writes:
> Davide Pesavento writes:
> > Hi,
> > the attached patch fixes executable stacks in HiPE asm code for amd64.
> > I guess a similar patch can easily be applied to the other
> > architectures.
> >
> > References:
> > [1] https://bugs.gentoo.org/show_bug.cgi?id=249328
> > [2] http://www.erlang.org/pipermail/erlang-bugs/2008-December/001125.html
> > [3] http://www.gentoo.org/proj/en/hardened/gnu-stack.xml
>
> Thanks, this patch is what I ([2] above) suspected was needed.
>
> Note that HiPE never has used executable stacks, all this does is
> annotate some assembly file modules so that the build tools don't
> mark them as needing executable stack.
>
> This will be included in the R13B release, extended to cover all
> architectures not just amd64.
Here is the corresponding patch committed to HiPE CVS, extended to
amd64, arm, ppc32, sparc32, and x86. Applies cleanly to R12B-5.
If you intend to maintain an R12B-5 based package I also advise you to
include the following bug fix:
<http://www.erlang.org/pipermail/erlang-bugs/2009-January/001173.html>
/Mikael
The HiPE group
--- otp-0125/erts/emulator/hipe/hipe_amd64_bifs.m4.~1~ 2008-10-27 20:07:08.000000000 +0100
+++ otp-0125/erts/emulator/hipe/hipe_amd64_bifs.m4 2009-02-01 11:36:47.000000000 +0100
@@ -531,3 +531,7 @@ define(gc_bif_interface_2,`standard_bif_
define(gc_nofail_primop_interface_1,`nofail_primop_interface_1($1, $2)')
include(`hipe/hipe_bif_list.m4')
+
+`#if defined(__linux__) && defined(__ELF__)
+.section .note.GNU-stack,"",%progbits
+#endif'
--- otp-0125/erts/emulator/hipe/hipe_amd64_glue.S.~1~ 2008-11-07 23:44:11.000000000 +0100
+++ otp-0125/erts/emulator/hipe/hipe_amd64_glue.S 2009-02-01 11:36:47.000000000 +0100
@@ -418,3 +418,7 @@ nbif_inc_stack_0:
LOAD_ARG_REGS
SWITCH_C_TO_ERLANG_QUICK
NSP_RET0
+
+#if defined(__linux__) && defined(__ELF__)
+.section .note.GNU-stack,"",%progbits
+#endif
--- otp-0125/erts/emulator/hipe/hipe_arm_bifs.m4.~1~ 2008-10-27 20:07:08.000000000 +0100
+++ otp-0125/erts/emulator/hipe/hipe_arm_bifs.m4 2009-02-01 11:37:21.000000000 +0100
@@ -525,3 +525,7 @@ $1:
#endif')
include(`hipe/hipe_bif_list.m4')
+
+`#if defined(__linux__) && defined(__ELF__)
+.section .note.GNU-stack,"",%progbits
+#endif'
--- otp-0125/erts/emulator/hipe/hipe_arm_glue.S.~1~ 2008-11-07 23:44:11.000000000 +0100
+++ otp-0125/erts/emulator/hipe/hipe_arm_glue.S 2009-02-01 11:38:25.000000000 +0100
@@ -392,3 +392,7 @@ hipe_arm_inc_stack:
LOAD_ARG_REGS
# this relies on LOAD_ARG_REGS not clobbering TEMP_ARG0
mov pc, TEMP_ARG0
+
+#if defined(__linux__) && defined(__ELF__)
+.section .note.GNU-stack,"",%progbits
+#endif
--- otp-0125/erts/emulator/hipe/hipe_ppc_bifs.m4.~1~ 2008-10-27 20:07:09.000000000 +0100
+++ otp-0125/erts/emulator/hipe/hipe_ppc_bifs.m4 2009-02-01 11:36:47.000000000 +0100
@@ -544,3 +544,7 @@ ASYM($1):
#endif')
include(`hipe/hipe_bif_list.m4')
+
+`#if defined(__linux__) && defined(__ELF__)
+.section .note.GNU-stack,"",%progbits
+#endif'
--- otp-0125/erts/emulator/hipe/hipe_ppc_glue.S.~1~ 2008-11-07 23:44:12.000000000 +0100
+++ otp-0125/erts/emulator/hipe/hipe_ppc_glue.S 2009-02-01 11:36:47.000000000 +0100
@@ -557,3 +557,7 @@ ASYM(hipe_ppc_inc_stack):
LOAD NSP, P_NSP(P)
LOAD_ARG_REGS
blr
+
+#if defined(__linux__) && defined(__ELF__)
+.section .note.GNU-stack,"",%progbits
+#endif
--- otp-0125/erts/emulator/hipe/hipe_sparc_bifs.m4.~1~ 2008-10-27 20:07:09.000000000 +0100
+++ otp-0125/erts/emulator/hipe/hipe_sparc_bifs.m4 2009-02-01 11:36:47.000000000 +0100
@@ -554,3 +554,7 @@ $1:
#endif')
include(`hipe/hipe_bif_list.m4')
+
+`#if defined(__linux__) && defined(__ELF__)
+.section .note.GNU-stack,"",%progbits
+#endif'
--- otp-0125/erts/emulator/hipe/hipe_sparc_glue.S.~1~ 2008-11-07 23:44:12.000000000 +0100
+++ otp-0125/erts/emulator/hipe/hipe_sparc_glue.S 2009-02-01 11:36:47.000000000 +0100
@@ -423,3 +423,7 @@ hipe_sparc_inc_stack:
/* this relies on LOAD_ARG_REGS not clobbering TEMP_ARG0 */
jmp TEMP_ARG0+8
ld [P+P_NSP], NSP /* delay slot */
+
+#if defined(__linux__) && defined(__ELF__)
+.section .note.GNU-stack,"",%progbits
+#endif
--- otp-0125/erts/emulator/hipe/hipe_x86_bifs.m4.~1~ 2008-10-27 20:07:09.000000000 +0100
+++ otp-0125/erts/emulator/hipe/hipe_x86_bifs.m4 2009-02-01 11:36:47.000000000 +0100
@@ -611,3 +611,7 @@ define(gc_bif_interface_2,`standard_bif_
define(gc_nofail_primop_interface_1,`nofail_primop_interface_1($1, $2)')
include(`hipe/hipe_bif_list.m4')
+
+`#if defined(__linux__) && defined(__ELF__)
+.section .note.GNU-stack,"",%progbits
+#endif'
--- otp-0125/erts/emulator/hipe/hipe_x86_glue.S.~1~ 2008-11-07 23:44:12.000000000 +0100
+++ otp-0125/erts/emulator/hipe/hipe_x86_glue.S 2009-02-01 11:36:47.000000000 +0100
@@ -395,3 +395,7 @@ ASYM(nbif_inc_stack_0):
LOAD_CALLER_SAVE
SWITCH_C_TO_ERLANG_QUICK
NSP_RET0
+
+#if defined(__linux__) && defined(__ELF__)
+.section .note.GNU-stack,"",%progbits
+#endif
More information about the erlang-patches
mailing list