WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] fix mapping bugs in map_domain_va in xc_ptrace.c

To: xen-changelog@xxxxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] fix mapping bugs in map_domain_va in xc_ptrace.c
From: BitKeeper Bot <riel@xxxxxxxxxxx>
Date: Sun, 20 Mar 2005 15:07:47 +0000
Delivery-date: Mon, 21 Mar 2005 16:04:05 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-archive: <http://sourceforge.net/mailarchive/forum.php?forum=xen-changelog>
List-help: <mailto:xen-changelog-request@lists.sourceforge.net?subject=help>
List-id: <xen-changelog.lists.sourceforge.net>
List-post: <mailto:xen-changelog@lists.sourceforge.net>
List-subscribe: <https://lists.sourceforge.net/lists/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.sourceforge.net?subject=subscribe>
List-unsubscribe: <https://lists.sourceforge.net/lists/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.sourceforge.net?subject=unsubscribe>
Reply-to: Xen Development List <xen-devel@xxxxxxxxxxxxxxxxxxxxx>
Sender: xen-changelog-admin@xxxxxxxxxxxxxxxxxxxxx
ChangeSet 1.1332, 2005/03/20 15:07:47+00:00, iap10@xxxxxxxxxxxxxxxxxxxx

        fix mapping bugs in map_domain_va in xc_ptrace.c
        map pages RO
        Signed-off-by: Kip Macy <kmacy@xxxxxxxxxxx>
        Signed-off-by: ian@xxxxxxxxxxxxx



 xc_ptrace.c |   24 ++++++++++++++++--------
 1 files changed, 16 insertions(+), 8 deletions(-)


diff -Nru a/tools/libxc/xc_ptrace.c b/tools/libxc/xc_ptrace.c
--- a/tools/libxc/xc_ptrace.c   2005-03-21 11:03:13 -05:00
+++ b/tools/libxc/xc_ptrace.c   2005-03-21 11:03:13 -05:00
@@ -123,7 +123,7 @@
 /* --------------------- */
 
 static void *
-map_domain_va(unsigned long domid, void * guest_va)
+map_domain_va(unsigned long domid, void * guest_va, int perm)
 {
     unsigned long pde, page;
     unsigned long va = (unsigned long)guest_va;
@@ -134,6 +134,8 @@
     static unsigned long *pde_virt;
     static unsigned long page_phys;
     static unsigned long *page_virt;
+    
+    static int prev_perm;
     if (!regs_valid) 
     {
        int retval = xc_domain_getfullinfo(xc_handle, domid, 0, NULL, &ctxt);
@@ -166,17 +168,19 @@
     }
     if ((page = pde_virt[vtopti(va)]) == 0)
        goto error_out;
-    if (page != page_phys) 
+    if (page != page_phys || perm != prev_perm) 
     {
        page_phys = page;
        if (page_virt)
            munmap(page_virt, PAGE_SIZE);
        if ((page_virt = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
-                                            PROT_READ|PROT_WRITE,
+                                            perm,
                                              page_phys >> PAGE_SHIFT)) == 
NULL) {
            printf("cr3 %lx pde %lx page %lx pti %lx\n", cr3, pde, page, 
vtopti(va));
+           page_phys = 0;
            goto error_out;
        }
+       prev_perm = perm;
     }  
     return (void *)(((unsigned long)page_virt) | (va & BSD_PAGE_MASK));
 
@@ -247,17 +251,21 @@
     switch (request) { 
     case PTRACE_PEEKTEXT:
     case PTRACE_PEEKDATA:
+       if ((guest_va = (unsigned long *)map_domain_va(pid, addr, PROT_READ)) 
== NULL) {
+           status = EFAULT;
+           goto done;
+       }
+
+       retval = *guest_va;
+       break;
     case PTRACE_POKETEXT:
     case PTRACE_POKEDATA:
-       if ((guest_va = (unsigned long *)map_domain_va(pid, addr)) == NULL) {
+       if ((guest_va = (unsigned long *)map_domain_va(pid, addr, 
PROT_READ|PROT_WRITE)) == NULL) {
            status = EFAULT;
            goto done;
        }
 
-       if (request == PTRACE_PEEKTEXT || request == PTRACE_PEEKDATA)
-           retval = *guest_va;
-       else
-           *guest_va = (unsigned long)data;
+       *guest_va = (unsigned long)data;
        break;
     case PTRACE_GETREGS:
     case PTRACE_GETFPREGS:


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>