All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC] Source Policy, CIL, and High Level Languages
@ 2014-07-09 19:21 Steve Lawrence
  2014-07-10  6:51 ` Dominick Grift
                   ` (4 more replies)
  0 siblings, 5 replies; 85+ messages in thread
From: Steve Lawrence @ 2014-07-09 19:21 UTC (permalink / raw)
  To: SELinux List

In January, we sent an RFC [1] to update userspace to integrate CIL
[2] and source policy. And in April, we sent an updated RFC [3] which
added support for high level languages and a tool to convert policy
package (pp) files to CIL. After getting some good feedback, we have
made some more changes, mostly to maintain ABI compatibility. The
major changes made since the last patchset are:

- Change how semanage_set_root was re-added to use the source policy
  infrastructure. Fixes were made so that semanage.conf was looked for
  inside the root. Also adds an semanage_root() function to get the
  current root.
- In previous patchsets, the semanage_module_upgrade* and
  semanage_module_install_base* functions were removed from the API,
  and semanage_module_install* had modified parameters. However, these
  changes broke the API and ABI. To maintain ABI compatibility, we've
  now added symbolic versioning to support the old version of the
  functions, which now just call the new install functions. semodule
  is updated to support --base and --upgrade, but with the addition of
  a deprecation message. API compatability is not maintained.
- Likewise, symbolic versioning was added to support the old module
  enable/disable functions, which call the new enable/disable
  functions.
- Modify the libsepol Makefile to now make including CIL optional via
  the DISABLE_CIL build flag. This only affects libsepol (not
  libsemanage), primarily so that SE for Android does not need to
  include unused CIL cruft.

With these changes, ABI compatibility is maintained. Additionally, we
have tested these changes with the userspace tests and against the
kernel test suite, and no new failures were discovered. We have
also tested this patchset with both Fedora 20 policy and with reference
policy and found no errors.

Because of the size of the patchset (67 file changes, ~8300
insertions, ~1800 deletions), all the changes have been pushed to the
selinux git repository to the 'integration' branch for
comments/review. Unlike the previous RFCs, for simplicity there is now
only a single branch, containing three types of changes:

Reverts
   Reverts changes made to master that conflict with the new source
   policy infrastructure (e.g. how paths are handled,
   enabled/disable modules). Rather than dealing with a large amount
   of conflicts with the source policy work, it was easier to just
   remove the commits that added conflicting features, rebase the old
   source policy work on top of that, and add back any features in a
   manner consistent with source policy. The only conflicts were
   related to enabling/disabling of modules, and semanage_set_root.

Source Policy
   This is a rebase of the old src-policy branch on top of the
   reverted commits.  The goal of these changes is to improve the API
   for module handling, add support for source policies, module
   priorities, enabling/disabling of modules, and moving the policy
   store from /etc/selinux/<store>/ to /var/lib/selinux/<store>/.

CIL Integration
   These changes build CIL into libsepol, and updates libsepol,
   libsemanage, semodule, and semanage to work with and understand CIL
   files and manage /var/lib/selinux and /etc/selinux. Switching to
   CIL has a few side effects, such as removing base modules,
   versions, and upgrades.

   This also adds a new tool (installed to
   /usr/libexec/selinux/hll/pp), which is an HLL compiler that
   converts binary pp modules to CIL. The infrastructure to use this
   compiler (or any other HLL compiler) was added to compile HLL
   modules to CIL, which is accomplished by writing the HLL data to
   the stdin of the compiler and reading the equivilent CIL from
   stdout. The resulting CIL is then cached in the policy store so
   this compilation does not need to take place during future store
   updates. Cached CIL modules can be ignored using a new semodule
   flag (-C/--ignore-cache) or a new configuration option in
   semanage.conf (ignore-cache). Other configuration options were
   added to semanage.conf to manage the path to HLL compilers
   (compiler-directory) and the policy store (store-root). Semodule
   was also modified to support changing the policy store with the
   -S/--store-root option.

   Lastly, the CIL integration changes required changes to the API,
   but symbolic versioning was used to maintain ABI compatibility.
   Because of this, the .so version is no longer incremented like in
   the previous version of this RFC.

