selinux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Smalley <sds@tycho.nsa.gov>
To: Ondrej Mosnacek <omosnace@redhat.com>
Cc: SElinux list <selinux@vger.kernel.org>,
	Petr Lautrbach <plautrba@redhat.com>
Subject: Re: [RFC PATCH 2/2] semodule: support changing policyvers via command line
Date: Thu, 6 Feb 2020 14:22:47 -0500	[thread overview]
Message-ID: <e716fb3d-e858-c546-7a9e-3aa2ccabb105@tycho.nsa.gov> (raw)
In-Reply-To: <b1014a44-296a-f417-850e-969986cdce0a@tycho.nsa.gov>

On 2/6/20 1:47 PM, Stephen Smalley wrote:
> On 2/6/20 10:35 AM, Stephen Smalley wrote:
>> On 2/6/20 10:28 AM, Ondrej Mosnacek wrote:
>>> On Thu, Feb 6, 2020 at 3:52 PM Stephen Smalley <sds@tycho.nsa.gov> 
>>> wrote:
>>>>
>>>> On 2/6/20 9:19 AM, Ondrej Mosnacek wrote:
>>>>> On Thu, Feb 6, 2020 at 2:44 PM Stephen Smalley <sds@tycho.nsa.gov> 
>>>>> wrote:
>>>> Seems like you could just have selinux-policy depend on the version of
>>>> libsepol used to build it.
>>>>
>>>> The problem with both your current approach and your proposed one is
>>>> that it means that if a user or package does a semodule -B (or any 
>>>> other
>>>> semodule/semanage command) on their system, that will generate the
>>>> latest policy.N version supported by their libsepol, and libselinux 
>>>> will
>>>> give precedence to that policy at load time.  So if they then later
>>>> update their selinux-policy package, and it only installs a prebuilt
>>>> policy.(N-1), that won't actually get loaded - libselinux
>>>> selinux_mkload_policy() will keep using the policy.N file (which may be
>>>> older).  Unless I'm missing something.
>>>
>>> Hm, yes, you're right... It seems we have no other choice than to
>>> better handle the dependency between selinux-policy and libsepol.
>>> Please disregard this patch series.
>>
>> Historically, I think we got to this point because originally 
>> selinux-policy would run semodule from %post to generate the policy.N 
>> file at install time, thereby always generating the latest version 
>> supported, and then later switched to pre-building policy.N at package 
>> build time and just dropping it in place at install time to avoid the 
>> runtime and memory overhead.  Particularly because it could otherwise 
>> fail at install time on low-memory systems/VMs.
>>
>> As a separate matter, one could possibly argue that libselinux 
>> selinux_mkload_policy() should give preference to the newest file 
>> (i.e. timestamp-based) rather than the latest policy version.  But 
>> even if we were to make that change going forward, it won't help with 
>> existing distro releases.
> 
> I guess that doesn't help either since the timestamp of the policy.N 
> file generated at package build may still be older than that of any 
> locally generated one, even if the package was installed later.

Looks like selinux-policy.spec has preInstall and postInstall macros 
that are triggering a rebuild of policy (semodule -B) if there are any 
/etc/selinux/targeted/policy/policy.* files that differ from the 
packaged one.  So if the user did a semodule -B or any other 
semodule/semanage command previously that generated a newer policy 
version (or the same version but with different contents) then the 
package install is going to run semodule -B and re-generate it anyway.
I guess it isn't broken then.

      reply	other threads:[~2020-02-06 19:22 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-06 13:12 [RFC PATCH 0/2] userspace: Allow changing version of kernel policy built by semodule Ondrej Mosnacek
2020-02-06 13:12 ` [RFC PATCH 1/2] libsemanage: support changing policy version via API Ondrej Mosnacek
2020-02-06 13:12 ` [RFC PATCH 2/2] semodule: support changing policyvers via command line Ondrej Mosnacek
2020-02-06 13:45   ` Stephen Smalley
2020-02-06 14:19     ` Ondrej Mosnacek
2020-02-06 14:52       ` Stephen Smalley
2020-02-06 15:28         ` Ondrej Mosnacek
2020-02-06 15:35           ` Stephen Smalley
2020-02-06 18:47             ` Stephen Smalley
2020-02-06 19:22               ` Stephen Smalley [this message]

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=e716fb3d-e858-c546-7a9e-3aa2ccabb105@tycho.nsa.gov \
    --to=sds@tycho.nsa.gov \
    --cc=omosnace@redhat.com \
    --cc=plautrba@redhat.com \
    --cc=selinux@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).