Skip to contentSkip to conversation

libxl: Exposed Flask XSM functionality

PATCH Superseded Machon Gregory 2 participants 4 messages Apr 15, 2011 – Jun 2, 2011

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 libxl: Exposed Flask XSM functionality

Adds support for assigning a label to domains, obtaining and setting the current enforcing mode, and loading a policy with xl command and libxl header when the Flask XSM is in use. Adheres to the changes made by the patch to remove exposure of libxenctrl/libxenstore headers via libxl.h.

 tools/libxl/libxl_flask.c |   71 ++++++++++++++++++
 tools/libxl/Makefile        |    2
 tools/libxl/libxl.c         |    1
 tools/libxl/libxl.h         |    8 ++
 tools/libxl/libxl.idl       |    3
 tools/libxl/xl.h            |    3
 tools/libxl/xl_cmdimpl.c    |  165 
++++++++++++++++++++++++++++++++++++++++++--
 tools/libxl/xl_cmdtable.c   |   18 ++++
 8 files changed, 261 insertions(+), 10 deletions(-)
Signed-off-by [email protected]
Signature · 2 lines
Machon Gregory
National Information Assurance Research Lab (NIARL)
tools/libxl/Makefile +1 -1
diff -r b5165fb66b56 tools/libxl/Makefile
@@ -35,7 +35,7 @@
 LIBXL_OBJS = flexarray.o libxl.o libxl_create.o libxl_dm.o libxl_pci.o \
 			libxl_dom.o libxl_exec.o libxl_xshelp.o libxl_device.o \
 			libxl_internal.o libxl_utils.o libxl_uuid.o $(LIBXL_OBJS-y)
-LIBXL_OBJS += _libxl_types.o
+LIBXL_OBJS += _libxl_types.o libxl_flask.o
 
 $(LIBXL_OBJS): CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest) $(CFLAGS_libxenstore) $(CFLAGS_libblktapctl)
 
tools/libxl/libxl.c +1 -0
diff -r b5165fb66b56 tools/libxl/libxl.c
@@ -342,6 +342,7 @@
 {
     memcpy(&(xlinfo->uuid), xcinfo->handle, sizeof(xen_domain_handle_t));
     xlinfo->domid = xcinfo->domain;
+    xlinfo->ssidref = xcinfo->ssidref;
 
     xlinfo->dying    = !!(xcinfo->flags&XEN_DOMINF_dying);
     xlinfo->shutdown = !!(xcinfo->flags&XEN_DOMINF_shutdown);
tools/libxl/libxl.h +8 -0
diff -r b5165fb66b56 tools/libxl/libxl.h
@@ -555,6 +555,14 @@
     return domid > 0 && domid < DOMID_FIRST_RESERVED;
 }
 
+int libxl_flask_context_to_sid(libxl_ctx *ctx, char *buf, size_t len,
+                               uint32_t *ssidref);
+int libxl_flask_sid_to_context(libxl_ctx *ctx, uint32_t ssidref, char **buf, 
+                               size_t *len);
+int libxl_flask_getenforce(libxl_ctx *ctx);
+int libxl_flask_setenforce(libxl_ctx *ctx, int mode);
+int libxl_flask_loadpolicy(libxl_ctx *ctx, void *policy, uint32_t size);
+
 /* common paths */
 const char *libxl_sbindir_path(void);
 const char *libxl_bindir_path(void);
