[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH RFCv3 8/8] xsm: add XEN_DOMCTL_set_recipient support
Signed-off-by: Vitaly Kuznetsov <vkuznets@xxxxxxxxxx> --- xen/common/domctl.c | 14 +++++++++++--- xen/include/xsm/dummy.h | 6 ++++++ xen/include/xsm/xsm.h | 6 ++++++ xen/xsm/dummy.c | 1 + xen/xsm/flask/hooks.c | 17 +++++++++++++++++ xen/xsm/flask/policy/access_vectors | 10 ++++++++++ 6 files changed, 51 insertions(+), 3 deletions(-) diff --git a/xen/common/domctl.c b/xen/common/domctl.c index 38cd10a..b456ff2 100644 --- a/xen/common/domctl.c +++ b/xen/common/domctl.c @@ -1158,6 +1158,10 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl) if ( op->u.recipient.recipient == DOMID_INVALID ) { + ret = xsm_set_recipient(XSM_HOOK, d, NULL); + if ( ret ) + break; + if ( d->recipient ) { put_domain(d->recipient); @@ -1172,10 +1176,14 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl) ret = -ESRCH; break; } - else - { - d->recipient = recipient_dom; + + ret = xsm_set_recipient(XSM_HOOK, d, recipient_dom); + if ( ret ) { + put_domain(recipient_dom); + break; } + + d->recipient = recipient_dom; } break; diff --git a/xen/include/xsm/dummy.h b/xen/include/xsm/dummy.h index df55e70..c037b78 100644 --- a/xen/include/xsm/dummy.h +++ b/xen/include/xsm/dummy.h @@ -113,6 +113,12 @@ static XSM_INLINE int xsm_set_target(XSM_DEFAULT_ARG struct domain *d, struct do return xsm_default_action(action, current->domain, NULL); } +static XSM_INLINE int xsm_set_recipient(XSM_DEFAULT_ARG struct domain *d, struct domain *e) +{ + XSM_ASSERT_ACTION(XSM_HOOK); + return xsm_default_action(action, current->domain, NULL); +} + static XSM_INLINE int xsm_domctl(XSM_DEFAULT_ARG struct domain *d, int cmd) { XSM_ASSERT_ACTION(XSM_OTHER); diff --git a/xen/include/xsm/xsm.h b/xen/include/xsm/xsm.h index 6c1c079..818654d 100644 --- a/xen/include/xsm/xsm.h +++ b/xen/include/xsm/xsm.h @@ -58,6 +58,7 @@ struct xsm_operations { int (*domctl_scheduler_op) (struct domain *d, int op); int (*sysctl_scheduler_op) (int op); int (*set_target) (struct domain *d, struct domain *e); + int (*set_recipient) (struct domain *d, struct domain *e); int (*domctl) (struct domain *d, int cmd); int (*sysctl) (int cmd); int (*readconsole) (uint32_t clear); @@ -210,6 +211,11 @@ static inline int xsm_set_target (xsm_default_t def, struct domain *d, struct do return xsm_ops->set_target(d, e); } +static inline int xsm_set_recipient (xsm_default_t def, struct domain *d, struct domain *r) +{ + return xsm_ops->set_recipient(d, r); +} + static inline int xsm_domctl (xsm_default_t def, struct domain *d, int cmd) { return xsm_ops->domctl(d, cmd); diff --git a/xen/xsm/dummy.c b/xen/xsm/dummy.c index 0826a8b..e38d9c6 100644 --- a/xen/xsm/dummy.c +++ b/xen/xsm/dummy.c @@ -35,6 +35,7 @@ void xsm_fixup_ops (struct xsm_operations *ops) set_to_dummy_if_null(ops, domctl_scheduler_op); set_to_dummy_if_null(ops, sysctl_scheduler_op); set_to_dummy_if_null(ops, set_target); + set_to_dummy_if_null(ops, set_recipient); set_to_dummy_if_null(ops, domctl); set_to_dummy_if_null(ops, sysctl); set_to_dummy_if_null(ops, readconsole); diff --git a/xen/xsm/flask/hooks.c b/xen/xsm/flask/hooks.c index df05566..ae16795 100644 --- a/xen/xsm/flask/hooks.c +++ b/xen/xsm/flask/hooks.c @@ -565,6 +565,21 @@ static int flask_set_target(struct domain *d, struct domain *t) return rc; } +static int flask_set_recipient(struct domain *d, struct domain *r) +{ + int rc; + struct domain_security_struct *dsec, *rsec; + dsec = d->ssid; + rsec = r->ssid; + + rc = current_has_perm(d, SECCLASS_DOMAIN2, DOMAIN2__SET_AS_SOURCE); + if ( rc ) + return rc; + if ( r ) + rc = current_has_perm(r, SECCLASS_DOMAIN2, DOMAIN2__SET_AS_RECIPIENT); + return rc; +} + static int flask_domctl(struct domain *d, int cmd) { switch ( cmd ) @@ -577,6 +592,7 @@ static int flask_domctl(struct domain *d, int cmd) case XEN_DOMCTL_iomem_permission: case XEN_DOMCTL_memory_mapping: case XEN_DOMCTL_set_target: + case XEN_DOMCTL_set_recipient: #ifdef CONFIG_X86 /* These have individual XSM hooks (arch/x86/domctl.c) */ case XEN_DOMCTL_shadow_op: @@ -1493,6 +1509,7 @@ static struct xsm_operations flask_ops = { .domctl_scheduler_op = flask_domctl_scheduler_op, .sysctl_scheduler_op = flask_sysctl_scheduler_op, .set_target = flask_set_target, + .set_recipient = flask_set_recipient, .domctl = flask_domctl, .sysctl = flask_sysctl, .readconsole = flask_readconsole, diff --git a/xen/xsm/flask/policy/access_vectors b/xen/xsm/flask/policy/access_vectors index d279841..5604281 100644 --- a/xen/xsm/flask/policy/access_vectors +++ b/xen/xsm/flask/policy/access_vectors @@ -132,6 +132,8 @@ class domain # target = the new target domain # see also the domain2 make_priv_for and set_as_target checks set_target +# XEN_DOMCTL_set_recipient + set_recipient # SCHEDOP_remote_shutdown shutdown # XEN_DOMCTL_set{,_machine}_address_size @@ -184,6 +186,14 @@ class domain2 # source = the domain making the hypercall # target = the new target domain set_as_target +# checked in XEN_DOMCTL_set_recipient: +# source = the domain making the hypercall +# target = the new source domain + set_as_source +# checked in XEN_DOMCTL_set_recipient: +# source = the domain making the hypercall +# target = the new recipient domain + set_as_recipient # XEN_DOMCTL_set_cpuid set_cpuid # XEN_DOMCTL_gettscinfo -- 1.9.3 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |