From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43910) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCa47-0005GY-Iq for qemu-devel@nongnu.org; Mon, 13 Jun 2016 18:10:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bCa43-0007db-6r for qemu-devel@nongnu.org; Mon, 13 Jun 2016 18:10:38 -0400 Received: from eddie.linux-mips.org ([148.251.95.138]:34866 helo=cvs.linux-mips.org) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCa42-0007cQ-Oq for qemu-devel@nongnu.org; Mon, 13 Jun 2016 18:10:35 -0400 Received: from localhost.localdomain ([127.0.0.1]:55520 "EHLO linux-mips.org" rhost-flags-OK-OK-OK-FAIL) by eddie.linux-mips.org with ESMTP id S27027984AbcFMWK1hhyWh (ORCPT ); Tue, 14 Jun 2016 00:10:27 +0200 Date: Tue, 14 Jun 2016 00:10:18 +0200 From: Ralf Baechle Message-ID: <20160613221018.GA1592@linux-mips.org> References: <20160613144555.GP18794@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: Re: [Qemu-devel] qemu-img segfaults on MIPS hosts due to not having an executable stack List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: "Daniel P. Berrange" , Leon Alrae , Michael Tokarev , QEMU Developers , Aurelien Jarno , James Hogan On Mon, Jun 13, 2016 at 04:16:02PM +0100, Peter Maydell wrote: > On 13 June 2016 at 15:45, Daniel P. Berrange 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