# HG changeset patch # User kaf24@firebug.cl.cam.ac.uk # Date 1114254280 0 # Node ID cc637433c0fd7dc5782e35dfc69e37d1666aefcb # Parent c7f1dee0ac34e14be3302c26512a46b37389fc6c bitkeeper revision 1.1373 (426a2bc8m7wX71OOkLtSOgNXcrObMA) xc_domain.c: Ensure ctxt is mlocked in xc_domain_getfullinfo. diff -r c7f1dee0ac34 -r cc637433c0fd tools/libxc/xc_domain.c --- a/tools/libxc/xc_domain.c Sat Apr 23 10:53:18 2005 +0000 +++ b/tools/libxc/xc_domain.c Sat Apr 23 11:04:40 2005 +0000 @@ -146,7 +146,7 @@ int xc_domain_getfullinfo(int xc_handle, xc_domaininfo_t *info, full_execution_context_t *ctxt) { - int rc; + int rc, errno_saved; dom0_op_t op; op.cmd = DOM0_GETDOMAININFO; @@ -154,12 +154,23 @@ int xc_domain_getfullinfo(int xc_handle, op.u.getdomaininfo.exec_domain = (u16)vcpu; op.u.getdomaininfo.ctxt = ctxt; + if ( (ctxt != NULL) && + ((rc = mlock(ctxt, sizeof(*ctxt))) != 0) ) + return rc; + rc = do_dom0_op(xc_handle, &op); - if ( info ) + if ( ctxt != NULL ) + { + errno_saved = errno; + (void)munlock(ctxt, sizeof(*ctxt)); + errno = errno_saved; + } + + if ( info != NULL ) memcpy(info, &op.u.getdomaininfo, sizeof(*info)); - if ( ((u16)op.u.getdomaininfo.domain != domid) && rc > 0 ) + if ( ((u16)op.u.getdomaininfo.domain != domid) && (rc > 0) ) return -ESRCH; else return rc;