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-devel

[Xen-devel] [PATCH] linux-2.6.18: fix type inconsistency with xenbus_con

To: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] linux-2.6.18: fix type inconsistency with xenbus_conn()
From: "Jan Beulich" <JBeulich@xxxxxxxxxx>
Date: Fri, 01 Apr 2011 11:56:02 +0100
Delivery-date: Fri, 01 Apr 2011 03:55:46 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
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@xxxxxxxxxx>

--- a/drivers/xen/xenbus/xenbus_comms.h
+++ b/drivers/xen/xenbus/xenbus_comms.h
@@ -59,4 +59,11 @@ static inline int is_xenstored_ready(voi
        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 */
--- a/drivers/xen/xenbus/xenbus_dev.c
+++ b/drivers/xen/xenbus/xenbus_dev.c
@@ -395,12 +395,10 @@ static unsigned int xenbus_dev_poll(stru
        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 xenb
        .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
 };
--- a/drivers/xen/xenbus/xenbus_probe.c
+++ b/drivers/xen/xenbus/xenbus_probe.c
@@ -887,7 +887,8 @@ void xenbus_probe(struct work_struct *un
 }
 
 
-#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;
@@ -949,6 +950,7 @@ static int xsd_port_read(char *page, cha
 }
 #endif
 
+#ifdef CONFIG_XEN_XENBUS_DEV
 static int xb_free_port(evtchn_port_t port)
 {
        struct evtchn_close close;
@@ -956,7 +958,8 @@ static int xb_free_port(evtchn_port_t po
        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;
@@ -964,10 +967,8 @@ int xenbus_conn(domid_t remote_dom, unsi
        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)
@@ -1004,6 +1005,8 @@ fail0:
        xen_store_evtchn = -1;
        return rc;
 }
+#endif
+#endif /* CONFIG_XEN_PRIVILEGED_GUEST */
 
 static int xenbus_probe_init(void)
 {



Attachment: xen-xenbus_conn-type.patch
Description: Text document

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] linux-2.6.18: fix type inconsistency with xenbus_conn(), Jan Beulich <=