With these changes, it is possible to build and manage SELinux
policy using pp and CIL modules and the familiar semodule/semanage
tools.

To make this easier to experiment with and test, below are the steps
needed to install the updated userspace and migrate a minimal Fedora 20
installation to the new policy store.

Thanks, and we look forward to any questions/comments.

- Steve

[1] http://marc.info/?l=selinux&m=138921403805934&w=2
[2] https://github.com/SELinuxProject/cil/wiki
[3] http://marc.info/?l=selinux&m=139878606630921&w=2


Steps to Install SELinux Userspace with source policy, CIL, and HLL

# Start with a fresh Fedora 20-x86_64 Mimimal Installation

# Install SELinux userspace dependencies
$ yum install audit-libs-devel bison bzip2-devel dbus-devel
dbus-glib-devel flex flex-static gcc git glib2-devel libcap-ng-devel
libcgroup-devel libsepol-static pcre-devel python-devel python-IPy
setools-devel swig ustr-devel

# Update to the latest targeted policy
$ yum update selinux-policy-targeted

# Clone the repos and checkout branches
$ git clone -b integration https://github.com/SELinuxProject/selinux.git
$ git clone -b master https://github.com/SELinuxProject/cil.git

# Create a symlink to the cil repo so CIL can be built into libsepol
$ ln -s ~/cil/ selinux/libsepol/cil

# Install SELinux userspace with CIL integration and HLL support
$ make -C selinux LIBDIR=/usr/lib64 SHLIBDIR=/lib64 install install-pywrap

# Migrate to the new source policy infrastructure
$ ./selinux/libsemanage/utils/semanage_migrate_etc_to_var.py

# List the installed modules, showing priority and HLL
$ semodule --list=full

