Skip to contentSkip to conversation

tools/libxc: Set max_elem to zero in xc_lockprof_query_number()

PATCH In review Boris Ostrovsky 2 participants 2 messages Aug 13, 2014 – Aug 26, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools/libxc: Set max_elem to zero in xc_lockprof_query_number()

If max_elem is not zero then hypervisor's spinlock_profile_ucopy_elem() will attempt to copy profile data into user's data buffer. Since this buffer is explicitly set to (the equivalent of) NULL the copy will fail, causing xenlockprof to fail as well.

---
 tools/libxc/xc_misc.c | 1 +
 1 file changed, 1 insertion(+)
tools/libxc/xc_misc.c +1 -0
index 4143de6..e253a58 100644
@@ -320,6 +320,7 @@ int xc_lockprof_query_number(xc_interface *xch,
     DECLARE_SYSCTL;
 
     sysctl.cmd = XEN_SYSCTL_lockprof_op;
+    sysctl.u.lockprof_op.max_elem = 0;
     sysctl.u.lockprof_op.cmd = XEN_SYSCTL_LOCKPROF_query;
     set_xen_guest_handle(sysctl.u.lockprof_op.data, HYPERCALL_BUFFER_NULL);
 
Signature · 1 line
1.8.1.4
#1 lore raw
Quoted 6 lines · Boris Ostrovsky

If max_elem is not zero then hypervisor's spinlock_profile_ucopy_elem() will attempt to copy profile data into user's data buffer. Since this buffer is explicitly set to (the equivalent of) NULL the copy will fail, causing xenlockprof to fail as well.

I would have expected DECLARE_SYSCTL to zero the struct, but anyway:
Acked + applied, thanks (and sorry for the delay).