Skip to contentSkip to conversation

1/2: Testing of ACM security hooks and tools

PATCH New Stefan Berger 1 participant 1 message Oct 18, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 1/2: Testing of ACM security hooks and tools

This patch adds tests cases for the ACM security hooks and tools to the xm test suite. The tests can be run with ACM turned off (not compiled into Xen; see user doc for this), but most of them will be skipped then. They can be run with a command like

make -C tests/security-acm check-TESTS

from the xm-test directory. They are also part of the default tests in the tests suite and part of a new group test 'security'. Since some of the tests require resources to be labeled, one must explicitly enable the resources to be allowed to be labeled by the test suite by running

./configure --enable-full-labeling

once. To turn it off, the '--enable-full-labeling' parameter should be omitted.

xen-unstable.hg/tools/xm-test/tests/Makefile.am +1 -0
Index: root/xen-unstable.hg/tools/xm-test/tests/Makefile.am
===================================================================
@@ -19,6 +19,7 @@ SUBDIRS = 	               	\
 		pause		\
 		reboot 		\
 		sched-credit	\
+		security-acm    \
 		sedf		\
 		shutdown	\
 		sysrq		\
xen-unstable.hg/tools/xm-test/tests/security-acm/01_security-acm_basic.py new file +118 -0

118 lines not on this page · raw message

xen-unstable.hg/tools/xm-test/tests/security-acm/Makefile.am new file +25 -0
Index: root/xen-unstable.hg/tools/xm-test/tests/security-acm/Makefile.am
===================================================================
@@ -0,0 +1,25 @@
+SUBDIRS =
+
+TESTS = 01_security-acm_basic.test \
+        02_security-acm_dom_start.test \
+        03_security-acm_dom_conflict.test \
+        04_security-acm_dom_res.test \
+        05_security-acm_dom_res_conf.test \
+        06_security-acm_dom_block_attach.test
+
+XFAIL_TESTS =
+
+EXTRA_DIST = $(TESTS) $(XFAIL_TESTS) acm_utils.py
+TESTS_ENVIRONMENT=@TENV@
+
+%.test: %.py
+	cp $< $@
+	chmod +x $@
+	@cp -f xm-test-security_policy.xml /etc/xen/acm-security/policies
+
+clean-local: am_config_clean-local
+
+am_config_clean-local:
+	rm -f *test
+	rm -f *log
+	rm -f *~
xen-unstable.hg/tools/xm-test/configure.ac +15 -0
Index: root/xen-unstable.hg/tools/xm-test/configure.ac
===================================================================
@@ -38,6 +38,20 @@ fi
 AM_CONDITIONAL(HVM, test x$ENABLE_HVM = xTrue)
 AC_SUBST(ENABLE_HVM)
 
+AC_ARG_ENABLE(full-labeling,
+	[[  --enable-full-labeling         allows the test suite to label all resources]],
+	[
+		ENABLE_LABELING=True
+	],[
+		ENABLE_LABELING=False
+	])
+
+if test "x$ENABLE_LABELING" = "xTrue"; then
+	echo "ACM_LABEL_RESOURCES = True" > lib/XmTestLib/acm_config.py
+else
+	rm -f lib/XmTestLib/acm_config.py*
+fi
+
 # Network needs to know ips to use: dhcp or a range of IPs in the form
 # of: 192.168.1.1-192.168.1.100
 # If not dhcp, a netmask and network address must be supplied. Defaults to