^ permalink raw reply	[flat|nested] 85+ messages in thread
* [RFC] Source Policy, CIL, and High Level Languages
@ 2014-04-29 14:59 Steve Lawrence
  2014-05-01 12:38 ` Dominick Grift
  0 siblings, 1 reply; 85+ messages in thread
From: Steve Lawrence @ 2014-04-29 14:59 UTC (permalink / raw)
  To: SELinux List

[-- Attachment #1: Type: text/plain, Size: 5511 bytes --]

In January, we sent an RFC [1] for updating userspace to integrate CIL
[2] and source policy. We received a lot of great feedback (thanks to
Richard Haines, Dominick Grift, Stephen Smalley, and Dan Walsh) and are
back with some changes, and again looking for more comments.

This keeps most of the changes as the previous RFC, including moving the
policy store to /var/lib/selinux and replacing binary modules with
support for CIL. Based on feedback from the previous email we have made
changes and added new features to this patchset, specifically:

- Support for preserve tunables
- Infrastructure to support High Level Languages (HLLs)
- A new HLL compiler which converts .pp files to CIL

With the new HLL infrastructure and the pp to CIL compiler, we have
successfully migrated a Fedora 20 system to the new /var/lib/selinux
layout, treating the existing .pp files as high level languages,
compiling them to CIL, and generating a binary policy file that is
semantically equivalent. This infrastructure allows for one to
transition to a full CIL policy, but still allows for backwards
compatiability with systems that rely either fully or partially on pp
modules.

Because of the size of the patchset (66 file changes, ~8000 insertions,
~2000 deletions), all the changes have been pushed to the selinux git
repository in three branches for comments/review. Each branch builds on
the other, with their purposes described below:

src-revert:
   Reverts changes made to master that conflict with the src-policy
   branch (e.g. how paths are handled, enabled/disable modules). Rather
   than dealing with a large amount of conflicts with the source policy
   work, it was easier to just remove the commits which add conflicting
   features, rebase the old source policy work on top of that, and add
   back any features in a manner consistent with source policy.

src-policy:
   This is a rebase of the old src-policy branch onto the src-revert
   branch, with some minor bug fixes squashed in. The goal of this
   patchset is to improve the API for module handling, add support for
   source policies, module priorities, enabling/disabling of modules,
   and moving the policy store from /etc/selinux/<store>/ to
   /var/lib/selinux/<store>/. Due to the use of -p/--path and
   -P/--preserve-tunables, the --priority short option was (pretty
   arbitrarily) changed to -X.

integration:
   This branch includes most of the more recent work. This builds CIL
   into libsepol, and updates libsepol, libsemanage, semodule, and
   semanage to work with and understand CIL files and manage
   /var/lib/selinux and /etc/selinux. Switching to CIL has a few side
   effects, such as removing base modules, versions, and upgrades. This
   also adds a new tool (installed to /usr/libexec/selinux/hll/pp),
   which is an HLL compiler that converts binary pp modules to CIL. The
   infrasture to use this compiler (or any other HLL compiler) was added
   to compile HLL modules to CIL, which is accomplished by writing the
   HLL data to the stdin of the compiler and reading the equivilent CIL
   from stdout. The resulting CIL is then cached in the policy store so
   this compilation does not need to take place during future store
   updates. Cached CIL modules can be ignored using a new semodule flag
   (-C/--ignore-cache) or a new configuration option in semanage.conf
   (ignore-cache). Other configuration options were added to
   semanage.conf to manage the path to HLL compilers
   (compiler-directory) and the policy store (store-root). Semodule was
   also modified to support changing the policy store with the with
   -S/--store-root option. Lastly, because much of the API is changed,
   the .so version numbers of libsemanage and libsepol were bumped to
   version 2.

With these three branches, it is possible to build and manage SELinux
policy using pp and CIL modules and the familiar semodule/semanage
tools.

To make this easier to experiment with and test, below are the steps
needed to install the updated userspace and migrate a minimal Fedora 20
installation to the new policy store.

Thanks, and we look forward to receive your feedback.

- Steve

[1] http://marc.info/?l=selinux&m=138921403805934&w=2
[2] http://userspace.selinuxproject.org/trac/wiki/CilDesign



Steps to Install SELinux Userspace with source policy, CIL, and HLL

# Start with a fresh Fedora 20-x86_64 Mimimal Installation

# Install SELinux userspace dependencies
$ yum install audit-libs-devel bison bzip2-devel dbus-devel
dbus-glib-devel flex flex-static gcc git glib2-devel libcap-ng-devel
libcgroup-devel libsepol-static pcre-devel python-devel python-IPy
setools-devel swig ustr-devel

# Disable the IRC module (this is due to an invalid filecon that has
since been fixed)
semodule --disable irc

# Clone the repos and checkout branches
$ git clone -b integration http://oss.tresys.com/git/selinux.git
$ git clone https://bitbucket.org/jwcarter/secilc.git

# Create a symlink to secilc so CIL can be built into libsepol
$ ln -s ~/secilc/ selinux/libsepol/cil

# Install SElinux userspace with CIL integration and HLL support
$ make -C selinux LIBDIR=/usr/lib64 SHLIBDIR=/lib64 install install-pywrap

# Migrate to the new source policy infrastructure
$ ./selinux/libsemanage/utils/semanage_migrate_etc_to_var.py --norebuild

# Install gnome module that removes a duplicate filename transition (see
attached)
$ semodule --install gnome.cil

# List the installed modules, showing priority and HLL
$ semodule --list=full

[-- Attachment #2: gnome.cil --]
[-- Type: application/vnd.ms-artgalry, Size: 79226 bytes --]

^ permalink raw reply	[flat|nested] 85+ messages in thread

end of thread, other threads:[~2014-08-18 22:37 UTC | newest]

Thread overview: 85+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-09 19:21 [RFC] Source Policy, CIL, and High Level Languages Steve Lawrence
2014-07-10  6:51 ` Dominick Grift
2014-07-10 12:19   ` Steve Lawrence
2014-07-10 12:35   ` Stephen Smalley
2014-07-10 12:52     ` Dominick Grift
2014-07-10 13:09       ` Dominick Grift
2014-07-10 13:12         ` Stephen Smalley
2014-07-10 13:26           ` Dominick Grift
2014-07-10 13:38             ` Stephen Smalley
2014-07-10 13:45               ` Dominick Grift
2014-07-11 15:02                 ` Steve Lawrence
2014-07-15 20:11                   ` Steve Lawrence
2014-07-10 15:02             ` Stephen Smalley
2014-07-11 17:20   ` Steve Lawrence
2014-07-14 16:48     ` Stephen Smalley
2014-07-14 16:53       ` Stephen Smalley
2014-07-14 17:08         ` Stephen Smalley
2014-07-14 17:12           ` Steve Lawrence
2014-07-14 17:49             ` Stephen Smalley
2014-07-15 19:56               ` Steve Lawrence
2014-07-16 14:16                 ` Stephen Smalley
2014-07-16 14:21                   ` Stephen Smalley
2014-07-16 14:26                     ` Stephen Smalley
2014-07-16 14:33                       ` Stephen Smalley
2014-07-16 15:11                         ` Steve Lawrence
2014-07-16 15:53                           ` Dominick Grift
2014-07-16 15:58                             ` Dominick Grift
2014-07-16 19:00                             ` Stephen Smalley
2014-07-17 13:49                               ` Steve Lawrence
2014-07-17 14:02                                 ` Stephen Smalley
2014-07-17 18:02                                 ` Stephen Smalley
2014-07-17 18:58                                   ` Steve Lawrence
2014-07-17 19:10                                     ` Stephen Smalley
2014-07-17 19:48                                       ` Stephen Smalley
2014-07-17 20:04                                         ` Steve Lawrence
2014-07-17 20:37                                           ` Stephen Smalley
2014-07-17 20:50                                             ` Daniel J Walsh
2014-07-17 20:52                                             ` Daniel J Walsh
2014-07-23 19:24                                               ` Stephen Smalley
2014-07-24 12:48                                                 ` Daniel J Walsh
2014-07-18 12:59                                             ` Steve Lawrence
2014-07-18 14:30                                               ` Stephen Smalley
2014-07-18 15:57                                                 ` Steve Lawrence
2014-07-22 15:05                                               ` James Carter
2014-07-18 14:13                                             ` Christopher J. PeBenito
2014-07-17 19:51                                       ` Steve Lawrence
2014-07-22 14:47                                     ` James Carter
2014-07-16 15:43                 ` Steve Lawrence
2014-07-14 17:33           ` Dominick Grift
2014-07-18 16:00   ` Steve Lawrence
2014-07-18 18:10     ` Stephen Smalley
2014-07-21 14:34       ` Steve Lawrence
2014-07-21 14:51         ` Stephen Smalley
2014-07-21 17:50           ` Steve Lawrence
2014-08-01 14:51             ` Steve Lawrence
2014-08-01 17:46               ` Stephen Smalley
2014-08-04 14:07                 ` Steve Lawrence
2014-08-18 22:37                 ` Steve Lawrence
2014-07-10 13:52 ` Stephen Smalley
2014-07-10 14:06   ` Dominick Grift
2014-07-10 14:09   ` Steve Lawrence
2014-07-10 14:58     ` James Carter
2014-07-10 13:59 ` Stephen Smalley
2014-07-10 14:53   ` Steve Lawrence
2014-07-10 14:11 ` Stephen Smalley
2014-07-10 14:13   ` Stephen Smalley
2014-07-10 14:17   ` Steve Lawrence
2014-07-10 14:20     ` Stephen Smalley
2014-07-10 14:23   ` Dominick Grift
2014-07-10 14:25     ` Stephen Smalley
2014-07-10 14:34       ` Stephen Smalley
2014-07-10 14:50         ` Dominick Grift
2014-07-10 14:43       ` Dominick Grift
2014-07-10 14:30 ` Stephen Smalley
2014-07-10 14:50   ` Stephen Smalley
2014-07-10 15:05     ` Steve Lawrence
2014-07-10 15:08       ` Stephen Smalley
2014-07-10 16:04   ` Steve Lawrence
  -- strict thread matches above, loose matches on Subject: below --
2014-04-29 14:59 Steve Lawrence
2014-05-01 12:38 ` Dominick Grift
2014-05-01 12:57   ` Steve Lawrence
2014-05-01 13:24     ` Dominick Grift
2014-05-01 13:27       ` Dominick Grift
2014-05-01 13:31         ` Dominick Grift
2014-05-01 14:01           ` Steve Lawrence

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.