Skip to contentSkip to conversation

sHype access control architecture for Xen

PATCH In review Reiner Sailer 8 participants 11 messages Jun 20, 2005 – Jun 21, 2005 Arm/actions semi architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sHype access control architecture for Xen

This E-mail contains the sHype access control architecture for inclusion into the Xen hypervisor (xeno-unstable.bk). This is a follow-up on earlier postings:
http://lists.xensource.com/archives/html/xen-devel/2005-04/msg00864.html

The *_xen.diff patch includes the core sHype access control architecture. Default is the NULL-policy.

The *_tools.diff patch includes the necessary additions to the tools directory:
a) adding support for an additional VM configuration paramter
b) adding basic policy management support into tools/policy

The default setting is the NULL policy. After patching in the diff- files, you should see no change in behavior. Please refer to the attached shype4xen_readme.txt file for instructions on how to activate and experiment with sHype.

While we have added support for saving and restoring security information when saving and restoring domains, the architecture currently supports save/restore only on the same hypervisor system running the same sHype policy. Future versions will include more flexible support for save/restore/migration.

Our group will submit a java-based policy translation tool for sHype to this mailing list today as well. This tool takes as input an XML-based descriptions of user-defined sHype policies and translates them into a binary policy format that can be loaded into sHype.

Thanks
Reiner

Signed-off by: Reiner Sailer <[email protected]>
Signed-off by: Stefan Berger <[email protected]>

Copyright: IBM Corporation (C)
20 June 2005
Author: Reiner Sailer

This document is a very short introduction into the sHype access control security architecture implementation and how it is perceived by users. It is a very preliminary draft for the courageous ones to get "their feet wet" and to be able to give feedback (via the xen-devel/xense-devel mailing lists).

Install:

cd into xeno-unstable.bk
(use --dry-run option if you want to test the patch only) patch -p1 -g0 < *tools.diff
patch -p1 -g0 < *xen.diff

(no rejects, probably some line offsets)

make uninstall; make mrproper; make; ./install.sh should install the default sHype into Xen (rebuild your initrd images if necessary). Reboot.

Debug output: there are two triggers for debug output:
a) General sHype debug:
xeno-unstable.bk/xen/include/public/acm.h undefine ACM_DEBUG to switch this debug off

b) sHype enforcement hook trace: This prints a small trace for each enforcement hook that is executed. The trigger is in xeno-unstable.bk/xen/include/acm/acm_hooks.h
undefine ACM_TRACE_MODE to switch this debug off

1. The default NULL policy
***************************
When you apply the patches and startup xen, you should at first not notice any difference because the default policy is the "NULL" policy, which as the name implies does not enforce anything.

However, when you try

[root@laptop policy]# xm list
Name Id Mem(MB) CPU State Time(s) Console SSID-REF
Domain-0 0 620 0 r---- 25.6 default

You might detect a new parameter "SSID-REF" displayed for domains. This parameter describes the subject security identifier reference of the domain. It is shown as "default" since there is no policy to be enforced.

To display the currently enforced policy, use the policy tool under xeno- unstable.bk/tools/policy: policy_tool getpolicy. You should see output like the one below.

[root@laptop policy]#./policy_tool getpolicy

Policy dump:
============

Magic     = 1debc.
PolVer    = aaaa0000.
Len       = 14.
Primary   = NULL policy (c=0, off=14).

Secondary = NULL policy (c=0, off=14).
No primary policy (NULL).
No secondary policy (NULL).

Policy dump End.

Since this is a dump of a binary policy, it's not pretty. The important parts are the "Primary" and "Secondary" policy fields set to "NULL policy". sHype currently allows to set two independent policies; thus the two SSID-REF parts shown in 'xm list'. Right here: primary policy only means this policy is checked first, the secondary policy is checked if the primary results in "permitted access". The result of the combined policy is "permitted" if both policies return permitted (NULL policy always returns permitted). The result is "denied" if at least one of the policies returns "denied". Look into xeno- unstable.bk/xen/include/acm/acm_hooks.h for the general hook structure integrating the policy decisions (if you like, you won't need it for the rest of the Readme file).

2. Setting Chinese Wall and Simple Type Enforcement policies:
*************************************************************

We'll get fast to the point. However, in order to understand what we are doing, we must at least understand the purpose of the policies that we are going to enforce. The two policies presented here are just examples and the implementation encourages adding new policies easily.

2.1. Chinese Wall policy: "decides whether a domain can be started based on this domain's ssidref and the ssidrefs of the currently running domains". Generally, the Chinese wall policy allows specifying certain types (or classes or categories, whatever the preferred word) that conflict; we usually assign a type to a workload and the set of types of those workloads running in a domain make up the type set for this domain. Each domain is assigned a set of types through its SSID-REF (we register Chinese Wall as primary policy, so the ssidref used for determining the Chinese Wall types is the one annotated with "p:" in xm list) since each SSID-REF points at a set of types. We'll see how SSIDREFs are represented in Xen later when we will look at the policy. (A good read for Chinese Wall is: Brewer/Nash The Chinese Wall Security Policy 1989.)

So let's assume the Chinese Wall policy we are running distinguishes 10 types:
t0 ... t9. Let us assume further that each SSID-REF points to a set that includes exactly one type (attached to domains that run workloads of a single type). SSID-REF 0 points to {t0}, ssidref 1 points to {t1} ... 9 points to {t9}. [This is actually the example policy we are going to push into xen later]

Now the Chinese Wall policy allows you to define "Conflict type sets" and it guarantees that of any conflict set at most one type is "running" at any time. As an example, we have defined 2 conflict set: {t2, t3} and {t0, t5, t6}. Specifying these conflict sets, sHype ensures that at most one type of each set is running (either t2 or t3 but not both; either t0 or t5 or t6 but not multiple of them).

The effect is that administrators can define which workload types cannot run simultaneously on a single Xen system. This is useful to limit the covert timing channels between such payloads or to ensure that payloads don't interfere with each other through existing resource dependencies.

2.2. Simple Type Enforcement (ste) policy: "decides whether two domains can share data, e.g., setup event channels or grant tables to each other, based on the two domains' ssidref. This, as the name says, is a simple policy. Think of each type as of a single color. Each domain has one or more colors, i.e., the domains ssid for the ste policy points to a set that has set one or multiple types. Let us assume in our example policy we differentiate 5 colors (types) and define 5 different ssids referenced by ssidref=0..4. Each ssid shall have exactly one type set, i.e., describes a uni-color. Only ssid(0) has all types set, i.e., has all defined colors.

