]> xenbits.xensource.com Git - people/royger/linux-2.6.18-xen.git/commitdiff
xenbus: fix type inconsistency with xenbus_conn()
authorJan Beulich <jbeulich@novell.com>
Sat, 2 Apr 2011 14:54:29 +0000 (15:54 +0100)
committerJan Beulich <jbeulich@novell.com>
Sat, 2 Apr 2011 14:54:29 +0000 (15:54 +0100)
Its (bogus) declaration in xenbus_dev.c was inconsistent with the
actual implementation, leaving room for stack corruption on 64-bit
systems. Thus move the declaration to a header included by both
parties, and use proper types for the parameters.

Additionally, the function is needed on privileged kernels only, and
hence neither the potentially forward-incompatible HAVE_UNLOCKED_IOCTL
conditionals in xenbus_dev.c are needed, nor does the function (and
its helper) need to be compiled in unprivileged builds.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
drivers/xen/xenbus/xenbus_comms.h
drivers/xen/xenbus/xenbus_dev.c
drivers/xen/xenbus/xenbus_probe.c

index bbd36f7de4c258b0836dd45cb7d7f7a35671df97..dde49025705163469cbebb3c0742c3a979e3827c 100644 (file)
@@ -59,4 +59,11 @@ static inline int is_xenstored_ready(void)
        return s == XENBUS_XSD_FOREIGN_READY || s == XENBUS_XSD_LOCAL_READY;
 }
 
+#if defined(CONFIG_XEN_XENBUS_DEV) && defined(CONFIG_XEN_PRIVILEGED_GUEST)
+#include <xen/interface/event_channel.h>
+#include <xen/interface/grant_table.h>
+
+int xenbus_conn(domid_t, grant_ref_t *, evtchn_port_t *);
+#endif
+
 #endif /* _XENBUS_COMMS_H */
index f3721a78ba410f03cbf1401abc0f6441a205e3fd..508a785754b88e370f70524a244ca857f38765da 100644 (file)
@@ -395,12 +395,10 @@ static unsigned int xenbus_dev_poll(struct file *file, poll_table *wait)
        return 0;
 }
 
-#ifdef HAVE_UNLOCKED_IOCTL
+#ifdef CONFIG_XEN_PRIVILEGED_GUEST
 static long xenbus_dev_ioctl(struct file *file,
                              unsigned int cmd, unsigned long data)
 {
-       extern int xenbus_conn(domid_t remote_dom, int *grant_ref,
-                              evtchn_port_t *local_port);
        void __user *udata = (void __user *) data;
        int ret = -ENOTTY;
        
@@ -453,7 +451,7 @@ static const struct file_operations xenbus_dev_file_ops = {
        .open = xenbus_dev_open,
        .release = xenbus_dev_release,
        .poll = xenbus_dev_poll,
-#ifdef HAVE_UNLOCKED_IOCTL
+#ifdef CONFIG_XEN_PRIVILEGED_GUEST
        .unlocked_ioctl = xenbus_dev_ioctl
 #endif
 };
index 7c16968470d7be1ae2d2be751287ddafec578d22..0c0f68877882a2c579b9c276875284a14f69be9e 100644 (file)
@@ -871,7 +871,8 @@ void xenbus_probe(void *unused)
 }
 
 
-#if defined(CONFIG_PROC_FS) && defined(CONFIG_XEN_PRIVILEGED_GUEST)
+#ifdef CONFIG_XEN_PRIVILEGED_GUEST
+#ifdef CONFIG_PROC_FS
 static struct file_operations xsd_kva_fops;
 static struct proc_dir_entry *xsd_kva_intf;
 static struct proc_dir_entry *xsd_port_intf;
@@ -933,6 +934,7 @@ static int xsd_port_read(char *page, char **start, off_t off,
 }
 #endif
 
+#ifdef CONFIG_XEN_XENBUS_DEV
 static int xb_free_port(evtchn_port_t port)
 {
        struct evtchn_close close;
@@ -940,7 +942,8 @@ static int xb_free_port(evtchn_port_t port)
        return HYPERVISOR_event_channel_op(EVTCHNOP_close, &close);
 }
 
-int xenbus_conn(domid_t remote_dom, unsigned long *grant_ref, evtchn_port_t *local_port)
+int xenbus_conn(domid_t remote_dom, grant_ref_t *grant_ref,
+               evtchn_port_t *local_port)
 {
        struct evtchn_alloc_unbound alloc_unbound;
        int rc, rc2;
@@ -948,10 +951,8 @@ int xenbus_conn(domid_t remote_dom, unsigned long *grant_ref, evtchn_port_t *loc
        BUG_ON(atomic_read(&xenbus_xsd_state) != XENBUS_XSD_FOREIGN_INIT);
        BUG_ON(!is_initial_xendomain());
 
-#if defined(CONFIG_PROC_FS) && defined(CONFIG_XEN_PRIVILEGED_GUEST)
        remove_xen_proc_entry("xsd_kva");
        remove_xen_proc_entry("xsd_port");
-#endif
 
        rc = xb_free_port(xen_store_evtchn);
        if (rc != 0)
@@ -988,6 +989,8 @@ fail0:
        xen_store_evtchn = -1;
        return rc;
 }
+#endif
+#endif /* CONFIG_XEN_PRIVILEGED_GUEST */
 
 static int xenbus_probe_init(void)
 {