qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] fix interaction with noexecstack
@ 2004-09-04  0:00 Lennert Buytenhek
  2004-09-04  0:15 ` Lennert Buytenhek
  2004-09-04 10:49 ` Fabrice Bellard
  0 siblings, 2 replies; 10+ messages in thread
From: Lennert Buytenhek @ 2004-09-04  0:00 UTC (permalink / raw)
  To: qemu-devel

Hi,

qemu-arm doesn't work on Fedora Core 2 by default because it expects to
be able to execute stuff off the heap (code_gen_buffer), but that part of
the heap is not marked PROT_EXEC, and Fedora Core 2 has a patch that sets
the CS segment limit to the highest PROT_EXEC-mapped address in the address
space.

It's a bit of a hacky fix, but it Works For Me(tm) on the default Fedora
2.6.5 kernel.  I haven't yet looked into why qemu-arm was crashing on the
Fedora 2.6.[78] update kernels.


--L


diff -urN qemu-20040804.orig/exec.c qemu-20040804.test/exec.c
--- qemu-20040804.orig/exec.c	2004-07-06 02:00:18.000000000 +0300
+++ qemu-20040804.test/exec.c	2004-09-04 02:49:25.414945456 +0300
@@ -127,6 +127,9 @@
 
 static void page_init(void)
 {
+    unsigned long address;
+    unsigned long length;
+
     /* NOTE: we can always suppose that qemu_host_page_size >=
        TARGET_PAGE_SIZE */
 #ifdef _WIN32
@@ -134,6 +137,17 @@
 #else
     qemu_real_host_page_size = getpagesize();
 #endif
+
+    address = (unsigned long)code_gen_buffer;
+    address &= ~(qemu_real_host_page_size - 1);
+
+    length = (unsigned long)code_gen_buffer + sizeof(code_gen_buffer);
+    length -= address;
+    length += qemu_real_host_page_size - 1;
+    length &= ~(qemu_real_host_page_size - 1);
+
+    mprotect(address, length, PROT_READ | PROT_WRITE | PROT_EXEC);
+
     if (qemu_host_page_size == 0)
         qemu_host_page_size = qemu_real_host_page_size;
     if (qemu_host_page_size < TARGET_PAGE_SIZE)

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2004-09-29 21:29 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-09-04  0:00 [Qemu-devel] [PATCH] fix interaction with noexecstack Lennert Buytenhek
2004-09-04  0:15 ` Lennert Buytenhek
2004-09-04 10:49 ` Fabrice Bellard
2004-09-04 12:19   ` Filip Navara
2004-09-04 14:45     ` [Qemu-devel] " Ronald
2004-09-04 16:15       ` Filip Navara
2004-09-04 17:07         ` [Qemu-devel] " Ronald
2004-09-07  7:59           ` Hartmut Birr
2004-09-05 14:13         ` [Qemu-devel] " Lennert Buytenhek
2004-09-29 21:23         ` Fabrice Bellard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).