qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] fix interaction with noexecstack


From: Fabrice Bellard
Subject: Re: [Qemu-devel] [PATCH] fix interaction with noexecstack
Date: Sat, 04 Sep 2004 12:49:38 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624

The patch seems OK for me, at least until the instruction cache is dynamically allocated.

Fabrice.

Lennert Buytenhek wrote:
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)



_______________________________________________
Qemu-devel mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/qemu-devel








reply via email to

[Prev in Thread] Current Thread [Next in Thread]