All of lore.kernel.org
 help / color / mirror / Atom feed
From: Leesoo Ahn <lsahn@wewakecorp.com>
To: Casey Schaufler <casey@schaufler-ca.com>
Cc: linux-security-module@vger.kernel.org
Subject: Re: [LSM Stacking] SELinux policy inside container affects aprocesson Host
Date: Mon, 24 Jul 2023 11:29:25 +0900	[thread overview]
Message-ID: <a05afacc-4c93-89ec-b7ab-0d26cc874eff@wewakecorp.com> (raw)
In-Reply-To: <f21a05f9-249d-e362-6ae4-32499d190a21@schaufler-ca.com>

2023-07-18 오전 12:51에 Casey Schaufler 이(가) 쓴 글:
> On 7/17/2023 8:24 AM, Leesoo Ahn wrote:
>  > 23. 7. 7. 23:20에 Paul Moore 이(가) 쓴 글:
>  >> On Fri, Jul 7, 2023 at 4:29 AM Leesoo Ahn <lsahn@wewakecorp.com> wrote:
>  >>  > 2023-07-06 오후 10:43에 Paul Moore 이(가) 쓴 글:
[...]>  >> 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. Even in a world where
>  >> SELinux is fully namespaced, it would likely still be necessary to run
>  >> some type of SELinux policy on the host (initial namespace) in order
>  >> to support SELinux policies in the containers.
>  >
>  > Thank you for the reply. It really helped me to know the current
>  > status of them and what to do now.
>  >
>  > Just a little information for who is interested in the stacking that
>  > we decided to branch the LSM hooks by which lsm the current process is
>  > in instead of entirely calling them in order.
> 
> Could you describe your approach more fully?

As far as I know, the current stacking feature is implemented calling 
the entire hooks in order of 'lsm=' boot parameter. But our desire must 
be calling a proper hook at a time by a task's current LSM, for instance 
Apparmor 'or' SELinux instead of 'and'.

And so we have been considering adding two new hooks which work as the 
same as the origin hooks but additionally branch to a proper hook 
function with the information of current LSM by calling lsm_task_ilsm().

The following changes are a part of our approach,

------ code part ------
#define call_int_hook_by_ilsm(FUNC, ILSM, IRC, ...) ({                 \
        int RC = IRC;                                           \
        do {                                                    \
                struct security_hook_list *P;                   \
                int id; \
                                                                \
                id = (ILSM == LSMBLOB_INVALID) \
                        ? lsm_slotlist[0]->id \
                        : lsm_slotlist[ILSM]->id; \
                hlist_for_each_entry(P, &security_hook_heads.FUNC, list) { \
                        if (P->lsmid->slot != LSMBLOB_NOT_NEEDED && id 
!= P->lsmid->id) \
                                continue; \
                        RC = P->hook.FUNC(__VA_ARGS__);         \
                        if (RC != 0)                            \
                                break;                          \
                }                                               \
        } while (0);                                            \
        RC;                                                     \
})

[...]

int ilsm = lsm_task_ilsm(current);
ret = call_int_hook_by_ilsm(mmap_addr, ilsm, 0, addr);
------------

We are still worrying about the part of calling lsm_task_ilsm() with 
'current', it seems dangerous in some unknown cases.

What do you think about this approach, Casey?

Best regards,
Leesoo

  reply	other threads:[~2023-07-24  2:36 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           ` Leesoo Ahn [this message]
2023-07-24 21:35             ` [LSM Stacking] SELinux policy inside container affects aprocesson Host 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
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=a05afacc-4c93-89ec-b7ab-0d26cc874eff@wewakecorp.com \
    --to=lsahn@wewakecorp.com \
    --cc=casey@schaufler-ca.com \
    --cc=linux-security-module@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 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.