Skip to content

Commit 09ddebd

Browse files
dozylynxandyhhp
authored andcommitted
xsm, argo: XSM control for any access to argo by a domain
Will inhibit initialization of the domain's argo data structure to prevent receiving any messages or notifications and access to any of the argo hypercall operations. Signed-off-by: Christopher Clark <[email protected]> Acked-by: Daniel De Graaf <[email protected]> v3 Daniel/Jan: add to the default xsm policy for enable v3 Add Daniel's Acked-by v3 xen-project#4 Jason/Roger: soft_reset: can assume reinit is ok if d->argo set v2 self: fix xsm use in soft-reset prior to introduction v1 xen-project#5 (#17) feedback Paul: XSM control for any access: use currd v1 #16 feedback Jan: apply const to function signatures
1 parent 6da973f commit 09ddebd

File tree

7 files changed

+30
-7
lines changed

7 files changed

+30
-7
lines changed

tools/flask/policy/modules/guest_features.te

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ allow domain_type xen_t:xen tmem_op;
55
# pmu_ctrl is for)
66
allow domain_type xen_t:xen2 pmu_use;
77

8-
# Allow all domains:
8+
# Allow all domains to enable the Argo interdomain communication hypercall;
99
# to register single-sender (unicast) rings to partner with any domain;
1010
# to register any-sender (wildcard) rings that can be sent to by any domain;
1111
# and send messages to rings.
12-
allow domain_type xen_t:argo { register_any_source };
12+
allow domain_type xen_t:argo { enable register_any_source };
1313
allow domain_type domain_type:argo { send register_single_source };
1414

1515
# Allow guest console output to the serial console. This is used by PV Linux

xen/common/argo.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2005,7 +2005,7 @@ do_argo_op(unsigned int cmd, XEN_GUEST_HANDLE_PARAM(void) arg1,
20052005
argo_dprintk("->do_argo_op(%u,%p,%p,%lu,0x%lx)\n", cmd,
20062006
(void *)arg1.p, (void *)arg2.p, arg3, arg4);
20072007

2008-
if ( unlikely(!opt_argo_enabled) )
2008+
if ( unlikely(!opt_argo_enabled || xsm_argo_enable(currd)) )
20092009
return -EOPNOTSUPP;
20102010

20112011
switch (cmd)
@@ -2152,7 +2152,7 @@ argo_init(struct domain *d)
21522152
{
21532153
struct argo_domain *argo;
21542154

2155-
if ( !opt_argo_enabled )
2155+
if ( !opt_argo_enabled || xsm_argo_enable(d) )
21562156
{
21572157
argo_dprintk("argo disabled, domid: %u\n", d->domain_id);
21582158
return 0;
@@ -2208,9 +2208,10 @@ argo_soft_reset(struct domain *d)
22082208
wildcard_rings_pending_remove(d);
22092209

22102210
/*
2211-
* Since opt_argo_enabled cannot change at runtime, if d->argo is true
2212-
* then opt_argo_enabled must be true, and we can assume that init
2213-
* is allowed to proceed again here.
2211+
* Since neither opt_argo_enabled or xsm_argo_enable(d) can change at
2212+
* runtime, if d->argo is true then both opt_argo_enabled and
2213+
* xsm_argo_enable(d) must be true, and we can assume that init is
2214+
* allowed to proceed again here.
22142215
*/
22152216
argo_domain_init(d->argo);
22162217
}

xen/include/xsm/dummy.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,11 @@ static XSM_INLINE int xsm_dm_op(XSM_DEFAULT_ARG struct domain *d)
721721
#endif /* CONFIG_X86 */
722722

723723
#ifdef CONFIG_ARGO
724+
static XSM_INLINE int xsm_argo_enable(struct domain *d)
725+
{
726+
return 0;
727+
}
728+
724729
static XSM_INLINE int xsm_argo_register_single_source(struct domain *d,
725730
struct domain *t)
726731
{

xen/include/xsm/xsm.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ struct xsm_operations {
182182
int (*xen_version) (uint32_t cmd);
183183
int (*domain_resource_map) (struct domain *d);
184184
#ifdef CONFIG_ARGO
185+
int (*argo_enable) (const struct domain *d);
185186
int (*argo_register_single_source) (const struct domain *d,
186187
const struct domain *t);
187188
int (*argo_register_any_source) (const struct domain *d);
@@ -705,6 +706,11 @@ static inline int xsm_domain_resource_map(xsm_default_t def, struct domain *d)
705706
}
706707

707708
#ifdef CONFIG_ARGO
709+
static inline xsm_argo_enable(const struct domain *d)
710+
{
711+
return xsm_ops->argo_enable(d);
712+
}
713+
708714
static inline xsm_argo_register_single_source(const struct domain *d,
709715
const struct domain *t)
710716
{

xen/xsm/dummy.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ void __init xsm_fixup_ops (struct xsm_operations *ops)
153153
set_to_dummy_if_null(ops, xen_version);
154154
set_to_dummy_if_null(ops, domain_resource_map);
155155
#ifdef CONFIG_ARGO
156+
set_to_dummy_if_null(ops, argo_enable);
156157
set_to_dummy_if_null(ops, argo_register_single_source);
157158
set_to_dummy_if_null(ops, argo_register_any_source);
158159
set_to_dummy_if_null(ops, argo_send);

xen/xsm/flask/hooks.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1720,6 +1720,12 @@ static int flask_domain_resource_map(struct domain *d)
17201720
}
17211721

17221722
#ifdef CONFIG_ARGO
1723+
static int flask_argo_enable(const struct domain *d)
1724+
{
1725+
return avc_has_perm(domain_sid(d), SECINITSID_XEN, SECCLASS_ARGO,
1726+
ARGO__ENABLE, NULL);
1727+
}
1728+
17231729
static int flask_argo_register_single_source(const struct domain *d,
17241730
const struct domain *t)
17251731
{
@@ -1875,6 +1881,7 @@ static struct xsm_operations flask_ops = {
18751881
.xen_version = flask_xen_version,
18761882
.domain_resource_map = flask_domain_resource_map,
18771883
#ifdef CONFIG_ARGO
1884+
.argo_enable = flask_argo_enable,
18781885
.argo_register_single_source = flask_argo_register_single_source,
18791886
.argo_register_any_source = flask_argo_register_any_source,
18801887
.argo_send = flask_argo_send,

xen/xsm/flask/policy/access_vectors

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,9 @@ class version
535535
# Class argo is used to describe the Argo interdomain communication system.
536536
class argo
537537
{
538+
# Enable initialization of a domain's argo subsystem and
539+
# permission to access the argo hypercall operations.
540+
enable
538541
# Domain requesting registration of a communication ring
539542
# to receive messages from a specific other domain.
540543
register_single_source

0 commit comments

Comments
 (0)