[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] xen: convert do_sysctl to use XSM


  • To: xen-changelog@xxxxxxxxxxxxxxxxxxx
  • From: Xen patchbot-unstable <patchbot@xxxxxxx>
  • Date: Wed, 16 Jan 2013 08:22:09 +0000
  • Delivery-date: Wed, 16 Jan 2013 08:22:55 +0000
  • List-id: "Change log for Mercurial \(receive only\)" <xen-changelog.lists.xen.org>

# HG changeset patch
# User Daniel De Graaf <dgdegra@xxxxxxxxxxxxx>
# Date 1357899021 0
# Node ID 6be26b7bda2f0c2cc86a8c68d0a302fffdeac7ae
# Parent  fd939d1a9b306b5e219fd1080eefdcd1c47cfcb0
xen: convert do_sysctl to use XSM

The xsm_sysctl hook now covers every sysctl, in addition to the more
fine-grained XSM hooks in most sub-functions.

Signed-off-by: Daniel De Graaf <dgdegra@xxxxxxxxxxxxx>
Committed-by: Keir Fraser <keir@xxxxxxx>
---


diff -r fd939d1a9b30 -r 6be26b7bda2f xen/common/sysctl.c
--- a/xen/common/sysctl.c       Fri Jan 11 10:09:45 2013 +0000
+++ b/xen/common/sysctl.c       Fri Jan 11 10:10:21 2013 +0000
@@ -34,15 +34,16 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xe
     struct xen_sysctl curop, *op = &curop;
     static DEFINE_SPINLOCK(sysctl_lock);
 
-    if ( !IS_PRIV(current->domain) )
-        return -EPERM;
-
     if ( copy_from_guest(op, u_sysctl, 1) )
         return -EFAULT;
 
     if ( op->interface_version != XEN_SYSCTL_INTERFACE_VERSION )
         return -EACCES;
 
+    ret = xsm_sysctl(op->cmd);
+    if ( ret )
+        return ret;
+
     /*
      * Trylock here avoids deadlock with an existing sysctl critical section
      * which might (for some current or future reason) want to synchronise
diff -r fd939d1a9b30 -r 6be26b7bda2f xen/include/xsm/dummy.h
--- a/xen/include/xsm/dummy.h   Fri Jan 11 10:09:45 2013 +0000
+++ b/xen/include/xsm/dummy.h   Fri Jan 11 10:10:21 2013 +0000
@@ -106,6 +106,13 @@ static XSM_INLINE int xsm_domctl(struct 
     return 0;
 }
 
+static XSM_INLINE int xsm_sysctl(int cmd)
+{
+    if ( !IS_PRIV(current->domain) )
+        return -EPERM;
+    return 0;
+}
+
 static XSM_INLINE int xsm_set_virq_handler(struct domain *d, uint32_t virq)
 {
     return 0;
diff -r fd939d1a9b30 -r 6be26b7bda2f xen/include/xsm/xsm.h
--- a/xen/include/xsm/xsm.h     Fri Jan 11 10:09:45 2013 +0000
+++ b/xen/include/xsm/xsm.h     Fri Jan 11 10:10:21 2013 +0000
@@ -58,6 +58,7 @@ struct xsm_operations {
     int (*domain_settime) (struct domain *d);
     int (*set_target) (struct domain *d, struct domain *e);
     int (*domctl) (struct domain *d, int cmd);
+    int (*sysctl) (int cmd);
     int (*set_virq_handler) (struct domain *d, uint32_t virq);
     int (*tbufcontrol) (void);
     int (*readconsole) (uint32_t clear);
@@ -266,6 +267,11 @@ static inline int xsm_domctl (struct dom
     return xsm_ops->domctl(d, cmd);
 }
 
+static inline int xsm_sysctl (int cmd)
+{
+    return xsm_ops->sysctl(cmd);
+}
+
 static inline int xsm_set_virq_handler (struct domain *d, uint32_t virq)
 {
     return xsm_ops->set_virq_handler(d, virq);
diff -r fd939d1a9b30 -r 6be26b7bda2f xen/xsm/dummy.c
--- a/xen/xsm/dummy.c   Fri Jan 11 10:09:45 2013 +0000
+++ b/xen/xsm/dummy.c   Fri Jan 11 10:10:21 2013 +0000
@@ -45,6 +45,7 @@ void xsm_fixup_ops (struct xsm_operation
     set_to_dummy_if_null(ops, domain_settime);
     set_to_dummy_if_null(ops, set_target);
     set_to_dummy_if_null(ops, domctl);
+    set_to_dummy_if_null(ops, sysctl);
     set_to_dummy_if_null(ops, set_virq_handler);
     set_to_dummy_if_null(ops, tbufcontrol);
     set_to_dummy_if_null(ops, readconsole);
diff -r fd939d1a9b30 -r 6be26b7bda2f xen/xsm/flask/hooks.c
--- a/xen/xsm/flask/hooks.c     Fri Jan 11 10:09:45 2013 +0000
+++ b/xen/xsm/flask/hooks.c     Fri Jan 11 10:10:21 2013 +0000
@@ -668,6 +668,38 @@ static int flask_domctl(struct domain *d
     }
 }
 
+static int flask_sysctl(int cmd)
+{
+    switch ( cmd )
+    {
+    /* These have individual XSM hooks */
+    case XEN_SYSCTL_readconsole:
+    case XEN_SYSCTL_tbuf_op:
+    case XEN_SYSCTL_sched_id:
+    case XEN_SYSCTL_perfc_op:
+    case XEN_SYSCTL_getdomaininfolist:
+    case XEN_SYSCTL_debug_keys:
+    case XEN_SYSCTL_getcpuinfo:
+    case XEN_SYSCTL_availheap:
+    case XEN_SYSCTL_get_pmstat:
+    case XEN_SYSCTL_pm_op:
+    case XEN_SYSCTL_page_offline_op:
+    case XEN_SYSCTL_lockprof_op:
+    case XEN_SYSCTL_cpupool_op:
+    case XEN_SYSCTL_scheduler_op:
+#ifdef CONFIG_X86
+    case XEN_SYSCTL_physinfo:
+    case XEN_SYSCTL_cpu_hotplug:
+    case XEN_SYSCTL_topologyinfo:
+    case XEN_SYSCTL_numainfo:
+#endif
+        return 0;
+    default:
+        printk("flask_sysctl: Unknown op %d\n", cmd);
+        return -EPERM;
+    }
+}
+
 static int flask_set_virq_handler(struct domain *d, uint32_t virq)
 {
     return domain_has_perm(current->domain, d, SECCLASS_DOMAIN, 
DOMAIN__SET_VIRQ_HANDLER);
@@ -1563,6 +1595,7 @@ static struct xsm_operations flask_ops =
     .domain_settime = flask_domain_settime,
     .set_target = flask_set_target,
     .domctl = flask_domctl,
+    .sysctl = flask_sysctl,
     .set_virq_handler = flask_set_virq_handler,
     .tbufcontrol = flask_tbufcontrol,
     .readconsole = flask_readconsole,

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.