@@ -127,6 +141,7 @@ AC_CONFIG_FILES([
     tests/restore/Makefile
     tests/save/Makefile
     tests/sched-credit/Makefile
+    tests/security-acm/Makefile
     tests/sedf/Makefile
     tests/shutdown/Makefile
     tests/sysrq/Makefile
xen-unstable.hg/tools/xm-test/tests/security-acm/02_security-acm_dom_start.py new file +64 -0

64 lines not on this page · raw message

xen-unstable.hg/tools/xm-test/lib/XmTestLib/XenDomain.py +2 -0
Index: root/xen-unstable.hg/tools/xm-test/lib/XmTestLib/XenDomain.py
===================================================================
@@ -102,6 +102,8 @@ class XenConfig:
         self.defaultOpts["disk"] = []
         self.defaultOpts["vif"]  = []
         self.defaultOpts["vtpm"] = []
+        if isACMEnabled():
+            self.defaultOpts["access_control"] = []
 
         self.opts = self.defaultOpts
 
xen-unstable.hg/tools/xm-test/tests/security-acm/xm-test-security_policy.xml new file +110 -0

110 lines not on this page · raw message

xen-unstable.hg/tools/xm-test/tests/security-acm/03_security-acm_dom_conflict.py new file +60 -0

60 lines not on this page · raw message

xen-unstable.hg/tools/xm-test/tests/security-acm/acm_utils.py new file +15 -0
Index: root/xen-unstable.hg/tools/xm-test/tests/security-acm/acm_utils.py
===================================================================
@@ -0,0 +1,15 @@
+#!/usr/bin/python
+
+# Copyright (C) International Business Machines Corp., 2006
+# Author: Stefan Berger <[email protected]>
+
+from XmTestLib import *
+from XmTestLib.acm import *
+
+testpolicy = "xm-test"
+vmconfigfile = "/tmp/xm-test.conf"
+
+if not isACMEnabled():
+    SKIP("Not running this test since ACM not enabled.")
+
+ACMLoadPolicy(testpolicy)
xen-unstable.hg/tools/xm-test/tests/security-acm/04_security-acm_dom_res.py new file +69 -0

69 lines not on this page · raw message

xen-unstable.hg/tools/xm-test/tests/security-acm/05_security-acm_dom_res_conf.py new file +38 -0
Index: root/xen-unstable.hg/tools/xm-test/tests/security-acm/05_security-acm_dom_res_conf.py
===================================================================
@@ -0,0 +1,38 @@
+#!/usr/bin/python
+
+# Copyright (C) International Business Machines Corp., 2006
+# Author: Stefan Berger <[email protected]>
+#
+# A test that tries to start a domain using a resource that it is
+# not supposed to be able to use due to its labeling
+
+from XmTestLib import *
+from acm_utils import *
+import commands
+import os
+
+testlabel1 = "blue"
+resource1  = "phy:ram0"
+
+config = {"access_control":"policy=%s,label=%s" % (testpolicy,testlabel1),
+          "disk"          :"%s,hda1,w" % (resource1)}
+
+domain1 = XmTestDomain(name="domain-%s" % testlabel1,
+                       extraConfig=config)
+
+ACMLabelResource(resource1,"red")
+
+try:
+    domain1.start(noConsole=True)
+    # Should never get here
+    FAIL("Could start domain with resource that it is not supposed to access.")
+except DomainError, e:
+    #That's exactly what we want to have in this case
+    dummy = 0
+
+# Verify via dry-run
+status, output = traceCommand("xm dry-run /tmp/xm-test.conf | "
+                              "grep -v \"Dry Run\"")
+if not re.search("%s: DENIED" %resource1, output):
+    FAIL("'xm dry-run' did not show expected result that operation was NOT "
+         "permitted: \n%s" % output)
xen-unstable.hg/tools/xm-test/lib/XmTestLib/acm.py new file +80 -0

80 lines not on this page · raw message

xen-unstable.hg/tools/xm-test/tests/security-acm/06_security-acm_dom_block_attach.py new file +82 -0

82 lines not on this page · raw message

xen-unstable.hg/tools/xm-test/README +32 -0
Index: root/xen-unstable.hg/tools/xm-test/README
===================================================================
@@ -112,6 +112,38 @@ Xm-test will look for disk.img in the ra
 default.
 
 
+BUILDING for ACM Security Testing
+=================================
+
+A number of tests have been added to test the access control module (ACM)
+in the Xen hypervisor and the tools for supporting ACM. Those tests are
+located in the security-acm directory. If ACM support is compiled into Xen
+(see the user guide for how to do this) those tests can be run with the
+following command from the xm-test directory
+
+./runtest.sh [...] -g security <report>
+
+Some of these tests will work even without support of ACM by Xen.
+
+Several of these tests require the privilege of being allowed to label
+resources and will otherwise be skipped. By default the test suite
+is not allowed to automatically label resources since this may affect
+existing labels. To enable this, the test suite must be configured with
+the following parameter passed to the configure scripts (in addition to
+any other desired parameters)
+
+./configure --enable-full-labeling
+
+To revoke the privilege at a later time run the configure scripts without
+this parameter:
+
+./configure
+
+If a 'make' has previously been run for building the test suite, it is not
+necessary to run 'make' again just for enabling or disabling the automatic
+labeling of resources.
+
+
 Running
 =======
 
xen-unstable.hg/tools/xm-test/grouptest/default +1 -0
Index: root/xen-unstable.hg/tools/xm-test/grouptest/default
===================================================================
@@ -22,6 +22,7 @@ reboot
 restore
 save
 sched-credit
+security-acm
 shutdown
 sysrq
 unpause
xen-unstable.hg/tools/xm-test/grouptest/security new file +1 -0
Index: root/xen-unstable.hg/tools/xm-test/grouptest/security
===================================================================
@@ -0,0 +1 @@
+security-acm

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