tools/libxl/libxl.idl +2 -1
diff -r b5165fb66b56 tools/libxl/libxl.idl
@@ -28,6 +28,7 @@
 libxl_dominfo = Struct("dominfo",[
     ("uuid",        libxl_uuid),
     ("domid",       domid),
+    ("ssidref",     uint32),
     ("running",     BitField(uint8, 1)),
     ("blocked",     BitField(uint8, 1)),
     ("paused",      BitField(uint8, 1)),
@@ -77,7 +78,7 @@
     ("hvm",          bool),
     ("hap",          bool),
     ("oos",          bool),
-    ("ssidref",      integer),
+    ("ssidref",      uint32),
     ("name",         string),
     ("uuid",         libxl_uuid),
     ("xsdata",       libxl_key_value_list),
tools/libxl/libxl_flask.c new file +71 -0

71 lines not on this page · raw message

tools/libxl/xl.h +3 -0
diff -r b5165fb66b56 tools/libxl/xl.h
@@ -87,6 +87,9 @@
 int main_cpupoolcpuremove(int argc, char **argv);
 int main_cpupoolmigrate(int argc, char **argv);
 int main_cpupoolnumasplit(int argc, char **argv);
+int main_getenforce(int argc, char **argv);
+int main_setenforce(int argc, char **argv);
+int main_loadpolicy(int argc, char **argv);
 
 void help(const char *command);
 
tools/libxl/xl_cmdimpl.c +158 -7

221 lines not on this page · raw message

tools/libxl/xl_cmdtable.c +17 -1
diff -r b5165fb66b56 tools/libxl/xl_cmdtable.c
@@ -36,7 +36,8 @@
       "List information about all/some domains",
       "[options] [Domain]\n",
       "-l, --long              Output all VM details\n"
-      "-v, --verbose           Prints out UUIDs",
+      "-v, --verbose           Prints out UUIDs and security context\n"
+      "-Z, --context           Prints out security context"
     },
     { "destroy",
       &main_destroy,
@@ -364,6 +365,21 @@
       "Splits up the machine into one CPU pool per NUMA node",
       "",
     },
+    { "getenforce",
+      &main_getenforce,
+      "Returns the current enforcing mode of the Flask Xen security module",
+      "",
+    },
+    { "setenforce",
+      &main_setenforce,
+      "Sets the current enforcing mode of the Flask Xen security module",
+      "<1|0|Enforcing|Permissive>",
+    },
+    { "loadpolicy",
+      &main_loadpolicy,
+      "Loads a new policy int the Flask Xen security module",
+      "<policy file>",
+    },
 };
 
 int cmdtable_len = sizeof(cmd_table)/sizeof(struct cmd_spec);

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

#1 lore raw

Machon Gregory writes ("[Xen-devel] [PATCHv3] libxl: Exposed Flask XSM functionality"):

Quoted 4 lines

Adds support for assigning a label to domains, obtaining and setting the current enforcing mode, and loading a policy with xl command and libxl header when the Flask XSM is in use. Adheres to the changes made by the patch to remove exposure of libxenctrl/libxenstore headers via libxl.h.

Thanks for this but I'm afraid it needs refreshing for latest xen-unstable.

Regards,
Ian.

#2 lore raw

PATCH v4 1/1 libxl: Exposed Flask XSM functionality

Refresh of the patch that adds support for assigning a label to domains, obtaining and setting the current enforcing mode, and loading a policy with xl command and libxl header when the Flask XSM is in use. Adheres to the changes made by the patch to remove exposure of libxenctrl/libxenstore headers via libxl.h.

 tools/libxl/libxl_flask.c |   71 ++++++++++++++++++
 tools/libxl/Makefile        |    2
 tools/libxl/libxl.c         |    1
 tools/libxl/libxl.h         |    8 ++
 tools/libxl/libxl.idl       |    3
 tools/libxl/xl.h            |    3
 tools/libxl/xl_cmdimpl.c    |  165 
++++++++++++++++++++++++++++++++++++++++++--
 tools/libxl/xl_cmdtable.c   |   18 ++++
 8 files changed, 261 insertions(+), 10 deletions(-)
Signed-off-by [email protected]
Signature · 2 lines
Machon Gregory
National Information Assurance Research Lab (NIARL)
tools/libxl/Makefile +1 -1
diff -r 75421c62b19f tools/libxl/Makefile
@@ -35,7 +35,7 @@
 LIBXL_OBJS = flexarray.o libxl.o libxl_create.o libxl_dm.o libxl_pci.o \
 			libxl_dom.o libxl_exec.o libxl_xshelp.o libxl_device.o \
 			libxl_internal.o libxl_utils.o libxl_uuid.o $(LIBXL_OBJS-y)
-LIBXL_OBJS += _libxl_types.o
+LIBXL_OBJS += _libxl_types.o libxl_flask.o
 
 $(LIBXL_OBJS): CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest) $(CFLAGS_libxenstore) $(CFLAGS_libblktapctl)
 