Sharing is enforced by the ste policy by requiring that two domains that want to establish an event channel or grant pages to each other must have a common color. Currently all domains communicate through DOM0 by default; i.e., Domain0 will necessarily have all colors to be able to create domains (thus, we will assign ssidref(0) to Domain0 in our example below.

More complex mandatory access control policies governing sharing will follow; such policies are more sophisticated than the "color" scheme above by allowing more flexible (and complex :_) access control decisions than "share a color" or "don't share a color" and will be able to express finer-grained policies.

2.3 Binary Policy:
In the future, we will have a policy tool that takes as input a more humane policy description, using types such as development, home-banking, donated- Grid, CorpA-Payload ... and translates the respective policy into what we see today as the binary policy using 1s and 0s and sets of them. For now, we must live with the binary policy when working with sHype.

2.4 Exemplary use of a real sHype policy on Xen. To activate a real policy, edit the file (yes, this will soon be a compile option):
xeno-unstable.bk/xen/include/public/acm.h
Change: #define ACM_USE_SECURITY_POLICY ACM_NULL_POLICY
To : #define ACM_USE_SECURITY_POLICY ACM_CHINESE_WALL_AND_SIMPLE_TYPE_ENFORCEMENT_POLICY cd xeno-unstable.bk
make mrproper
make uninstall (manually remove /etc/xen.old if necessary)
make
./install.sh (recreate your kernel initrd's if necessary)
Reboot into new xen.gz

After booting, check out 'xm dmesg'; should show somewhere in the middle:

(XEN) acm_init: Enforcing Primary CHINESE WALL policy, Secondary SIMPLE TYPE ENFORCEMENT policy.

Even though you can activate those policies in any combination and also independently, the policy tool currently only supports setting the policy for the above combination.

Now look at the minimal startup policy with:
xeno-unstable.bk/tools/policytool getpolicy

You should see something like:

[root@laptop policy]# ./policy_tool getpolicy

Policy dump:
============

Magic     = 1debc.
PolVer    = aaaa0000.
Len       = 36.
Primary   = CHINESE WALL policy (c=1, off=14).

Secondary = SIMPLE TYPE ENFORCEMENT policy (c=2, off=2c).

Chinese Wall policy:
====================

Max Types     = 1.
Max Ssidrefs  = 1.
Max ConfSets  = 1.
Ssidrefs Off  = 10.

Conflicts Off = 12.
Runing T. Off = 14.
C. Agg. Off = 16.

SSID To CHWALL-Type matrix:

ssidref 0: 00

Confict Sets:

c-set 0: 00

Running
Types: 00

Conflict
Aggregate Set: 00

Simple Type Enforcement policy:
===============================

Max Types     = 1.
Max Ssidrefs  = 1.
Ssidrefs Off  = 8.

SSID To STE-Type matrix:

ssidref 0: 01

Policy dump End.

This is a minimal policy (of little use), except it will disable starting any domain that does not have ssidref set to 0x0. The Chinese Wall policy has nothing to enforce and the ste policy only knows one type, which is set for the only defined ssidref.

The item that defines the ssidref in a domain configuration is:

ssidref = 0x12345678

Where ssidref is interpreted as a 32bit number, where the lower 16bits become the ssidref for the primary policy and the higher 16bits become the ssidref for the secondary policy. sHype currently supports two policies but this is an implementation decision and can be extended if necessary.

This reference defines the security information of a domain. The meaning of the SSID-REF depends on the policy, so we explain it when we explain the real policies.

Setting a new Security Policy:
******************************
The policy tool with all its current limitations has one usable example policy compiled-in. Please try at this time to use the setpolicy command:
xeno-unstable.bk/tools/policy/policy_tool setpolicy

You should see a dump of the policy you are setting. It should say at the very end:

Policy successfully set.

Now try to dump the currently enforced policy, which is the policy we have just set and the dynamic security state information of this policy
(<<< ... some additional explanations)

[root@laptop policy]# ./policy_tool getpolicy

Policy dump:
============

Magic     = 1debc.
PolVer    = aaaa0000.
Len       = 112.
Primary   = CHINESE WALL policy (c=1, off=14).

Secondary = SIMPLE TYPE ENFORCEMENT policy (c=2, off=d8).

Chinese Wall policy:
====================

Max Types     = a.
Max Ssidrefs  = 5.
Max ConfSets  = 2.
Ssidrefs Off  = 10.

Conflicts Off = 74.
Runing T. Off = 9c.
C. Agg. Off = b0.

SSID To CHWALL-Type matrix:

   ssidref 0:  01 00 00 00 00 00 00 00 00 00  <<< type0 is set for ssidref0
   ssidref 1:  00 01 00 00 00 00 00 00 00 00 
   ssidref 2:  00 00 01 00 00 00 00 00 00 00 
   ssidref 3:  00 00 00 01 00 00 00 00 00 00 
   ssidref 4:  00 00 00 00 01 00 00 00 00 00  <<< type4 is set for ssidref4

<<< types 5-9 are unused
Confict Sets:

   c-set 0:    00 00 01 01 00 00 00 00 00 00  <<< type2 and type3 never run together
   c-set 1:    01 00 00 00 00 01 01 00 00 00  <<< only one of types 0, 5 or 6 

<<< can run simultaneously
Running
Types: 01 00 00 00 00 00 00 00 00 00 <<< ref-count for types of running domains

Conflict
Aggregate Set: 00 00 00 00 00 01 01 00 00 00 <<< aggregated set of types that
<<< cannot run because they <<< are in conflict set 1 and <<< (domain 0 is running w t0)

Simple Type Enforcement policy:
===============================

Max Types     = 5.
Max Ssidrefs  = 5.
Ssidrefs Off  = 8.

SSID To STE-Type matrix:

ssidref 0: 01 01 01 01 01 <<< ssidref0 points to a set that
<<< has all types set (colors)
ssidref 1: 00 01 00 00 00 <<< ssidref1 has color1 set
ssidref 2: 00 00 01 00 00 <<< ...
ssidref 3: 00 00 00 01 00
ssidref 4: 00 00 00 00 01

Policy dump End.

This is a small example policy with which we will demonstrate the enforcement.

Starting Domains with policy enforcement
========================================
Now let us play with this policy.

Define 3 or 4 domain configurations. I use the following config using a ramdisk only and about 8MBytes of memory for each DomU (test purposes):

#-------configuration xmsec1------------------------- kernel = "/boot/vmlinuz-2.6.11-xenU" ramdisk="/boot/U1_ramdisk.img"
#security reference identifier
ssidref= 0x00010001
memory = 10
name = "xmsec1"
cpu = -1 # leave to Xen to pick
# Number of network interfaces. Default is 1. nics=1
dhcp="dhcp"
#-----------------------------------------------------

xmsec2 and xmsec3 look the same except for the name and the ssidref line. Use your domain config file and add "ssidref = 0x00010001" to the first (xmsec1), "ssidref= 0x00020002" to the second (call it xmsec2), and "ssidref=0x00030003" to the third (we will call this one xmsec3).

First start xmsec1: xm create -c xmsec1 (succeeds)

Then
[root@laptop policy]# xm list

Name              Id  Mem(MB)  CPU  State  Time(s)  Console  SSID-REF
Domain-0           0      620   0  r----     42.3            s:00/p:00
xmnosec            1        9   0  -b---      0.3    9601    s:00/p:05
xmsec1             2        9   0  -b---      0.2    9602    s:01/p:01

Shows a new domain xmsec1 running with primary (here: chinese wall) ssidref 1 and secondary (here: simple type enforcement) ssidref 1. The ssidrefs are independent and can differ for a domain.

[root@laptop policy]# ./policy_tool getpolicy

Policy dump:
============

Magic     = 1debc.
PolVer    = aaaa0000.
Len       = 112.
Primary   = CHINESE WALL policy (c=1, off=14).

Secondary = SIMPLE TYPE ENFORCEMENT policy (c=2, off=d8).

Chinese Wall policy:
====================

Max Types     = a.
Max Ssidrefs  = 5.
Max ConfSets  = 2.
Ssidrefs Off  = 10.

Conflicts Off = 74.
Runing T. Off = 9c.
C. Agg. Off = b0.

SSID To CHWALL-Type matrix:

   ssidref 0:  01 00 00 00 00 00 00 00 00 00
   ssidref 1:  00 01 00 00 00 00 00 00 00 00
   ssidref 2:  00 00 01 00 00 00 00 00 00 00
   ssidref 3:  00 00 00 01 00 00 00 00 00 00
   ssidref 4:  00 00 00 00 01 00 00 00 00 00

Confict Sets:

c-set 0: 00 00 01 01 00 00 00 00 00 00
c-set 1: 01 00 00 00 00 01 01 00 00 00 <<< t1 is not part of any c-set

Running
Types: 01 01 00 00 00 00 00 00 00 00 <<< xmsec1 has ssidref 1->type1
^^ <<< ref-count at position 1 incr
Conflict
Aggregate Set: 00 00 00 00 00 01 01 00 00 00 <<< domain 1 was allowed to
<<< start since type 1 was not <<< in conflict with running <<< types

Simple Type Enforcement policy:
===============================

Max Types     = 5.
Max Ssidrefs  = 5.
Ssidrefs Off  = 8.

SSID To STE-Type matrix:

   ssidref 0: 01 01 01 01 01           <<< the ste policy does not maintain; we
   ssidref 1: 00 01 00 00 00   <--     <<< see that domain xmsec1 has ste 
   ssidref 2: 00 00 01 00 00           <<< ssidref1->type1 and has this type in
   ssidref 3: 00 00 00 01 00           <<< common with dom0

ssidref 4: 00 00 00 00 01

Policy dump End.

Look at sHype output in xen dmesg:

[root@laptop xen]# xm dmesg
.
.
[somewhere near the very end]
(XEN) chwall_init_domain_ssid: determined chwall_ssidref to 1. (XEN) ste_init_domain_ssid.
(XEN) ste_init_domain_ssid: determined ste_ssidref to 1. (XEN) acm_init_domain_ssid: Instantiated individual ssid for domain 0x01. (XEN) chwall_post_domain_create.
(XEN) ste_pre_eventchannel_interdomain.
(XEN) ste_pre_eventchannel_interdomain: (evtchn 0 --> 1) common type #01. (XEN) shype_authorize_domops.
(XEN) ste_pre_eventchannel_interdomain.
(XEN) ste_pre_eventchannel_interdomain: (evtchn 0 --> 1) common type #01. (XEN) ste_pre_eventchannel_interdomain.
(XEN) ste_pre_eventchannel_interdomain: (evtchn 0 --> 1) common type #01.

You can see that the chinese wall policy does not complain and that the ste policy makes three access control decisions for three event-channels setup between domain 0 and the new domain 1. Each time, the two domains share the type1 and setting up the eventchannel is permitted.

Starting up a second domain xmsec2:

[root@laptop xen]# xm create -c xmsec2
Using config file "xmsec2".
Started domain xmsec2, console on port 9602
************ REMOTE CONSOLE: CTRL-] TO QUIT ********
Linux version 2.6.11-xenU ([email protected]) (gcc version 3.4.2 20041017 (Red Hat 3.4.2-6.fc3)) #1 Wed Mar 30 13:14:31 EST 2005
.
.
.
[root@laptop policy]# xm list

Name              Id  Mem(MB)  CPU  State  Time(s)  Console  SSID-REF
Domain-0           0      620   0  r----     71.7            s:00/p:00
xmsec1             1        9   0  -b---      0.3    9601    s:01/p:01
xmsec2             2        7   0  -b---      0.3    9602    s:02/p:02   << our domain runs both policies with ssidref 2

[root@laptop policy]# ./policy_tool getpolicy

Policy dump:
============

Magic     = 1debc.
PolVer    = aaaa0000.
Len       = 112.
Primary   = CHINESE WALL policy (c=1, off=14).

Secondary = SIMPLE TYPE ENFORCEMENT policy (c=2, off=d8).

Chinese Wall policy:
====================

Max Types     = a.
Max Ssidrefs  = 5.
Max ConfSets  = 2.
Ssidrefs Off  = 10.

Conflicts Off = 74.
Runing T. Off = 9c.
C. Agg. Off = b0.

SSID To CHWALL-Type matrix:

   ssidref 0:  01 00 00 00 00 00 00 00 00 00
   ssidref 1:  00 01 00 00 00 00 00 00 00 00
   ssidref 2:  00 00 01 00 00 00 00 00 00 00   <<< our domain has type 2 set
   ssidref 3:  00 00 00 01 00 00 00 00 00 00
   ssidref 4:  00 00 00 00 01 00 00 00 00 00

Confict Sets:

c-set 0: 00 00 01 01 00 00 00 00 00 00 <<< t2 is in c-set0 with type 3
c-set 1: 01 00 00 00 00 01 01 00 00 00

Running
Types: 01 01 01 00 00 00 00 00 00 00 <<< t2 is running since the
^^ <<< current aggregate conflict
<<< set (see above) does not <<< include type 2
Conflict
Aggregate Set: 00 00 00 01 00 01 01 00 00 00 <<< type 3 is added to the
<<< conflict aggregate

Simple Type Enforcement policy:
===============================

Max Types     = 5.
Max Ssidrefs  = 5.
Ssidrefs Off  = 8.

SSID To STE-Type matrix:

ssidref 0: 01 01 01 01 01
ssidref 1: 00 01 00 00 00
ssidref 2: 00 00 01 00 00
ssidref 3: 00 00 00 01 00
ssidref 4: 00 00 00 00 01

Policy dump End.

The sHype xen dmesg output looks similar to the one above when starting the first domain.

Now we start xmsec3 and it has ssidref3. Thus, it tries to run as type3 which conflicts with running type2 (from xmsec2). As expected, creating this domain fails for security policy enforcement reasons.

[root@laptop xen]# xm create -c xmsec3
Using config file "xmsec3".
Error: Error creating domain: (22, 'Invalid argument') [root@laptop xen]#

[root@laptop xen]# xm dmesg
.
.
[somewhere near the very end]
(XEN) chwall_pre_domain_create.
(XEN) chwall_pre_domain_create: CHINESE WALL CONFLICT in type 03.

xmsec3 ssidref3 points to type3, which is in the current conflict aggregate set. This domain cannot start until domain xmsec2 is destroyed, at which time the aggregate conflict set is reduced and type3 is excluded from it. Then, xmsec3 can start. Of course, afterwards, xmsec2 cannot be restarted. Try it.

3. Policy tool
**************
toos/policy/policy_tool.c

a) ./policy_tool getpolicy
prints the currently enforced policy
(see for example section 1.)

