From: Daniel De Graaf <dgdegra@tycho.nsa.gov>
To: xen-devel@lists.xen.org
Cc: Daniel De Graaf <dgdegra@tycho.nsa.gov>, keir@xen.org
Subject: [PATCH 11/19] xen: convert do_sysctl to use XSM
Date: Fri, 16 Nov 2012 13:28:26 -0500 [thread overview]
Message-ID: <1353090514-18537-12-git-send-email-dgdegra@tycho.nsa.gov> (raw)
In-Reply-To: <1353090514-18537-1-git-send-email-dgdegra@tycho.nsa.gov>
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@tycho.nsa.gov>
---
xen/common/sysctl.c | 7 ++++---
xen/include/xsm/dummy.h | 7 +++++++
xen/include/xsm/xsm.h | 6 ++++++
xen/xsm/dummy.c | 1 +
xen/xsm/flask/hooks.c | 33 +++++++++++++++++++++++++++++++++
5 files changed, 51 insertions(+), 3 deletions(-)
diff --git a/xen/common/sysctl.c b/xen/common/sysctl.c
index 47142f4..599430e 100644
--- a/xen/common/sysctl.c
+++ b/xen/common/sysctl.c
@@ -33,15 +33,16 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl)
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 --git a/xen/include/xsm/dummy.h b/xen/include/xsm/dummy.h
index f5fe89f..073217a 100644
--- a/xen/include/xsm/dummy.h
+++ b/xen/include/xsm/dummy.h
@@ -106,6 +106,13 @@ static XSM_DEFAULT(int, domctl)(struct domain *d, int cmd)
return 0;
}
+static XSM_DEFAULT(int, sysctl)(int cmd)
+{
+ if ( !IS_PRIV(current->domain) )
+ return -EPERM;
+ return 0;
+}
+
static XSM_DEFAULT(int, set_virq_handler)(struct domain *d, uint32_t virq)
{
return 0;
diff --git a/xen/include/xsm/xsm.h b/xen/include/xsm/xsm.h
index a0c97cb..4900d1f 100644
--- a/xen/include/xsm/xsm.h
+++ b/xen/include/xsm/xsm.h
@@ -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);
@@ -265,6 +266,11 @@ static inline int xsm_domctl (struct domain *d, int cmd)
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 --git a/xen/xsm/dummy.c b/xen/xsm/dummy.c
index 10f9c47..43e8617 100644
--- a/xen/xsm/dummy.c
+++ b/xen/xsm/dummy.c
@@ -44,6 +44,7 @@ void xsm_fixup_ops (struct xsm_operations *ops)
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 --git a/xen/xsm/flask/hooks.c b/xen/xsm/flask/hooks.c
index 2e002f0..e25dd1c 100644
--- a/xen/xsm/flask/hooks.c
+++ b/xen/xsm/flask/hooks.c
@@ -675,6 +675,38 @@ static int flask_domctl(struct domain *d, int cmd)
}
}
+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);
@@ -1601,6 +1633,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,
--
1.7.11.7
next prev parent reply other threads:[~2012-11-16 18:28 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-16 18:28 [PATCH v5] Merge IS_PRIV checks into XSM hooks Daniel De Graaf
2012-11-16 18:28 ` [PATCH 01/19] libxl: introduce XSM relabel on build Daniel De Graaf
2012-11-19 10:42 ` Ian Campbell
2012-11-20 16:38 ` Daniel De Graaf
2012-11-16 18:28 ` [PATCH 02/19] flask/policy: Add domain relabel example Daniel De Graaf
2012-11-19 10:46 ` Ian Campbell
2012-11-20 17:26 ` Daniel De Graaf
2012-11-16 18:28 ` [PATCH 03/19] arch/x86: add distinct XSM hooks for map/unmap Daniel De Graaf
2012-11-19 8:59 ` Jan Beulich
2012-11-19 14:53 ` Daniel De Graaf
2012-11-20 16:39 ` Jan Beulich
2012-11-16 18:28 ` [PATCH 04/19] xsm/flask: Add checks on the domain performing the set_target operation Daniel De Graaf
2012-11-16 18:28 ` [PATCH 05/19] xsm: Use the dummy XSM module if XSM is disabled Daniel De Graaf
2012-11-16 18:28 ` [PATCH 06/19] xen: use XSM instead of IS_PRIV where duplicated Daniel De Graaf
2012-11-19 9:08 ` Jan Beulich
2012-11-19 14:59 ` Daniel De Graaf
2012-11-19 15:43 ` Jan Beulich
2012-11-19 11:00 ` Ian Campbell
2012-11-19 15:16 ` Daniel De Graaf
2012-11-16 18:28 ` [PATCH 07/19] xen: avoid calling rcu_lock_*target_domain when an XSM hook exists Daniel De Graaf
2012-11-16 18:28 ` [PATCH 08/19] arch/x86: convert platform_hypercall to use XSM Daniel De Graaf
2012-11-16 18:28 ` [PATCH 09/19] xen: lock target domain in do_domctl common code Daniel De Graaf
2012-11-19 9:24 ` Jan Beulich
2012-11-19 15:20 ` Daniel De Graaf
2012-11-20 16:40 ` Jan Beulich
2012-11-20 16:44 ` Daniel De Graaf
2012-11-20 16:53 ` Jan Beulich
2012-11-16 18:28 ` [PATCH 10/19] xen: convert do_domctl to use XSM Daniel De Graaf
2012-11-16 18:28 ` Daniel De Graaf [this message]
2012-11-16 18:28 ` [PATCH 12/19] xsm/flask: add missing hooks Daniel De Graaf
2012-11-16 18:28 ` [PATCH 13/19] xsm/flask: add distinct SIDs for self/target access Daniel De Graaf
2012-11-16 18:28 ` [PATCH 14/19] arch/x86: Add missing mem_sharing XSM hooks Daniel De Graaf
2012-11-16 18:28 ` [PATCH 15/19] arch/x86: use XSM hooks for get_pg_owner access checks Daniel De Graaf
2012-11-16 18:28 ` [PATCH 16/19] xen: Add XSM hook for XENMEM_exchange Daniel De Graaf
2012-11-16 18:28 ` [PATCH 17/19] tmem: add XSM hooks Daniel De Graaf
2012-11-16 18:28 ` [PATCH 18/19] xen/arch/*: add struct domain parameter to arch_do_domctl Daniel De Graaf
2012-11-16 18:28 ` [PATCH 19/19] flask: move policy headers into hypervisor Daniel De Graaf
2012-11-19 9:45 ` [PATCH v5] Merge IS_PRIV checks into XSM hooks Jan Beulich
2012-11-19 10:26 ` Tim Deegan
2012-11-19 15:49 ` Daniel De Graaf
2012-11-19 21:28 ` [PATCH RFC 0/5] XSM hook renames and cleanup Daniel De Graaf
2012-11-19 21:28 ` [PATCH 1/5] Remove XSM_DEFAULT macro Daniel De Graaf
2012-11-19 21:28 ` [PATCH 2/5] xen: domctl XSM hook removal Daniel De Graaf
2012-11-19 21:28 ` [PATCH 3/5] xen: sysctl " Daniel De Graaf
2012-11-19 21:28 ` [PATCH 4/5] xen: platform_hypercall " Daniel De Graaf
2012-11-19 21:28 ` [PATCH RFC 5/5] xen/xsm: include default hook action in name Daniel De Graaf
2012-11-20 8:07 ` [PATCH RFC 0/5] XSM hook renames and cleanup Jan Beulich
2012-11-20 14:51 ` Daniel De Graaf
2012-11-20 14:51 ` [PATCH 1/5] Remove XSM_DEFAULT macro Daniel De Graaf
2012-11-20 14:51 ` [PATCH 2/5] xen: domctl XSM hook removal Daniel De Graaf
2012-11-20 15:15 ` Jan Beulich
2012-11-20 14:51 ` [PATCH 3/5] xen: sysctl " Daniel De Graaf
2012-11-20 15:25 ` Jan Beulich
2012-11-20 15:34 ` Daniel De Graaf
2012-11-20 14:51 ` [PATCH 4/5] xen: platform_hypercall " Daniel De Graaf
2012-11-20 14:51 ` [PATCH RFC 5/5] xen/xsm: include default hook action in name Daniel De Graaf
2012-11-22 16:57 ` Tim Deegan
2012-11-23 16:42 ` Daniel De Graaf
2012-11-27 14:49 ` Tim Deegan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1353090514-18537-12-git-send-email-dgdegra@tycho.nsa.gov \
--to=dgdegra@tycho.nsa.gov \
--cc=keir@xen.org \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).