tools/libxl/libxl.c +1 -0
diff -r 75421c62b19f tools/libxl/libxl.c
@@ -342,6 +342,7 @@
 {
     memcpy(&(xlinfo->uuid), xcinfo->handle, sizeof(xen_domain_handle_t));
     xlinfo->domid = xcinfo->domain;
+    xlinfo->ssidref = xcinfo->ssidref;
 
     xlinfo->dying    = !!(xcinfo->flags&XEN_DOMINF_dying);
     xlinfo->shutdown = !!(xcinfo->flags&XEN_DOMINF_shutdown);
tools/libxl/libxl.h +8 -0
diff -r 75421c62b19f tools/libxl/libxl.h
@@ -499,6 +499,14 @@
     return domid > 0 && domid < DOMID_FIRST_RESERVED;
 }
 
+int libxl_flask_context_to_sid(libxl_ctx *ctx, char *buf, size_t len,
+                               uint32_t *ssidref);
+int libxl_flask_sid_to_context(libxl_ctx *ctx, uint32_t ssidref, char **buf, 
+                               size_t *len);
+int libxl_flask_getenforce(libxl_ctx *ctx);
+int libxl_flask_setenforce(libxl_ctx *ctx, int mode);
+int libxl_flask_loadpolicy(libxl_ctx *ctx, void *policy, uint32_t size);
+
 /* common paths */
 const char *libxl_sbindir_path(void);
 const char *libxl_bindir_path(void);
tools/libxl/libxl.idl +2 -1
diff -r 75421c62b19f tools/libxl/libxl.idl
@@ -89,6 +89,7 @@
 libxl_dominfo = Struct("dominfo",[
     ("uuid",        libxl_uuid),
     ("domid",       libxl_domid),
+    ("ssidref",      uint32),
     ("running",     bool),
     ("blocked",     bool),
     ("paused",      bool),
@@ -138,7 +139,7 @@
     ("hvm",          bool),
     ("hap",          bool),
     ("oos",          bool),
-    ("ssidref",      integer),
+    ("ssidref",      uint32),
     ("name",         string),
     ("uuid",         libxl_uuid),
     ("xsdata",       libxl_key_value_list),
tools/libxl/libxl_flask.c new file +71 -0

71 lines not on this page · raw message

tools/libxl/xl.h +3 -0
diff -r 75421c62b19f tools/libxl/xl.h
@@ -87,6 +87,9 @@
 int main_cpupoolcpuremove(int argc, char **argv);
 int main_cpupoolmigrate(int argc, char **argv);
 int main_cpupoolnumasplit(int argc, char **argv);
+int main_getenforce(int argc, char **argv);
+int main_setenforce(int argc, char **argv);
+int main_loadpolicy(int argc, char **argv);
 
 void help(const char *command);
 
tools/libxl/xl_cmdimpl.c +158 -7

221 lines not on this page · raw message

tools/libxl/xl_cmdtable.c +17 -1
diff -r 75421c62b19f tools/libxl/xl_cmdtable.c
@@ -36,7 +36,8 @@
       "List information about all/some domains",
       "[options] [Domain]\n",
       "-l, --long              Output all VM details\n"
-      "-v, --verbose           Prints out UUIDs",
+      "-v, --verbose           Prints out UUIDs and security context\n"
+      "-Z, --context           Prints out security context"
     },
     { "destroy",
       &main_destroy,
@@ -364,6 +365,21 @@
       "Splits up the machine into one CPU pool per NUMA node",
       "",
     },
+    { "getenforce",
+      &main_getenforce,
+      "Returns the current enforcing mode of the Flask Xen security module",
+      "",
+    },
+    { "setenforce",
+      &main_setenforce,
+      "Sets the current enforcing mode of the Flask Xen security module",
+      "<1|0|Enforcing|Permissive>",
+    },
+    { "loadpolicy",
+      &main_loadpolicy,
+      "Loads a new policy int the Flask Xen security module",
+      "<policy file>",
+    },
 };
 
 int cmdtable_len = sizeof(cmd_table)/sizeof(struct cmd_spec);

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

Applied
#3 lore raw

Machon Gregory writes ("[Xen-devel] [PATCHv4] libxl: Exposed Flask XSM functionality"):

Quoted 5 lines

Refresh of the patch that adds support for assigning a label to domains, obtaining and setting the current enforcing mode, and loading a policy with xl command and libxl header when the Flask XSM is in use. Adheres to the changes made by the patch to remove exposure of libxenctrl/libxenstore headers via libxl.h.

Applied, thanks.

Ian.