b) ./policy_tool setpolicy
sets a predefined and hardcoded security
policy (the one described in section 2.)

c) ./policy_tool dumpstats
prints some status information about the caching of access control decisions (number of cache hits and number of policy evaluations for grant_table and event channels).

d) ./policy_tool loadpolicy <binary_policy_file> sets the policy defined in the <binary_policy_file> please use the policy_processor that is posted to this mailing list to create such a binary policy from an XML policy description

4. Policy interface:
********************
The Policy interface is working in "network-byte-order" (big endian). The reason for this is that policy files/management should be portable and independent of the platforms.

Our policy interface enables managers to create a single binary policy file in a trusted environment and distributed it to multiple systems for enforcement.

====================end-of file=======================================

xen/acm/acm_chinesewall_hooks.c +503 -0
diff -uprN xeno-unstable.bk_orig/xen/acm/acm_chinesewall_hooks.c xeno-unstable.bk-shype/xen/acm/acm_chinesewall_hooks.c
@@ -0,0 +1,503 @@
+/****************************************************************
+ * acm_chinesewall_hooks.c
+ * 
+ * Copyright (C) 2005 IBM Corporation
+ *
+ * Author:
+ * Reiner Sailer <[email protected]>
+ *
+ * Contributions:
+ * Stefan Berger <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, version 2 of the
+ * License.
+ *
+ * sHype Chinese Wall Policy for Xen
+ *    This code implements the hooks that are called
+ *    throughout Xen operations and decides authorization
+ *    based on domain types and Chinese Wall conflict type 
+ *    sets. The CHWALL policy decides if a new domain can be started
+ *    based on the types of running domains and the type of the
+ *    new domain to be started. If the new domain's type is in
+ *    conflict with types of running domains, then this new domain
+ *    is not allowed to be created. A domain can have multiple types,
+ *    in which case all types of a new domain must be conflict-free
+ *    with all types of already running domains.
+ *
+ */
+#include <xen/config.h>
+#include <xen/errno.h>
+#include <xen/types.h>
+#include <xen/lib.h>
+#include <xen/delay.h>
+#include <xen/sched.h>
+#include <public/acm.h>
+#include <asm/atomic.h>
+#include <acm/acm_core.h>
+#include <acm/acm_hooks.h>
+#include <acm/acm_endian.h>
+
+/* local cache structures for chinese wall policy */
+struct chwall_binary_policy chwall_bin_pol;
+
+/*
+ * Initializing chinese wall policy (will be filled by policy partition
+ * using setpolicy command)
+ */
+int acm_init_chwall_policy(void)
+{
+	/* minimal startup policy; policy write-locked already */
+	chwall_bin_pol.max_types = 1;
+	chwall_bin_pol.max_ssidrefs = 1;
+	chwall_bin_pol.max_conflictsets = 1;
+	chwall_bin_pol.ssidrefs = (domaintype_t *)xmalloc_array(domaintype_t, chwall_bin_pol.max_ssidrefs*chwall_bin_pol.max_types);
+	chwall_bin_pol.conflict_sets = (domaintype_t *)xmalloc_array(domaintype_t, chwall_bin_pol.max_conflictsets*chwall_bin_pol.max_types);
+	chwall_bin_pol.running_types = (domaintype_t *)xmalloc_array(domaintype_t, chwall_bin_pol.max_types);
+	chwall_bin_pol.conflict_aggregate_set = (domaintype_t *)xmalloc_array(domaintype_t, chwall_bin_pol.max_types);
+	
+	if ((chwall_bin_pol.conflict_sets == NULL) || (chwall_bin_pol.running_types == NULL) ||
+	    (chwall_bin_pol.ssidrefs == NULL) || (chwall_bin_pol.conflict_aggregate_set == NULL))
+		return ACM_INIT_SSID_ERROR;
+
+	/* initialize state */
+	memset((void *)chwall_bin_pol.ssidrefs, 0, chwall_bin_pol.max_ssidrefs*chwall_bin_pol.max_types*sizeof(domaintype_t));
+	memset((void *)chwall_bin_pol.conflict_sets, 0, chwall_bin_pol.max_conflictsets*chwall_bin_pol.max_types*sizeof(domaintype_t));
+	memset((void *)chwall_bin_pol.running_types, 0, chwall_bin_pol.max_types*sizeof(domaintype_t));
+	memset((void *)chwall_bin_pol.conflict_aggregate_set, 0, chwall_bin_pol.max_types*sizeof(domaintype_t));	
+	return ACM_OK;
+}
+
+static int
+chwall_init_domain_ssid(void **chwall_ssid, ssidref_t ssidref)
+{
+	struct chwall_ssid *chwall_ssidp = xmalloc(struct chwall_ssid);
+	traceprintk("%s.\n", __func__);
+	if (chwall_ssidp == NULL)
+		return ACM_INIT_SSID_ERROR;
+	/* 
+	 * depending on wheter chwall is primary or secondary, get the respective
+	 * part of the global ssidref (same way we'll get the partial ssid pointer)
+	 */
+	chwall_ssidp->chwall_ssidref = GET_SSIDREF(ACM_CHINESE_WALL_POLICY, ssidref);
+	if (chwall_ssidp->chwall_ssidref >= chwall_bin_pol.max_ssidrefs) {
+		printkd("%s: ERROR chwall_ssidref(%x) > max(%x).\n",
+			__func__, chwall_ssidp->chwall_ssidref, chwall_bin_pol.max_ssidrefs-1);
+		xfree(chwall_ssidp);
+		return ACM_INIT_SSID_ERROR;
+	}
+	(*chwall_ssid) = chwall_ssidp;
+	printkd("%s: determined chwall_ssidref to %x.\n", 
+	       __func__, chwall_ssidp->chwall_ssidref);
+	return ACM_OK;
+}
+
+static void
+chwall_free_domain_ssid(void *chwall_ssid)
+{
+	traceprintk("%s.\n", __func__);
+	if (chwall_ssid != NULL)
+		xfree(chwall_ssid);
+	return;
+}
+
+
+/* dump chinese wall cache; policy read-locked already */
+static int
+chwall_dump_policy(u8 *buf, u16 buf_size) {	
+     struct acm_chwall_policy_buffer *chwall_buf = (struct acm_chwall_policy_buffer *)buf;
+     int ret = 0;
+
+     chwall_buf->chwall_max_types = htons(chwall_bin_pol.max_types);
+     chwall_buf->chwall_max_ssidrefs = htons(chwall_bin_pol.max_ssidrefs);
+     chwall_buf->policy_code = htons(ACM_CHINESE_WALL_POLICY);
+     chwall_buf->chwall_ssid_offset = htons(sizeof(struct acm_chwall_policy_buffer));
+     chwall_buf->chwall_max_conflictsets = htons(chwall_bin_pol.max_conflictsets);
+     chwall_buf->chwall_conflict_sets_offset =
+	     htons(
+		   ntohs(chwall_buf->chwall_ssid_offset) + 
+		   sizeof(domaintype_t) * chwall_bin_pol.max_ssidrefs * 
+		   chwall_bin_pol.max_types);
+
+     chwall_buf->chwall_running_types_offset = 
+	     htons(
+		   ntohs(chwall_buf->chwall_conflict_sets_offset) +
+		   sizeof(domaintype_t) * chwall_bin_pol.max_conflictsets *
+		   chwall_bin_pol.max_types);
+
+     chwall_buf->chwall_conflict_aggregate_offset =
+	     htons(
+		   ntohs(chwall_buf->chwall_running_types_offset) +
+		   sizeof(domaintype_t) * chwall_bin_pol.max_types);
+
+     ret = ntohs(chwall_buf->chwall_conflict_aggregate_offset) +
+	     sizeof(domaintype_t) * chwall_bin_pol.max_types;
+
+     /* now copy buffers over */
+     arrcpy16((u16 *)(buf + ntohs(chwall_buf->chwall_ssid_offset)),
+	      chwall_bin_pol.ssidrefs,
+	      chwall_bin_pol.max_ssidrefs * chwall_bin_pol.max_types);
+
+     arrcpy16((u16 *)(buf + ntohs(chwall_buf->chwall_conflict_sets_offset)),
+	      chwall_bin_pol.conflict_sets,
+	      chwall_bin_pol.max_conflictsets * chwall_bin_pol.max_types);
+
+     arrcpy16((u16 *)(buf + ntohs(chwall_buf->chwall_running_types_offset)),
+	      chwall_bin_pol.running_types,
+	      chwall_bin_pol.max_types);
+
+     arrcpy16((u16 *)(buf + ntohs(chwall_buf->chwall_conflict_aggregate_offset)),
+	      chwall_bin_pol.conflict_aggregate_set,
+	      chwall_bin_pol.max_types);
+     return ret;
+}
+
+/* adapt security state (running_types and conflict_aggregate_set) to all running
+ * domains; chwall_init_state is called when a policy is changed to bring the security
+ * information into a consistent state and to detect violations (return != 0).
+ * from a security point of view, we simulate that all running domains are re-started
+ */ 
+static int
+chwall_init_state(struct acm_chwall_policy_buffer *chwall_buf, domaintype_t *ssidrefs, domaintype_t *conflict_sets,
+		  domaintype_t *running_types, domaintype_t *conflict_aggregate_set)
+{
+	int violation = 0, i, j;
+	struct chwall_ssid *chwall_ssid;
+	ssidref_t chwall_ssidref;
+	struct domain **pd;
+
+        write_lock(&domlist_lock);
+	/* go through all domains and adjust policy as if this domain was started now */
+        pd = &domain_list;
+        for ( pd = &domain_list; *pd != NULL; pd = &(*pd)->next_in_list ) {
+		chwall_ssid = GET_SSIDP(ACM_CHINESE_WALL_POLICY, (struct acm_ssid_domain *)(*pd)->ssid);
+		chwall_ssidref = chwall_ssid->chwall_ssidref;
+		traceprintk("%s: validating policy for domain %x (chwall-REF=%x).\n", 
+			__func__, (*pd)->domain_id, chwall_ssidref);
+		/* a) adjust types ref-count for running domains */
+		for (i=0; i< chwall_buf->chwall_max_types; i++)
+			running_types[i] +=
+				ssidrefs[chwall_ssidref*chwall_buf->chwall_max_types + i];
+
+		/* b) check for conflict */
+		for (i=0; i< chwall_buf->chwall_max_types; i++)
+			if (conflict_aggregate_set[i] && 
+			    ssidrefs[chwall_ssidref*chwall_buf->chwall_max_types + i]) {
+				printk("%s: CHINESE WALL CONFLICT in type %02x.\n", __func__, i);
+				violation = 1;
+				goto out;
+			}
+		/* set violation and break out of the loop */
+		/* c) adapt conflict aggregate set for this domain (notice conflicts) */
+		for (i=0; i<chwall_buf->chwall_max_conflictsets; i++) {
+			int common = 0;
+			/* check if conflict_set_i and ssidref have common types */
+			for (j=0; j<chwall_buf->chwall_max_types; j++)
+				if (conflict_sets[i*chwall_buf->chwall_max_types + j] &&
+				    ssidrefs[chwall_ssidref*chwall_buf->chwall_max_types + j]) {
+					common = 1;
+					break;
+				}
+			if (common == 0)
+				continue; /* try next conflict set */
+			/* now add types of the conflict set to conflict_aggregate_set (except types in chwall_ssidref) */
+			for (j=0; j<chwall_buf->chwall_max_types; j++)
+				if (conflict_sets[i*chwall_buf->chwall_max_types + j] &&
+				    !ssidrefs[chwall_ssidref*chwall_buf->chwall_max_types + j])
+					conflict_aggregate_set[j]++;
+		}	
+	}
+ out:
+        write_unlock(&domlist_lock);
+	return violation;
+	/* returning "violation != 0" means that the currently running set of domains would 
+	 * not be possible if the new policy had been enforced before starting them; for chinese
+	 * wall, this means that the new policy includes at least one conflict set of which 
+	 * more than one type is currently running */
+}
+
+static int
+chwall_set_policy(u8 *buf, u16 buf_size) 
+{	
+	/* policy write-locked already */
+	struct acm_chwall_policy_buffer *chwall_buf = (struct acm_chwall_policy_buffer *)buf;
+	void *ssids = NULL, *conflict_sets = NULL, *running_types = NULL, *conflict_aggregate_set = NULL;	
+
+        /* rewrite the policy due to endianess */
+        chwall_buf->policy_code                      = ntohs(chwall_buf->policy_code);
+        chwall_buf->chwall_max_types                 = ntohs(chwall_buf->chwall_max_types);
+        chwall_buf->chwall_max_ssidrefs              = ntohs(chwall_buf->chwall_max_ssidrefs);
+        chwall_buf->chwall_max_conflictsets          = ntohs(chwall_buf->chwall_max_conflictsets);
+        chwall_buf->chwall_ssid_offset               = ntohs(chwall_buf->chwall_ssid_offset);
+        chwall_buf->chwall_conflict_sets_offset      = ntohs(chwall_buf->chwall_conflict_sets_offset);
+        chwall_buf->chwall_running_types_offset      = ntohs(chwall_buf->chwall_running_types_offset);
+        chwall_buf->chwall_conflict_aggregate_offset = ntohs(chwall_buf->chwall_conflict_aggregate_offset);
+
+	/* 1. allocate new buffers */
+	ssids = xmalloc_array(domaintype_t, chwall_buf->chwall_max_types*chwall_buf->chwall_max_ssidrefs);
+	conflict_sets = xmalloc_array(domaintype_t, chwall_buf->chwall_max_conflictsets*chwall_buf->chwall_max_types);
+	running_types = xmalloc_array(domaintype_t,chwall_buf->chwall_max_types);
+	conflict_aggregate_set = xmalloc_array(domaintype_t, chwall_buf->chwall_max_types);
+
+	if ((ssids == NULL)||(conflict_sets == NULL)||(running_types == NULL)||(conflict_aggregate_set == NULL))
+		goto error_free;
+
+	/* 2. set new policy */
+	if (chwall_buf->chwall_ssid_offset + sizeof(domaintype_t) * 
+	    chwall_buf->chwall_max_types * chwall_buf->chwall_max_ssidrefs > buf_size)
+		goto error_free;
+	arrcpy(ssids, buf + chwall_buf->chwall_ssid_offset,
+	       sizeof(domaintype_t),  
+	       chwall_buf->chwall_max_types * chwall_buf->chwall_max_ssidrefs);
+
+	if (chwall_buf->chwall_conflict_sets_offset + sizeof(domaintype_t) * 
+	    chwall_buf->chwall_max_types * chwall_buf->chwall_max_conflictsets > buf_size)
+		goto error_free;
+
+	arrcpy(conflict_sets, buf + chwall_buf->chwall_conflict_sets_offset,
+	       sizeof(domaintype_t),
+	       chwall_buf->chwall_max_types * chwall_buf->chwall_max_conflictsets);
+
+	/* we also use new state buffers since max_types can change */
+	memset(running_types, 0, sizeof(domaintype_t)*chwall_buf->chwall_max_types);
+	memset(conflict_aggregate_set, 0, sizeof(domaintype_t)*chwall_buf->chwall_max_types);
+
+	/* 3. now re-calculate the state for the new policy based on running domains; 
+	 *    this can fail if new policy is conflicting with running domains */
+	if (chwall_init_state(chwall_buf, ssids, conflict_sets, running_types, conflict_aggregate_set)) {
+		printk("%s: New policy conflicts with running domains. Policy load aborted.\n", __func__);
+		goto error_free; /* new policy conflicts with running domains */
+	}
+	/* 4. free old policy buffers, replace with new ones */
+	chwall_bin_pol.max_types = chwall_buf->chwall_max_types;
+	chwall_bin_pol.max_ssidrefs = chwall_buf->chwall_max_ssidrefs;
+	chwall_bin_pol.max_conflictsets = chwall_buf->chwall_max_conflictsets;
+	if (chwall_bin_pol.ssidrefs != NULL) 
+		xfree(chwall_bin_pol.ssidrefs);
+	if (chwall_bin_pol.conflict_aggregate_set != NULL) 
+		xfree(chwall_bin_pol.conflict_aggregate_set);
+	if (chwall_bin_pol.running_types != NULL) 
+		xfree(chwall_bin_pol.running_types);
+	if (chwall_bin_pol.conflict_sets != NULL) 
+		xfree(chwall_bin_pol.conflict_sets);
+	chwall_bin_pol.ssidrefs = ssids;
+	chwall_bin_pol.conflict_aggregate_set = conflict_aggregate_set;
+	chwall_bin_pol.running_types = running_types;
+	chwall_bin_pol.conflict_sets = conflict_sets;
+	return ACM_OK;
+
+error_free:
+	printk("%s: ERROR setting policy.\n", __func__);
+	if (ssids != NULL) xfree(ssids);
+	if (conflict_sets != NULL) xfree(conflict_sets);
+	if (running_types != NULL) xfree(running_types);
+	if (conflict_aggregate_set != NULL) xfree(conflict_aggregate_set);
+	return -EFAULT;
+}
+	
+static int 
+chwall_dump_stats(u8 *buf, u16 len)
+{
+	/* no stats for Chinese Wall Policy */
+	return 0;
+}
+
+/***************************
+ * Authorization functions
+ ***************************/
+
+
+/* -------- DOMAIN OPERATION HOOKS -----------*/
+
+static int 
+chwall_pre_domain_create(void *subject_ssid, ssidref_t ssidref)
+{
+	ssidref_t chwall_ssidref;
+	int i,j;
+	traceprintk("%s.\n", __func__);
+
+	read_lock(&acm_bin_pol_rwlock);
+	chwall_ssidref = GET_SSIDREF(ACM_CHINESE_WALL_POLICY, ssidref);
+	if (chwall_ssidref == ACM_DEFAULT_LOCAL_SSID) {
+		printk("%s: ERROR CHWALL SSID is NOT SET but policy enforced.\n", __func__);
+		read_unlock(&acm_bin_pol_rwlock);
+		return ACM_ACCESS_DENIED; /* catching and indicating config error */
+	}
+	if (chwall_ssidref >= chwall_bin_pol.max_ssidrefs) {
+		printk("%s: ERROR chwall_ssidref > max(%x).\n",
+		       __func__, chwall_bin_pol.max_ssidrefs-1);
+		read_unlock(&acm_bin_pol_rwlock);
+		return ACM_ACCESS_DENIED;
+	}
+	/* A: chinese wall check for conflicts */
+	for (i=0; i< chwall_bin_pol.max_types; i++)
+		if (chwall_bin_pol.conflict_aggregate_set[i] && 
+		    chwall_bin_pol.ssidrefs[chwall_ssidref*chwall_bin_pol.max_types + i]) {
+			printk("%s: CHINESE WALL CONFLICT in type %02x.\n", __func__, i);
+			read_unlock(&acm_bin_pol_rwlock);
+		        return ACM_ACCESS_DENIED;
+		}
+
+	/* B: chinese wall conflict set adjustment (so that other 
+	 *	other domains simultaneously created are evaluated against this new set)*/
+	for (i=0; i<chwall_bin_pol.max_conflictsets; i++) {
+		int common = 0;
+		/* check if conflict_set_i and ssidref have common types */
+		for (j=0; j<chwall_bin_pol.max_types; j++)
+			if (chwall_bin_pol.conflict_sets[i*chwall_bin_pol.max_types + j] &&
+			    chwall_bin_pol.ssidrefs[chwall_ssidref*chwall_bin_pol.max_types + j]) {
+				common = 1;
+				break;
+			}
+		if (common == 0)
+			continue; /* try next conflict set */
+		/* now add types of the conflict set to conflict_aggregate_set (except types in chwall_ssidref) */
+		for (j=0; j<chwall_bin_pol.max_types; j++)
+			if (chwall_bin_pol.conflict_sets[i*chwall_bin_pol.max_types + j] &&
+			    !chwall_bin_pol.ssidrefs[chwall_ssidref*chwall_bin_pol.max_types + j])
+				chwall_bin_pol.conflict_aggregate_set[j]++;
+	}
+	read_unlock(&acm_bin_pol_rwlock);
+	return ACM_ACCESS_PERMITTED;
+}
+
+static void
+chwall_post_domain_create(domid_t domid, ssidref_t ssidref)
+{
+	int i,j;
+	ssidref_t chwall_ssidref;
+	traceprintk("%s.\n", __func__);
+	
+	read_lock(&acm_bin_pol_rwlock);
+	chwall_ssidref = GET_SSIDREF(ACM_CHINESE_WALL_POLICY, ssidref);
+	/* adjust types ref-count for running domains */
+	for (i=0; i< chwall_bin_pol.max_types; i++)
+		chwall_bin_pol.running_types[i] +=
+			chwall_bin_pol.ssidrefs[chwall_ssidref*chwall_bin_pol.max_types + i];
+	if (domid) {
+		read_unlock(&acm_bin_pol_rwlock);
+		return;
+	}
+	/* Xen does not call pre-create hook for DOM0;
+	 * to consider type conflicts of any domain with DOM0, we need
+	 * to adjust the conflict_aggregate for DOM0 here the same way it
+	 * is done for non-DOM0 domains in the pre-hook */
+	printkd("%s: adjusting security state for DOM0 (ssidref=%x, chwall_ssidref=%x).\n", 
+		__func__, ssidref, chwall_ssidref);
+
+	/* chinese wall conflict set adjustment (so that other 
+	 *	other domains simultaneously created are evaluated against this new set)*/
+	for (i=0; i<chwall_bin_pol.max_conflictsets; i++) {
+		int common = 0;
+		/* check if conflict_set_i and ssidref have common types */
+		for (j=0; j<chwall_bin_pol.max_types; j++)
+			if (chwall_bin_pol.conflict_sets[i*chwall_bin_pol.max_types + j] &&
+			    chwall_bin_pol.ssidrefs[chwall_ssidref*chwall_bin_pol.max_types + j]) {
+				common = 1;
+				break;
+			}
+		if (common == 0)
+			continue; /* try next conflict set */
+		/* now add types of the conflict set to conflict_aggregate_set (except types in chwall_ssidref) */
+		for (j=0; j<chwall_bin_pol.max_types; j++)
+			if (chwall_bin_pol.conflict_sets[i*chwall_bin_pol.max_types + j] &&
+			    !chwall_bin_pol.ssidrefs[chwall_ssidref*chwall_bin_pol.max_types + j])
+				chwall_bin_pol.conflict_aggregate_set[j]++;
+	}
+	read_unlock(&acm_bin_pol_rwlock);
+	return;
+}
+
+static void
+chwall_fail_domain_create(void *subject_ssid, ssidref_t ssidref)
+{
+	int i, j;
+	ssidref_t chwall_ssidref;
+	traceprintk("%s.\n", __func__);
+
+	read_lock(&acm_bin_pol_rwlock);
+	chwall_ssidref = GET_SSIDREF(ACM_CHINESE_WALL_POLICY, ssidref);
+	/* roll-back: re-adjust conflicting types aggregate */
+	for (i=0; i<chwall_bin_pol.max_conflictsets; i++) {
+		int common = 0;
+		/* check if conflict_set_i and ssidref have common types */
+		for (j=0; j<chwall_bin_pol.max_types; j++)
+			if (chwall_bin_pol.conflict_sets[i*chwall_bin_pol.max_types + j] &&
+			    chwall_bin_pol.ssidrefs[chwall_ssidref*chwall_bin_pol.max_types + j]) {
+				common = 1;
+				break;
+			}
+		if (common == 0)
+			continue; /* try next conflict set, this one does not include any type of chwall_ssidref */
+		/* now add types of the conflict set to conflict_aggregate_set (except types in chwall_ssidref) */
+		for (j=0; j<chwall_bin_pol.max_types; j++)
+			if (chwall_bin_pol.conflict_sets[i*chwall_bin_pol.max_types + j] &&
+			    !chwall_bin_pol.ssidrefs[chwall_ssidref*chwall_bin_pol.max_types + j])
+				chwall_bin_pol.conflict_aggregate_set[j]--;
+	}
+	read_unlock(&acm_bin_pol_rwlock);
+}
+
+
+static void
+chwall_post_domain_destroy(void *object_ssid, domid_t id) 
+{
+	int i,j;
+	struct chwall_ssid *chwall_ssidp = 
+		GET_SSIDP(ACM_CHINESE_WALL_POLICY, (struct acm_ssid_domain *)object_ssid);
+	ssidref_t chwall_ssidref = chwall_ssidp->chwall_ssidref;
+
+	traceprintk("%s.\n", __func__);
+
+	read_lock(&acm_bin_pol_rwlock);
+	/* adjust running types set */
+	for (i=0; i< chwall_bin_pol.max_types; i++)
+		chwall_bin_pol.running_types[i] -=
+			chwall_bin_pol.ssidrefs[chwall_ssidref*chwall_bin_pol.max_types + i];
+
+	/* roll-back: re-adjust conflicting types aggregate */
+	for (i=0; i<chwall_bin_pol.max_conflictsets; i++) {
+		int common = 0;
+		/* check if conflict_set_i and ssidref have common types */
+		for (j=0; j<chwall_bin_pol.max_types; j++)
+			if (chwall_bin_pol.conflict_sets[i*chwall_bin_pol.max_types + j] &&
+			    chwall_bin_pol.ssidrefs[chwall_ssidref*chwall_bin_pol.max_types + j]) {
+				common = 1;
+				break;
+			}
+		if (common == 0)
+			continue; /* try next conflict set, this one does not include any type of chwall_ssidref */
+		/* now add types of the conflict set to conflict_aggregate_set (except types in chwall_ssidref) */
+		for (j=0; j<chwall_bin_pol.max_types; j++)
+			if (chwall_bin_pol.conflict_sets[i*chwall_bin_pol.max_types + j] &&
+			    !chwall_bin_pol.ssidrefs[chwall_ssidref*chwall_bin_pol.max_types + j])
+				chwall_bin_pol.conflict_aggregate_set[j]--;
+	}
+	read_unlock(&acm_bin_pol_rwlock);
+	return;
+}
+
+struct acm_operations acm_chinesewall_ops = {
+	/* policy management services */
+	.init_domain_ssid		= chwall_init_domain_ssid,
+	.free_domain_ssid		= chwall_free_domain_ssid,
+	.dump_binary_policy		= chwall_dump_policy,
+	.set_binary_policy		= chwall_set_policy,
+	.dump_statistics		= chwall_dump_stats,
+	/* domain management control hooks */
+	.pre_domain_create     		= chwall_pre_domain_create,
+	.post_domain_create		= chwall_post_domain_create,
+	.fail_domain_create		= chwall_fail_domain_create,
+	.post_domain_destroy		= chwall_post_domain_destroy,
+	/* event channel control hooks */
+	.pre_eventchannel_unbound      	= NULL,
+	.fail_eventchannel_unbound	= NULL,
+	.pre_eventchannel_interdomain	= NULL,
+	.fail_eventchannel_interdomain  = NULL,
+	/* grant table control hooks */
+	.pre_grant_map_ref       	= NULL,
+	.fail_grant_map_ref		= NULL,
+	.pre_grant_setup	       	= NULL,
+	.fail_grant_setup		= NULL,
+};
xen/acm/acm_core.c +205 -0

