From: KaiGai Kohei <kaigai@kaigai.gr.jp>
To: Stephen Smalley <sds@tycho.nsa.gov>
Cc: KaiGai Kohei <kaigai@ak.jp.nec.com>,
jmorris@namei.org, paul.moore@hp.com, jbrindle@tresys.com,
selinux@tycho.nsa.gov
Subject: Re: [PATCH 1/3] Thread/Child-Domain Assignment (rev.4)
Date: Wed, 20 Aug 2008 18:41:08 +0900 [thread overview]
Message-ID: <48ABE6B4.8020505@kaigai.gr.jp> (raw)
In-Reply-To: <1218824000.29535.315.camel@moss-spartans.epoch.ncsc.mil>
Stephen Smalley wrote:
> On Thu, 2008-08-14 at 16:38 +0900, KaiGai Kohei wrote:
>> The following patch is the revised one for the kernel.
>>
>> Joshua suggested it is not necessary to bound type attributes
>> based on boundary relationship, and I also agreed this opinion.
>> The related code is dropped in this patch, and several code
>> cleanup contained.
>>
>> This change makes it unnecessary to deliver text represented
>> attributes into kernelspace, but related codes are still remained
>> for ...
>>
>> | Stephen Smalley wrote:
>> | An aside: Possibly we should add the attribute flag at the same time
>> | and leave the type attributes in the type symtab in the kernel policy,
>> | as previously discussed. Then the kernel policy won't be lacking any
>> | information needed for analysis. Just need to make sure that
>> | context_to_sid doesn't accept attributes in the type field.
>>
>> Stephen, could you point out the previous discussion?
>
> Keeping the type attribute names in the types symtab in the kernel
> policy allows tools like audit2why and apol to extract the original
> attribute names and display them. I originally shed them because the
> kernel didn't need to use that information and we don't want attribute
> names to be used in security contexts, but it costs us little to save
> them and check for them, and it benefits the tools.
>
>> Thanks,
>>
>> [1/3] thread-context-kernel.4.patch
>> It allows a multithreaded process to assign an individual
>> "more bounded" security context, and it also enables to
>> handle binary policy format version 24 in kernel space.
>>
>> Signed-off-by: KaiGai Kohei <kaigai@ak.jp.nec.com>
>> --
>> security/selinux/avc.c | 2 +-
>> security/selinux/hooks.c | 11 +-
>> security/selinux/include/avc.h | 4 +
>> security/selinux/include/security.h | 16 ++-
>> security/selinux/ss/policydb.c | 298 +++++++++++++++++++++++++++++++++--
>> security/selinux/ss/policydb.h | 5 +
>> security/selinux/ss/services.c | 227 +++++++++++++++++++++++----
>> 7 files changed, 515 insertions(+), 48 deletions(-)
>
>> diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
>> index bc1c3ae..0201227 100644
>> --- a/security/selinux/hooks.c
>> +++ b/security/selinux/hooks.c
>> @@ -5180,9 +5180,14 @@ static int selinux_setprocattr(struct task_struct *p,
>>
>> if (sid == 0)
>> return -EINVAL;
>> -
>> - /* Only allow single threaded processes to change context */
>> - if (atomic_read(&p->mm->mm_users) != 1) {
>> + /*
>> + * SELinux allows to change context in the following case only.
>> + * - Single threaded processes.
>> + * - Multi threaded processes intend to change its context into
>> + * more restricted domain (defined by TYPEBOUNDS statement).
>> + */
>> + if (atomic_read(&p->mm->mm_users) != 1
>> + && security_bounded_transition(tsec->sid, sid) != 0) {
>
> Alternatively you could defer the security_bounded_transition() check
> until the if (t->mm == mm && t != p) block. The mm_users check is a
> merely a quick check to see whether we need to probe further to
> determine whether or not there are any other threads sharing the mm.
The reason why I moved it to front of the block is we can skip the checks
whether the given process is multithreaded or not, if security_bounded_transition()
returns success.
However, I have no preference here. There may be a bit performance gain, but this
code is not invoked so frequently.
So, I'll revert it on the next revision.
>> @@ -62,6 +63,17 @@ enum {
>> extern int selinux_policycap_netpeer;
>> extern int selinux_policycap_openperm;
>>
>> +/* boundary related definitions */
>> +#define POLICYDB_BOUNDS_MAXDEPTH 4
>> +#define POLICYDB_BOUNDS_ATTRIBUTE_FLAG 0xffffffff
>> +/*
>> + * NOTE: When "bounds" field equals POLICYDB_BOUNDS_ATTRIBUTE_FLAG,
>> + * it means this entry is attribute, not a normal type.
>> + * Boundary feature also requires to deliver attribute info into
>> + * kernel space, because it has to notice boundary violation related
>> + * to type/attribute relationships.
>> + */
>
> It seems a bit ugly to overload the bounds field for this purpose vs.
> encoding it into the primary field as you suggest elsewhere.
OK, I'll encode these properties of type_datum into the primary field.
>> diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c
>> index 84f8cc7..f134322 100644
>> --- a/security/selinux/ss/policydb.c
>> +++ b/security/selinux/ss/policydb.c
> <snip>
>> +static int constraint_bounds_sanity_check(struct policydb *p,
>> + struct constraint_expr *cexpr)
>> +{
>> + struct user_datum *user;
>> + struct role_datum *role;
>> + struct type_datum *type;
>> + struct ebitmap_node *node;
>> + unsigned long bit;
>> +
>> + /* no need to check boundary constraint */
>> + if (cexpr->expr_type != CEXPR_NAMES)
>> + return 0;
>> +
>> + ebitmap_for_each_positive_bit(&cexpr->names, node, bit) {
>> + if (cexpr->attr & CEXPR_USER) {
>> + if (bit >= p->p_users.nprim)
>> + goto broken_ebitmap;
>> +
>> + user = p->user_val_to_struct[bit];
>> + if (user->bounds &&
>> + !ebitmap_get_bit(&cexpr->names, user->bounds - 1)) {
>> + printk(KERN_ERR
>> + "SELinux: boundary violated cexpr:"
>> + " CEXPR_NAMES: user:%s bounds:%s\n",
>> + p->p_user_val_to_name[user->value - 1],
>> + p->p_user_val_to_name[user->bounds - 1]);
>> + return -EINVAL;
>> + }
>
> What if cexpr->op is CEXPR_NEQ, e.g. the clause was something like
> (u1 != untrusteduser)? Or the entire clause is negated? I'm not sure
> you want to apply these bounds checks on constraints at all.
CEXPR_NEQ is dealt as simply negated ebitmap in the current implementation.
For example, (u1 != untrusteduser) requires a user is not "untrusteduser"
and its parent is not "untrusteduser" also.
Hmm, however, it may be a bit complicated/hard to understand rule.
The purpose of this check is to prevent to attach wider permissions on
bounded types, like mcssetcats attribute which means a privilege.
Here is an idea.
If the type_attribute_bounds_av() is put after constraint checks on avc
computing, we can make sure the purpose of bounds checks. It simply means
a bounded type cannot have wider permissions than its parent in TE rules
and constraints.
Thanks,
--
KaiGai Kohei <kaigai@kaigai.gr.jp>
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
next prev parent reply other threads:[~2008-08-20 9:41 UTC|newest]
Thread overview: 97+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-15 10:06 [RFC] An idea of thread/child-domain assignment KaiGai Kohei
2008-07-15 13:38 ` Stephen Smalley
2008-07-16 2:17 ` KaiGai Kohei
2008-07-16 6:08 ` KaiGai Kohei
2008-07-16 12:00 ` Stephen Smalley
2008-07-16 12:18 ` Stephen Smalley
2008-07-18 6:21 ` KaiGai Kohei
2008-07-23 3:58 ` KaiGai Kohei
2008-07-25 12:51 ` [PATCH 0/3] Thread/Child-Domain Assignment KaiGai Kohei
2008-07-25 13:03 ` [PATCH 1/3] " KaiGai Kohei
2008-07-25 13:44 ` Stephen Smalley
2008-07-25 17:06 ` Joshua Brindle
2008-07-26 8:24 ` KaiGai Kohei
2008-07-25 17:07 ` Joshua Brindle
2008-07-26 7:55 ` KaiGai Kohei
2008-07-26 17:28 ` Stephen Smalley
2008-07-26 18:14 ` Joshua Brindle
2008-07-28 3:06 ` KaiGai Kohei
2008-07-28 17:31 ` Stephen Smalley
2008-07-29 6:51 ` KaiGai Kohei
2008-07-29 12:06 ` Stephen Smalley
2008-07-30 14:10 ` Joshua Brindle
2008-07-30 14:57 ` Stephen Smalley
2008-08-01 6:26 ` KaiGai Kohei
2008-07-25 13:03 ` [PATCH 2/3] " KaiGai Kohei
2008-07-29 7:15 ` KaiGai Kohei
2008-07-29 12:25 ` Scott Schmit
2008-07-29 13:28 ` Stephen Smalley
2008-07-25 13:04 ` [PATCH 3/3] " KaiGai Kohei
2008-07-25 13:04 ` [PATCH 4/3] " KaiGai Kohei
2008-08-05 5:47 ` [PATCH 0/3] Thread/Child-Domain Assignment (rev.2) KaiGai Kohei
2008-08-05 5:55 ` [PATCH 1/3] " KaiGai Kohei
2008-08-05 12:53 ` Stephen Smalley
2008-08-06 10:05 ` KaiGai Kohei
2008-08-06 10:13 ` [PATCH 1/3] Thread/Child-Domain Assignment (rev.3) KaiGai Kohei
2008-08-14 7:38 ` [PATCH 1/3] Thread/Child-Domain Assignment (rev.4) KaiGai Kohei
2008-08-15 18:13 ` Stephen Smalley
2008-08-20 9:41 ` KaiGai Kohei [this message]
2008-08-25 12:32 ` [PATCH 1/3] Thread/Child-Domain Assignment (rev.6) KaiGai Kohei
2008-08-25 12:57 ` Stephen Smalley
2008-08-25 13:45 ` KaiGai Kohei
2008-08-26 7:11 ` KaiGai Kohei
2008-08-26 9:01 ` James Morris
2008-08-26 10:29 ` James Morris
2008-08-26 10:47 ` James Morris
2008-08-27 1:15 ` KaiGai Kohei
2008-08-27 8:04 ` [LTP][PATCH 1/2] Replacement of deprecated interfaces KaiGai Kohei
2008-08-27 12:14 ` Stephen Smalley
2008-08-28 6:26 ` KaiGai Kohei
2008-08-28 12:10 ` Subrata Modak
2008-08-28 12:52 ` KaiGai Kohei
2008-08-28 13:34 ` Subrata Modak
2008-10-23 9:48 ` Subrata Modak
2008-08-27 8:05 ` [LTP][PATCH 2/2] Add a new test case for bounds types KaiGai Kohei
2008-10-22 13:00 ` Subrata Modak
2008-10-23 8:10 ` KaiGai Kohei
2008-10-23 9:30 ` Subrata Modak
2008-08-27 1:11 ` [PATCH 1/3] Thread/Child-Domain Assignment (rev.6) KaiGai Kohei
2008-08-28 7:35 ` [PATCH] SELinux: add boundary support and thread context assignment KaiGai Kohei
2008-08-28 12:43 ` Stephen Smalley
2008-08-28 15:06 ` James Morris
2008-08-05 5:55 ` [PATCH 2/3] Thread/Child-Domain Assignment (rev.2) KaiGai Kohei
2008-08-06 10:14 ` [PATCH 2/3] Thread/Child-Domain Assignment (rev.3) KaiGai Kohei
2008-10-09 17:10 ` [PATCH 2/3] Thread/Child-Domain Assignment (rev.2) Joshua Brindle
2008-10-10 1:19 ` KaiGai Kohei
2008-10-10 1:22 ` Joshua Brindle
2008-08-05 5:55 ` [PATCH 3/3] " KaiGai Kohei
2008-08-06 10:13 ` [PATCH 3/3] Thread/Child-Domain Assignment (rev.3) KaiGai Kohei
2008-08-25 12:32 ` [PATCH 3/3] Thread/Child-Domain Assignment (rev.4) KaiGai Kohei
2008-08-28 15:51 ` Joshua Brindle
2008-08-29 1:54 ` KaiGai Kohei
2008-08-29 3:01 ` Joshua Brindle
2008-09-01 6:26 ` KaiGai Kohei
2008-09-01 9:08 ` [PATCH] libsepol : Add support for a new policy version (POLICYDB_VERSION_BOUNDARY) KaiGai Kohei
2008-09-01 14:47 ` [PATCH 3/3] Thread/Child-Domain Assignment (rev.4) Joshua Brindle
2008-09-01 16:11 ` KaiGai Kohei
2008-09-09 2:04 ` [PATCH 3/3] Thread/Child-Domain Assignment (rev.6) KaiGai Kohei
2008-09-12 18:17 ` Joshua Brindle
2008-09-12 23:20 ` KaiGai Kohei
2008-09-15 13:44 ` Joshua Brindle
2008-09-16 1:50 ` KaiGai Kohei
2008-09-30 14:00 ` Joshua Brindle
2008-10-01 7:53 ` KaiGai Kohei
2008-10-01 19:56 ` Joshua Brindle
2008-10-04 23:30 ` Joshua Brindle
2008-10-06 9:19 ` KaiGai Kohei
2008-10-06 19:13 ` Joshua Brindle
2008-10-07 6:39 ` KaiGai Kohei
2008-10-09 15:30 ` Joshua Brindle
2008-10-09 17:00 ` Joshua Brindle
2008-10-10 0:57 ` KaiGai Kohei
2008-10-09 17:11 ` Joshua Brindle
2008-10-06 12:30 ` Stephen Smalley
2008-10-06 19:13 ` Joshua Brindle
2008-08-11 17:58 ` [PATCH 0/3] Thread/Child-Domain Assignment (rev.2) Joshua Brindle
2008-08-13 5:53 ` KaiGai Kohei
2008-08-14 8:55 ` A toy of SQL injection (Re: [PATCH 0/3] Thread/Child-Domain Assignment) KaiGai Kohei
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=48ABE6B4.8020505@kaigai.gr.jp \
--to=kaigai@kaigai.gr.jp \
--cc=jbrindle@tresys.com \
--cc=jmorris@namei.org \
--cc=kaigai@ak.jp.nec.com \
--cc=paul.moore@hp.com \
--cc=sds@tycho.nsa.gov \
--cc=selinux@tycho.nsa.gov \
/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.