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

[Xen-changelog] [xen-unstable] [LIBXC] Fix ptrace memory-mapping code to map pagetables read-only.



# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID 0dc4ae151be2399fd31c0cea2d4fbb49e1bf6692
# Parent  a5a3f48e92c95a7b7aae534102440dacdfaaffa8
[LIBXC] Fix ptrace memory-mapping code to map pagetables read-only.
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
 tools/libxc/xc_ptrace.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)

diff -r a5a3f48e92c9 -r 0dc4ae151be2 tools/libxc/xc_ptrace.c
--- a/tools/libxc/xc_ptrace.c   Wed Oct 04 19:00:11 2006 +0100
+++ b/tools/libxc/xc_ptrace.c   Thu Oct 05 09:30:07 2006 +0100
@@ -251,7 +251,7 @@ map_domain_va_pae(
     if ( !(l2e & _PAGE_PRESENT) )
         return NULL;
     l1p = to_ma(cpu, l2e);
-    l1 = xc_map_foreign_range(xc_handle, current_domid, PAGE_SIZE, perm, l1p 
>> PAGE_SHIFT);
+    l1 = xc_map_foreign_range(xc_handle, current_domid, PAGE_SIZE, PROT_READ, 
l1p >> PAGE_SHIFT);
     if ( l1 == NULL )
         return NULL;
 
@@ -281,7 +281,6 @@ map_domain_va_64(
     uint64_t *l4, *l3, *l2, *l1;
     static void *v[MAX_VIRT_CPUS];
 
-
     if ((ctxt[cpu].ctrlreg[4] & 0x20) == 0 ) /* legacy ia32 mode */
         return map_domain_va_32(xc_handle, cpu, guest_va, perm);
 
@@ -309,7 +308,6 @@ map_domain_va_64(
     if ( l2 == NULL )
         return NULL;
 
-    l1 = NULL;
     l2e = l2[l2_table_offset(va)];
     munmap(l2, PAGE_SIZE);
     if ( !(l2e & _PAGE_PRESENT) )
@@ -318,11 +316,12 @@ map_domain_va_64(
     if (l2e & 0x80)  { /* 2M pages */
         p = to_ma(cpu, (l1p + l1_table_offset(va)) << PAGE_SHIFT);
     } else { /* 4K pages */
-        l1 = xc_map_foreign_range(xc_handle, current_domid, PAGE_SIZE, perm, 
l1p >> PAGE_SHIFT);
+        l1 = xc_map_foreign_range(xc_handle, current_domid, PAGE_SIZE, 
PROT_READ, l1p >> PAGE_SHIFT);
         if ( l1 == NULL )
             return NULL;
 
         l1e = l1[l1_table_offset(va)];
+        munmap(l1, PAGE_SIZE);
         if ( !(l1e & _PAGE_PRESENT) )
             return NULL;
         p = to_ma(cpu, l1e);
@@ -330,8 +329,6 @@ map_domain_va_64(
     if ( v[cpu] != NULL )
         munmap(v[cpu], PAGE_SIZE);
     v[cpu] = xc_map_foreign_range(xc_handle, current_domid, PAGE_SIZE, perm, p 
>> PAGE_SHIFT);
-    if (l1)
-        munmap(l1, PAGE_SIZE);
     if ( v[cpu] == NULL )
         return NULL;
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.