205 lines not on this page · raw message

xen/acm/acm_null_hooks.c +76 -0

76 lines not on this page · raw message

xen/acm/acm_policy.c +197 -0

197 lines not on this page · raw message

xen/acm/acm_simple_type_enforcement_hooks.c +638 -0

638 lines not on this page · raw message

xen/acm/Makefile +15 -0
diff -uprN xeno-unstable.bk_orig/xen/acm/Makefile xeno-unstable.bk-shype/xen/acm/Makefile
@@ -0,0 +1,15 @@
+
+include $(BASEDIR)/Rules.mk
+OBJS =  acm_core.o 
+OBJS += acm_policy.o
+OBJS += acm_simple_type_enforcement_hooks.o
+OBJS += acm_chinesewall_hooks.o
+OBJS += acm_null_hooks.o
+
+default: acm.o
+
+acm.o: $(OBJS)
+	$(LD) $(LDFLAGS) -r -o acm.o $(OBJS)
+
+clean:
+	rm -f *.o *~ core
xen/arch/x86/setup.c +6 -0
diff -uprN xeno-unstable.bk_orig/xen/arch/x86/setup.c xeno-unstable.bk-shype/xen/arch/x86/setup.c
@@ -20,6 +20,7 @@
 #include <asm/desc.h>
 #include <asm/shadow.h>
 #include <asm/e820.h>
