All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Smalley <sds@tycho.nsa.gov>
To: Steve Lawrence <slawrence@tresys.com>,
	Dominick Grift <dominick.grift@gmail.com>
Cc: SELinux List <selinux@tycho.nsa.gov>
Subject: Re: [RFC] Source Policy, CIL, and High Level Languages
Date: Mon, 21 Jul 2014 10:51:35 -0400	[thread overview]
Message-ID: <53CD28F7.6030104@tycho.nsa.gov> (raw)
In-Reply-To: <53CD24EA.90903@tresys.com>

On 07/21/2014 10:34 AM, Steve Lawrence wrote:
> On 07/18/2014 02:10 PM, Stephen Smalley wrote:
>> On 07/18/2014 12:00 PM, Steve Lawrence wrote:
>>> On 07/10/2014 02:51 AM, Dominick Grift wrote:
>>>> On Wed, 2014-07-09 at 15:21 -0400, Steve Lawrence wrote:
>>>>> 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:
>>>>
>>>> <snip>
>>>>
>>>>
>>>> After associating user john with staff_u, johns home directory is
>>>> properly labeled (staff_u associated with /home/john). However, what is
>>>> strange here is that i cannot see staff_u home dir context specs
>>>> in /var/lib/selinux/targeted/active/modules/file_contexts.homedirs
>>>>  
>>>> Am i looking in the wrong place? How does SELinux know that staff_u
>>>> needs to be associated with /home/john
>>>>
>>>
>>> In the current upatream, file_contexts.homedirs is autogenerated and
>>> created in /etc/selinux/targeted/modules/active/ before it is copied to
>>> /etc/selinux/targeted/contexts/files. This file is not removed from the
>>> store, so it actually exists in two places.
>>>
>>> However, with the new source policy work, file_contexts.homedirs is
>>> generated in a temporary sandbox (not the policy store). The contents of
>>> the sandbox are copied to /etc/selinux, and then deleted at the end of
>>> the transaction. So the new source policy infrastructure no longer
>>> stores intermediate/final build files in the policy store.
>>>
>>> However, the migration script copies all the files from the old store to
>>> the new store, even including autogenerated files that the new source
>>> policy infrastructure will never look at or touch. This is just a bug in
>>> the migration script. We've updated the migration script to only migrate
>>> the files that actually need to be migrated (mostly *.local files). This
>>> has been rebased/pushed to github #integration branch.
>>
>> If I run semanage_migrate_etc_to_var.py -n on a clean (no
>> /var/lib/selinux at all) system, the /var/lib/selinux/targeted/active
>> directory contains a homedir_template and a netfilter_contexts file in
>> addition to the modules (and commit_num).  The first file is
>> automatically extracted from all of the file contexts during build and
>> the second is unused these days.  If I then run semodule -B (or omit the
>> -n option on migration), I further have file_contexts.template and
>> users_extra files under active, both of which are also generated.  I can
>> delete all four files and regenerate all but netfilter_contexts via
>> semodule -B.
>>
> 
> This has been fixed. Just needed to remove a couple more paths from the
> migration script and add a couple of unlink()'s in direct_commit().

Thanks.  I had a question though about the approach being used in the
new libsemanage for populating /var/lib/selinux/tmp/targeted initially
(not to be confused with /var/lib/selinux/targeted/tmp, which frankly I
do find rather confusing even though I understand it now).  libsemanage
copies the entire /etc/selinux/targeted directory layout (but not all
the files) under /var/lib/selinux/tmp/targeted, even directories that it
will never use (including e.g. the old modules directory), and then
copies the files it manages from /etc/selinux/targeted to the
corresponding /var/lib/selinux/tmp/targeted location before generating
the new policy.  This raises a few questions in my mind:

- Is it a good idea to depend on an already existing and populated
/etc/selinux/targeted directory tree?

- Why copy the entire directory structure rather than just creating the
directories we know we will need?

- What exactly is the dependency here?  If there is a mismatch between
the built files in /etc/selinux/targeted and the
/var/lib/selinux/targeted/active tree, can bad things happen?  Is
libsemanage depending on those prebuilt files being identical to what
would be generated if it did a rebuild from
/var/lib/selinux/targeted/active?  If not, why does it need them at all?

It looks to me as if possibly the old libsemanage relied on having
policy.kern locally available in the sandbox, then RH switched it to a
symlink to the installed file (wrongly, I think, as this would seemingly
break a revert to prior policy), and this made it also depend on the
installed policy file.  And it appears to assume that the directory
structure at least already exists under /etc/selinux/targeted.  But this
seems to take it a step further.  How do I bootstrap a policy install
with no prior /etc/selinux/targeted directory?

  reply	other threads:[~2014-07-21 14:51 UTC|newest]

Thread overview: 85+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53CD28F7.6030104@tycho.nsa.gov \
    --to=sds@tycho.nsa.gov \
    --cc=dominick.grift@gmail.com \
    --cc=selinux@tycho.nsa.gov \
    --cc=slawrence@tresys.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.