All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Moore <paul@paul-moore.com>
To: "Dr. Greg" <greg@enjellic.com>
Cc: Leesoo Ahn <lsahn@wewakecorp.com>,
	Casey Schaufler <casey@schaufler-ca.com>,
	linux-security-module@vger.kernel.org
Subject: Re: [LSM Stacking] SELinux policy inside container affects a processon Host
Date: Tue, 8 Aug 2023 10:32:51 -0400	[thread overview]
Message-ID: <CAHC9VhRy0=N+kJ8QETgQv8nkyA6_B+7t9QFiQCxC8MFU7A_E=Q@mail.gmail.com> (raw)
In-Reply-To: <20230808064014.GA31533@wind.enjellic.com>

On Tue, Aug 8, 2023 at 2:41 AM Dr. Greg <greg@enjellic.com> wrote:
> On Sun, Aug 06, 2023 at 03:25:32PM -0400, Paul Moore wrote:
> > On Sun, Aug 6, 2023 at 1:16???PM Dr. Greg <greg@enjellic.com> wrote:
> > > On Fri, Jul 28, 2023 at 10:54:23AM +0900, Leesoo Ahn wrote:
> > > > 2023-07-07 ?????? 11:20??? Paul Moore ???(???) ??? ???:
> > > > >On Fri, Jul 7, 2023 at 4:29???AM Leesoo Ahn <lsahn@wewakecorp.com> wrote:
> > > >
> > > > [...]
> > > >
> > > > >
> > > > >What you are looking for is a combination of LSM stacking and
> > > > >individual LSM namespacing. Sadly, I think the communications around
> > > > >LSM stacking have not been very clear on this and I worry that many
> > > > >people are going to be disappointed with LSM stacking for this very
> > > > >reason.
> > > > >
> > > > >While stacking of LSMs is largely done at the LSM layer, namespacing
> > > > >LSMs such that they can be customized for individual containers
> > > > >requires work to be done at the per-LSM level as each LSM is
> > > > >different. AppArmor already has a namespacing concept, but SELinux
> > > > >does not. Due to differences in the approach taken by the two LSMs,
> > > > >namespacing is much more of a challenge for SELinux, largely due to
> > > > >issues around filesystem labeling. We have not given up on the idea,
> > > > >but we have yet to arrive at a viable solution for namespacing
> > > > >SELinux.
> > > > >
> > > > >If you are interested in stacking SELinux and AppArmor, I believe the
> > > > >only practical solution is to run SELinux on the host system (initial
> > > > >namespace) and run AppArmor in the containers.
> > >
> > > > Paul, I don't get that SELinux on the host system and run AppArmor
> > > > in the containers is the only practical solution. Could you please
> > > > explain that in more details?
> > >
> > > It appears that Paul is extremely busy, so I thought the 'Quixote
> > > Group' would try and offer some reflections that may help with your
> > > efforts.
>
> > My apologies, yes I am rather busy at the moment, but I also stopped
> > following this thread a while ago as it didn't seem to be going
> > anywhere meaningful.  I happen to read this last email while I'm
> > waiting in an airport, so let me try and provide a quick explanation
> > about why running SELinux only in a container is a bad idea.
> >
> > As you probably know, the Linux kernel has no concept of a container,
> > it only supports subsystem specific namespaces, e.g. mount namespace,
> > network namespace, etc.  SELinux does not provide a subsystem
> > namespace, and it does not generally concern itself with other
> > subsystem names.  From a SELinux perspective there is no difference
> > between a process running in the host namespace or a
> > container/namespace; both are treated the same with access control
> > decisions made based on the processes' SELinux domain, the type of the
> > target resource, and the access requested.
> >
> > If one were to load a SELinux policy inside a container, even if it
> > were allowed, the system would likely behave in unexpected ways as the
> > container-loaded policy will take effect across the entire system, not
> > just inside the container.
>
> All reasonable and consistent, with what we had previously written
> with respect to there being no notion of LSM namespacing.
>
> To further assist Leesoo and others who may be following this, you had
> suggested the following earlier in this thread:
>
> Paul> If you are interested in stacking SELinux and AppArmor, I
> Paul> believe the only practical solution is to run SELinux on the
> Paul> host system (initial namespace) and run AppArmor in the
> Paul> containers.
>
> Which would seem to apply that in a 'stacked' LSM configuration of
> SELinux and AppArmor, there would be a possibility of using the two
> LSM's without them 'colliding', the equivalent of what could be
> considered a 'nested' LSM implementation.

SELinux applies access control across the entire system, regardless of
what namespaces may be configured on the system.  Loading a SELinux
policy in the host/initial-namespace during early boot helps ensure
proper labeling of system entities and a better user experience;
loading a SELinux policy in a container/namespace can lead to
surprising and unpredictable results across the whole of the system.
AppArmor is different in that it has support for
containers/namespaces.  Running SELinux on the host and AppArmor in a
container isn't so much about preventing collisions, they are still
simultaneously running and applying their security policies, it is
more about ensuring the LSMs, the admins, and the users all see
compatible views of the system.

Please do not confuse any of the above as a 'nested' or namespaced LSM
layer; the current in-progress LSM stacking is simply that: the
ability to stack some combination of LSMs in a few prescribed
configurations.  Talking about 'nesting' or 'namespacing' at the LSM
layer is confusing at best, and misleading at the worst.

-- 
paul-moore.com

  reply	other threads:[~2023-08-08 17:46 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-06  5:12 [LSM Stacking] SELinux policy inside container affects a process on Host Leesoo Ahn
2023-07-06 13:43 ` Paul Moore
2023-07-07  0:35   ` Serge E. Hallyn
2023-07-07  1:17     ` [LSM Stacking] SELinux policy inside container affects a processon Host Leesoo Ahn
2023-07-07  8:28   ` [LSM Stacking] SELinux policy inside container affects a process on Host Leesoo Ahn
2023-07-07 14:20     ` Paul Moore
2023-07-07 16:50       ` Casey Schaufler
2023-07-07 21:41         ` Paul Moore
2023-07-18 10:34         ` Dr. Greg
2023-07-18 17:20           ` Casey Schaufler
2023-07-19 18:45             ` Dr. Greg
2023-07-20  0:21               ` Casey Schaufler
2023-07-21 23:55                 ` Dr. Greg
2023-07-17 15:24       ` [LSM Stacking] SELinux policy inside container affects a processon Host Leesoo Ahn
2023-07-17 15:51         ` Casey Schaufler
2023-07-24  2:29           ` [LSM Stacking] SELinux policy inside container affects aprocesson Host Leesoo Ahn
2023-07-24 21:35             ` Casey Schaufler
2023-07-25  3:16               ` [LSM Stacking] SELinux policy inside container affects aprocessonHost Leesoo Ahn
2023-07-28  1:54       ` [LSM Stacking] SELinux policy inside container affects a processon Host Leesoo Ahn
2023-08-06 17:16         ` Dr. Greg
2023-08-06 19:25           ` Paul Moore
2023-08-08  6:40             ` Dr. Greg
2023-08-08 14:32               ` Paul Moore [this message]
2023-07-07 17:51     ` [LSM Stacking] SELinux policy inside container affects a process on Host Dr. Greg

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='CAHC9VhRy0=N+kJ8QETgQv8nkyA6_B+7t9QFiQCxC8MFU7A_E=Q@mail.gmail.com' \
    --to=paul@paul-moore.com \
    --cc=casey@schaufler-ca.com \
    --cc=greg@enjellic.com \
    --cc=linux-security-module@vger.kernel.org \
    --cc=lsahn@wewakecorp.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.