+#include <public/acm_dom0_setup.h>
 
 extern void dmi_scan_machine(void);
 extern void generic_apic_probe(void);
@@ -393,12 +394,17 @@ void __init __start_xen(multiboot_info_t
 
     shadow_mode_init();
 
+    /* initialize access control security module */
+    acm_init();
+
     /* Create initial domain 0. */
     dom0 = do_createdomain(0, 0);
     if ( dom0 == NULL )
         panic("Error creating domain 0\n");
 
     set_bit(_DOMF_privileged, &dom0->domain_flags);
+    /* post-create hooks sets security label */
+    acm_post_domain0_create(dom0->domain_id);
 
     /* Grab the DOM0 command line. */
     cmdline = (char *)(mod[0].string ? __va(mod[0].string) : NULL);
xen/arch/x86/x86_32/entry.S +1 -0
diff -uprN xeno-unstable.bk_orig/xen/arch/x86/x86_32/entry.S xeno-unstable.bk-shype/xen/arch/x86/x86_32/entry.S
@@ -751,6 +751,7 @@ ENTRY(hypercall_table)
         .long do_boot_vcpu
         .long do_ni_hypercall       /* 25 */
         .long do_mmuext_op
+	 .long do_policy_op          /* 27 */
         .rept NR_hypercalls-((.-hypercall_table)/4)
         .long do_ni_hypercall
         .endr
xen/common/dom0_ops.c +14 -1
diff -uprN xeno-unstable.bk_orig/xen/common/dom0_ops.c xeno-unstable.bk-shype/xen/common/dom0_ops.c
@@ -19,6 +19,7 @@
 #include <asm/current.h>
 #include <public/dom0_ops.h>
 #include <public/sched_ctl.h>
+#include <acm/acm_hooks.h>
 
 extern long arch_do_dom0_op(dom0_op_t *op, dom0_op_t *u_dom0_op);
 extern void arch_getdomaininfo_ctxt(
@@ -91,6 +92,7 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
 {
     long ret = 0;
     dom0_op_t curop, *op = &curop;
+    void *ssid = NULL; /* save security ptr between pre and post/fail hooks */
 
     if ( !IS_PRIV(current->domain) )
         return -EPERM;
@@ -101,6 +103,9 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
     if ( op->interface_version != DOM0_INTERFACE_VERSION )
         return -EACCES;
 
+    if ( acm_pre_dom0_op(op, &ssid) )
+        return -EACCES;
+
     switch ( op->cmd )
     {
 
@@ -357,6 +362,11 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
             ((d->domain_flags & DOMF_shutdown) ? DOMFLAGS_SHUTDOWN : 0) |
             d->shutdown_code << DOMFLAGS_SHUTDOWNSHIFT;
 
+        if (d->ssid != NULL)
+            op->u.getdomaininfo.ssidref = ((struct acm_ssid_domain *)d->ssid)->ssidref;
+        else    
+            op->u.getdomaininfo.ssidref = ACM_DEFAULT_SSID;
+
         op->u.getdomaininfo.tot_pages   = d->tot_pages;
         op->u.getdomaininfo.max_pages   = d->max_pages;
         op->u.getdomaininfo.shared_info_frame = 
@@ -493,7 +503,10 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
         ret = arch_do_dom0_op(op,u_dom0_op);
 
     }
-
+    if (!ret)
+        acm_post_dom0_op(op, ssid);
+    else
+        acm_fail_dom0_op(op, ssid);
     return ret;
 }
 
xen/common/event_channel.c +4 -0
diff -uprN xeno-unstable.bk_orig/xen/common/event_channel.c xeno-unstable.bk-shype/xen/common/event_channel.c
@@ -26,6 +26,7 @@
 
 #include <public/xen.h>
 #include <public/event_channel.h>
+#include <acm/acm_hooks.h>
 
 #define bucket_from_port(d,p) \
     ((d)->evtchn[(p)/EVTCHNS_PER_BUCKET])
@@ -587,6 +588,9 @@ long do_event_channel_op(evtchn_op_t *uo
     if ( copy_from_user(&op, uop, sizeof(op)) != 0 )
         return -EFAULT;
 
+    if (acm_pre_event_channel(&op))
+        return -EACCES;
+
     switch ( op.cmd )
     {
     case EVTCHNOP_alloc_unbound:
xen/common/grant_table.c +6 -0
diff -uprN xeno-unstable.bk_orig/xen/common/grant_table.c xeno-unstable.bk-shype/xen/common/grant_table.c
@@ -30,6 +30,7 @@
 #include <xen/sched.h>
 #include <xen/shadow.h>
 #include <xen/mm.h>
+#include <acm/acm_hooks.h>
 
 #define PIN_FAIL(_lbl, _rc, _f, _a...)   \
     do {                           \
@@ -357,6 +358,11 @@ __gnttab_map_grant_ref(
         return GNTST_bad_gntref;
     }
 
+    if (acm_pre_grant_map_ref(dom)) {
+        (void)__put_user(GNTST_permission_denied, &uop->handle);
+        return GNTST_permission_denied;
+    }
+
     if ( unlikely((rd = find_domain_by_id(dom)) == NULL) ||
          unlikely(ld == rd) )
     {
xen/common/policy_ops.c +117 -0

117 lines not on this page · raw message

xen/include/acm/acm_core.h +117 -0

117 lines not on this page · raw message

xen/include/acm/acm_endian.h +88 -0

88 lines not on this page · raw message

xen/include/acm/acm_hooks.h +337 -0

337 lines not on this page · raw message

xen/include/public/acm_dom0_setup.h +34 -0
diff -uprN xeno-unstable.bk_orig/xen/include/public/acm_dom0_setup.h xeno-unstable.bk-shype/xen/include/public/acm_dom0_setup.h
@@ -0,0 +1,34 @@
+/****************************************************************
+ * acm_dom0_setup.h
+ * 
+ * Copyright (C) 2005 IBM Corporation
+ *
+ * Author:
+ * Reiner Sailer <[email protected]>
+ *
+ * Includes necessary definitions to bring-up dom0
+ */
+#include <acm/acm_hooks.h>
+
+extern int acm_init(void);
+
+#if (ACM_USE_SECURITY_POLICY == ACM_NULL_POLICY)
+
+static inline void acm_post_domain0_create(domid_t domid) 
+{ 
+	return; 
+}
+
+#else
+
+/* predefined ssidref for DOM0 used by xen when creating DOM0 */
+#define ACM_DOM0_SSIDREF	0
+
+static inline void acm_post_domain0_create(domid_t domid)
+{
+	/* initialialize shared sHype security labels for new domain */
+	acm_init_domain_ssid(domid, ACM_DOM0_SSIDREF);
+	acm_post_domain_create(domid, ACM_DOM0_SSIDREF);
+}
+
+#endif
xen/include/public/acm.h +161 -0

161 lines not on this page · raw message

xen/include/public/dom0_ops.h +3 -0
diff -uprN xeno-unstable.bk_orig/xen/include/public/dom0_ops.h xeno-unstable.bk-shype/xen/include/public/dom0_ops.h
@@ -43,6 +43,8 @@ typedef struct sched_adjdom_cmd dom0_adj
 
 #define DOM0_CREATEDOMAIN      8
 typedef struct {
+    /* IN parameters */
+    u32 ssidref;
     /* IN/OUT parameters. */
     /* Identifier for new domain (auto-allocate if zero is specified). */
     domid_t domain;
@@ -88,6 +90,7 @@ typedef struct {
     u32      n_vcpu;
     s32      vcpu_to_cpu[MAX_VIRT_CPUS];  /* current mapping   */
     cpumap_t cpumap[MAX_VIRT_CPUS];       /* allowable mapping */
+    u32	     ssidref;
 } dom0_getdomaininfo_t;
 
 #define DOM0_SETDOMAININFO      13
xen/include/public/policy_ops.h +74 -0

74 lines not on this page · raw message

xen/include/public/xen.h +1 -0
diff -uprN xeno-unstable.bk_orig/xen/include/public/xen.h xeno-unstable.bk-shype/xen/include/public/xen.h
@@ -58,6 +58,7 @@
 #define __HYPERVISOR_boot_vcpu            24
 #define __HYPERVISOR_set_segment_base     25 /* x86/64 only */
 #define __HYPERVISOR_mmuext_op            26
+#define __HYPERVISOR_policy_op		  27
 
 /* 
  * VIRTUAL INTERRUPTS
xen/include/xen/sched.h +2 -0
diff -uprN xeno-unstable.bk_orig/xen/include/xen/sched.h xeno-unstable.bk-shype/xen/include/xen/sched.h
@@ -137,6 +137,8 @@ struct domain
     cpumask_t        cpumask;
 
     struct arch_domain arch;
+
+    void *ssid; /* sHype security subject identifier */
 };
 
 struct domain_setup_info
xen/Makefile +3 -1
diff -uprN xeno-unstable.bk_orig/xen/Makefile xeno-unstable.bk-shype/xen/Makefile
@@ -46,6 +46,7 @@ clean: delete-unfresh-files
 	$(MAKE) -C tools clean
 	$(MAKE) -C common clean
 	$(MAKE) -C drivers clean
+	$(MAKE) -C acm clean
 	$(MAKE) -C arch/$(TARGET_ARCH) clean
 	rm -f include/asm *.o $(TARGET)* *~ core
 	rm -f include/asm-*/asm-offsets.h
@@ -58,6 +59,7 @@ $(TARGET): delete-unfresh-files
 	$(MAKE) include/asm-$(TARGET_ARCH)/asm-offsets.h
 	$(MAKE) -C common
 	$(MAKE) -C drivers
+	$(MAKE) -C acm
 	$(MAKE) -C arch/$(TARGET_ARCH)
 
 # drivers/char/console.o may contain static banner/compile info. Blow it away.
@@ -109,7 +111,7 @@ include/asm-$(TARGET_ARCH)/asm-offsets.h
 
 .PHONY: default debug install dist clean delete-unfresh-files TAGS tags
 
-SUBDIRS = arch/$(TARGET_ARCH) common drivers 
+SUBDIRS = acm arch/$(TARGET_ARCH) common drivers 
 define all_sources
     ( find include/asm-$(TARGET_ARCH) -name SCCS -prune -o -name '*.h' -print; \
       find include -type d -name SCCS -prune -o \( -name "asm-*" -o \
xen/Rules.mk +1 -0
diff -uprN xeno-unstable.bk_orig/xen/Rules.mk xeno-unstable.bk-shype/xen/Rules.mk
@@ -35,6 +35,7 @@ OBJS    += $(patsubst %.c,%.o,$(C_SRCS))
 ALL_OBJS := $(BASEDIR)/common/common.o
 ALL_OBJS += $(BASEDIR)/drivers/char/driver.o
 ALL_OBJS += $(BASEDIR)/drivers/acpi/driver.o
+ALL_OBJS += $(BASEDIR)/acm/acm.o
 ALL_OBJS += $(BASEDIR)/arch/$(TARGET_ARCH)/arch.o
 
 
tools/libxc/xc_domain.c +3 -0
diff -uprN xeno-unstable.bk_orig/tools/libxc/xc_domain.c xeno-unstable.bk-shype/tools/libxc/xc_domain.c
@@ -9,6 +9,7 @@
 #include "xc_private.h"
 
 int xc_domain_create(int xc_handle,
+                     u32 ssidref,
                      u32 *pdomid)
 {
     int err;
@@ -16,6 +17,7 @@ int xc_domain_create(int xc_handle,
 
     op.cmd = DOM0_CREATEDOMAIN;
     op.u.createdomain.domain = (domid_t)*pdomid;
+    op.u.createdomain.ssidref = ssidref;
     if ( (err = do_dom0_op(xc_handle, &op)) != 0 )
         return err;
 
@@ -101,6 +103,7 @@ int xc_domain_getinfo(int xc_handle,
             info->crashed  = 1;
         }
 
+        info->ssidref  = op.u.getdomaininfo.ssidref;
         info->nr_pages = op.u.getdomaininfo.tot_pages;
         info->max_memkb = op.u.getdomaininfo.max_pages<<(PAGE_SHIFT);
         info->shared_info_frame = op.u.getdomaininfo.shared_info_frame;
tools/libxc/xc.h +2 -0
diff -uprN xeno-unstable.bk_orig/tools/libxc/xc.h xeno-unstable.bk-shype/tools/libxc/xc.h
@@ -110,6 +110,7 @@ int xc_waitdomain_core(int domain, 
 
 typedef struct {
     u32           domid;
+    u32           ssidref;
     unsigned int  dying:1, crashed:1, shutdown:1, 
                   paused:1, blocked:1, running:1;
     unsigned int  shutdown_reason; /* only meaningful if shutdown==1 */
@@ -124,6 +125,7 @@ typedef struct {
 
 typedef dom0_getdomaininfo_t xc_domaininfo_t;
 int xc_domain_create(int xc_handle, 
+                     u32 ssidref,
                      u32 *pdomid);
 
 
tools/Makefile +1 -0
diff -uprN xeno-unstable.bk_orig/tools/Makefile xeno-unstable.bk-shype/tools/Makefile
@@ -12,6 +12,7 @@ SUBDIRS += xcs
 SUBDIRS += xcutils
 SUBDIRS += pygrub
 SUBDIRS += firmware
+SUBDIRS += policy
 
 .PHONY: all install clean check check_clean ioemu eioemuinstall ioemuclean
 
tools/policy/Makefile +36 -0
diff -uprN xeno-unstable.bk_orig/tools/policy/Makefile xeno-unstable.bk-shype/tools/policy/Makefile
@@ -0,0 +1,36 @@
+XEN_ROOT = ../..
+include $(XEN_ROOT)/tools/Rules.mk
+
+SRCS     = policy_tool.c
+CFLAGS   += -static
+CFLAGS   += -Wall
+CFLAGS   += -Werror
+CFLAGS   += -O3
+CFLAGS   += -fno-strict-aliasing
+CFLAGS   += -I.
+
+all: build
+build: mk-symlinks
+	$(MAKE) policy_tool
+
+default: all
+
+install: all
+
+policy_tool : policy_tool.c
+	$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $<
+
+clean:
+	rm -rf policy_tool xen
+
+
+LINUX_ROOT := $(wildcard $(XEN_ROOT)/linux-2.6.*-xen-sparse)
+mk-symlinks:
+	[ -e xen/linux ] || mkdir -p xen/linux
+	[ -e xen/io ]    || mkdir -p xen/io
+	( cd xen >/dev/null ; \
+	  ln -sf ../$(XEN_ROOT)/xen/include/public/*.h . )
+	( cd xen/io >/dev/null ; \
+	  ln -sf ../../$(XEN_ROOT)/xen/include/public/io/*.h . )
+	( cd xen/linux >/dev/null ; \
+	  ln -sf ../../$(LINUX_ROOT)/include/asm-xen/linux-public/*.h . )
tools/policy/policy_tool.c +557 -0

191 lines not on this page · raw message

tools/python/xen/lowlevel/xc/xc.c +6 -4
diff -uprN xeno-unstable.bk_orig/tools/python/xen/lowlevel/xc/xc.c xeno-unstable.bk-shype/tools/python/xen/lowlevel/xc/xc.c

Lines of this file are not shown. View the raw message.

tools/python/xen/xend/image.py +3 -3
diff -uprN xeno-unstable.bk_orig/tools/python/xen/xend/image.py xeno-unstable.bk-shype/tools/python/xen/xend/image.py

Lines of this file are not shown. View the raw message.

tools/python/xen/xend/server/SrvDomainDir.py +1 -0
diff -uprN xeno-unstable.bk_orig/tools/python/xen/xend/server/SrvDomainDir.py xeno-unstable.bk-shype/tools/python/xen/xend/server/SrvDomainDir.py

Lines of this file are not shown. View the raw message.

tools/python/xen/xend/XendDomainInfo.py +12 -4
diff -uprN xeno-unstable.bk_orig/tools/python/xen/xend/XendDomainInfo.py xeno-unstable.bk-shype/tools/python/xen/xend/XendDomainInfo.py

Lines of this file are not shown. View the raw message.

tools/python/xen/xm/create.py +6 -1
diff -uprN xeno-unstable.bk_orig/tools/python/xen/xm/create.py xeno-unstable.bk-shype/tools/python/xen/xm/create.py

Lines of this file are not shown. View the raw message.

tools/python/xen/xm/main.py +7 -3
diff -uprN xeno-unstable.bk_orig/tools/python/xen/xm/main.py xeno-unstable.bk-shype/tools/python/xen/xm/main.py

Lines of this file are not shown. View the raw message.

tools/python/xen/xm/opts.py +7 -0
diff -uprN xeno-unstable.bk_orig/tools/python/xen/xm/opts.py xeno-unstable.bk-shype/tools/python/xen/xm/opts.py

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

Part of the diff is not shown here. View the raw message.

#1 lore raw
Quoted 24 lines · Reiner Sailer

This E-mail contains the sHype access control architecture for inclusion into the Xen hypervisor (xeno-unstable.bk). This is a follow-up on earlier postings:
http://lists.xensource.com/archives/html/xen-devel/2005-04/msg00864.html

The *_xen.diff patch includes the core sHype access control architecture. Default is the NULL-policy.

The *_tools.diff patch includes the necessary additions to the tools directory:
a) adding support for an additional VM configuration paramter
b) adding basic policy management support into tools/policy

The default setting is the NULL policy. After patching in the diff- files, you should see no change in behavior. Please refer to the attached shype4xen_readme.txt file for instructions on how to activate and experiment with sHype.

While we have added support for saving and restoring security information when saving and restoring domains, the architecture currently supports save/restore only on the same hypervisor system running the same sHype policy. Future versions will include more flexible support for save/restore/migration.

Quoted 4 lines

Our group will submit a java-based policy translation tool for sHype to this mailing list today as well. This tool takes as input an XML-based descriptions of user-defined sHype policies and translates them into a binary policy format that can be loaded into sHype.

any plan to write the tool in other language, not Java? i guess not many people (include me) are willing to install Java on their system.

since python is used in xen, i think it is a good candidate.

i will play with the code and give some feedbacks.

regards,
aq

#2 lore raw
Quoted 10 lines · aq

any plan to write the tool in other language, not Java? i guess not many people (include me) are willing to install Java on their system.

since python is used in xen, i think it is a good candidate.

i will play with the code and give some feedbacks.

regards,
aq

Ensuring that the code compiles cleanly with gcj would eliminate this issue.

-Tupshin

#3 lore raw
Quoted 5 lines · Tupshin Harper
Quoted 3 lines · aq

any plan to write the tool in other language, not Java? i guess not many people (include me) are willing to install Java on their system.

Quoted 8 lines
Quoted 7 lines

since python is used in xen, i think it is a good candidate.

i will play with the code and give some feedbacks.

regards,
aq

Ensuring that the code compiles cleanly with gcj would eliminate this issue.

but we still need java to run the binary code, dont we?

regards,
aq

#4 lore raw
Quoted 19 lines · aq
Quoted 16 lines · Tupshin Harper
Quoted 12 lines · aq

any plan to write the tool in other language, not Java? i guess not many people (include me) are willing to install Java on their system.

since python is used in xen, i think it is a good candidate.

i will play with the code and give some feedbacks.

regards,
aq

Quoted 10 lines
Quoted 3 lines

Ensuring that the code compiles cleanly with gcj would eliminate this issue.

but we still need java to run the binary code, dont we?

regards,
aq

No. GCJ can make native binaries (even statically linked ones) with no unusual dependencies.

-Tupshin

#5 lore raw
In reply to aq
Quoted 4 lines
Quoted 2 lines

Ensuring that the code compiles cleanly with gcj would eliminate this issue.

but we still need java to run the binary code, dont we?

The GCJ package can deal with binary Java code - you get:
* compiles .java files to .class or to native
* compiles .class to native
* GIJ interprets .class files that haven't been natively compiled

It's actually rather impressive!

But the binary that was originally mentioned earlier is the sHype policy, right? i.e. not Java, just produced by the tool

Cheers,
Mark

#6 lore raw
In reply to aq
Quoted 10 lines · Tupshin Harper
Quoted 8 lines
Quoted 7 lines · aq

any plan to write the tool in other language, not Java? i guess not many people (include me) are willing to install Java on their system.

since python is used in xen, i think it is a good candidate.

i will play with the code and give some feedbacks.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

regards,
aq

Ensuring that the code compiles cleanly with gcj would eliminate this issue.

but we still need java to run the binary code, dont we?

gjc is supposed to be able to compile Java to native machine code, but I have never used it myself. Assuming that it works you wouldn't need JRE or SDK.

Gregor

Signature · 1 line
Quidquid latine dictum sit, altum viditur --- Anon
#10 lore raw
In reply to aq
Quoted 10 lines · aq
Quoted 7 lines · Reiner Sailer

This E-mail contains the sHype access control architecture for inclusion into the Xen hypervisor (xeno-unstable.bk). This is a follow-up on earlier postings:
http://lists.xensource.com/archives/html/xen-devel/2005-04/msg00864.html

[snip]

Quoted 3 lines

any plan to write the tool in other language, not Java? i guess not many people (include me) are willing to install Java on their system.

Hmmm. I have the same complaint about Python. I tend to like anything that can be compiled into a more or less standalone binary.
The current Python tools have a whole chain of dependancies and I often find that this kind of thing ends up leaving me in a situation where I have conflicting dependancies. I just love staicaly compiled binaries or somthing that at most requires the libraries you get with a stock libc install.

I have not looked at the sHype tools but it may be that they can be compiled with gcj and turned into a static binary.

Quoted 14 lines

since python is used in xen, i think it is a good candidate.

i will play with the code and give some feedbacks.

regards,
aq

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

Signature · 3 lines
Alvin Starr                   ||   voice: (416)585-9971
Interlink Connectivity        ||   fax:   (416)585-9974
[email protected]              ||
#7 lore raw
In reply to aq
Quoted 10 lines · Tupshin Harper
Quoted 6 lines · aq

any plan to write the tool in other language, not Java? i guess not many people (include me) are willing to install Java on their system.

since python is used in xen, i think it is a good candidate.

i will play with the code and give some feedbacks.

Ensuring that the code compiles cleanly with gcj would eliminate this

issue.

We will look into compiling the tool with gcj. Thanks. We will appreciate your feedback.

Quoted 1 line

but we still need java to run the binary code, dont we?

No. The tool is used for generating a binary policy file, which can then be loaded into sHype via the xeno-unstable.bk/tools/policy/policy_tool command.

Thanks,
-Ray

#8 lore raw
Quoted 13 lines · Ray Valdez
Quoted 10 lines · Tupshin Harper
Quoted 6 lines · aq

any plan to write the tool in other language, not Java? i guess not many people (include me) are willing to install Java on their system.

since python is used in xen, i think it is a good candidate.

i will play with the code and give some feedbacks.

Ensuring that the code compiles cleanly with gcj would eliminate this

issue.

Quoted 9 lines

We will look into compiling the tool with gcj. Thanks. We will appreciate your feedback.

Quoted 1 line

but we still need java to run the binary code, dont we?

No. The tool is used for generating a binary policy file, which can then be loaded into sHype via the xeno-unstable.bk/tools/policy/policy_tool command.

to tell the truth, installing java into any of my machines is the last thing i want to do. if it is possible to compile java code to native binary, that would be great. then java turns out to be even better than python, right ;-)

regards,
aq