On Mon, Jun 13, 2016 at 04:16:02PM +0100, Peter Maydell wrote: > On 13 June 2016 at 15:45, Daniel P. Berrange <berra...@redhat.com> wrote: > > On Mon, Jun 13, 2016 at 03:11:08PM +0100, Peter Maydell wrote: > >> QEMU currently allocates coroutine stacks with a plain g_malloc(), > >> which makes them r/w but not exec. That's a bug in QEMU which we > >> should fix (though I'm not sure how best to identify the required > >> permissions for stacks). It's a bit unhelpful of the kernel to > >> assume an executable stack and not give a useful diagnostic or > >> failure mode if it's not true, though. > > > > I'd suggest we just #ifdef the code base on architecture, on that basis > > all platforms except mips are probably happy with non-exec stack. > > Have they really all got rid of signal handler trampolines?
Apparently Android wants a non-executable stack for security reasons. That said, some special code such as GCC's nested functions may require stack trampolines. For such code there is the option to use the p_flags of the PT_GNU_STACK program header to mark the stack executable. One way to do so is to pass the option "-z execstack" to ld or a ".section .note.GNU-stack,"",@progbits" into the assembler code which is what GCC will do when generating trampolines. Ralf